Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Commit 6379270

Browse files
author
Chris Wiechmann
committed
New parameter: DROP_TRACE_MESSAGE_LEVELS added
1 parent 07e0895 commit 6379270

File tree

9 files changed

+41
-9
lines changed

9 files changed

+41
-9
lines changed

.github/workflows/logstash.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
echo Using MEMCACHED: $MEMCACHED
4949
./logstash-filter-verifier --diff-command="diff -y" --keep-env=API_BUILDER_SSL_CERT --keep-env=API_BUILDER_URL --keep-env=MEMCACHED ./logstash/test/jms/test-opentrafficlog-jms.json ./logstash/pipelines/OpenTrafficPipeline.conf
5050
./logstash-filter-verifier --diff-command="diff -y" --keep-env=API_BUILDER_SSL_CERT --keep-env=API_BUILDER_URL --keep-env=MEMCACHED ./logstash/test/beatsInput/test-index-creation-lookup.json ./logstash/pipelines/BeatsInputPipeline.conf
51-
./logstash-filter-verifier --diff-command="diff -y" --keep-env=API_BUILDER_SSL_CERT --keep-env=API_BUILDER_URL --keep-env=MEMCACHED ./logstash/test/http/test-tracemessages.json ./logstash/pipelines/TraceMessagesPipeline.conf
51+
./logstash-filter-verifier --diff-command="diff -y" --keep-env=API_BUILDER_SSL_CERT --keep-env=API_BUILDER_URL --keep-env=MEMCACHED --keep-env=DROP_TRACE_MESSAGE_LEVELS ./logstash/test/http/test-tracemessages.json ./logstash/pipelines/TraceMessagesPipeline.conf
5252
./logstash-filter-verifier --diff-command="diff -y" --keep-env=API_BUILDER_SSL_CERT --keep-env=API_BUILDER_URL --keep-env=MEMCACHED ./logstash/test/http/test-tracemessages-gmt-4.json ./logstash/pipelines/TraceMessagesPipeline.conf
5353
./logstash-filter-verifier --diff-command="diff -y" --keep-env=API_BUILDER_SSL_CERT --keep-env=API_BUILDER_URL --keep-env=MEMCACHED ./logstash/test/http/test-events.json ./logstash/pipelines/EventsPipeline.conf
5454
./logstash-filter-verifier --diff-command="diff -y" --keep-env=API_BUILDER_SSL_CERT --keep-env=API_BUILDER_URL --keep-env=MEMCACHED ./logstash/test/http/test-opentrafficlog.json ./logstash/pipelines/OpenTrafficPipeline.conf
@@ -57,6 +57,7 @@ jobs:
5757
env:
5858
API_BUILDER_URL: 'http://localhost:8080'
5959
MEMCACHED: 'localhost:11211'
60+
DROP_TRACE_MESSAGE_LEVELS: DEBUG
6061
# This is not relevant as we test with HTTP
6162
# But it's required by Logstash to be a valid certificate
6263
API_BUILDER_SSL_CERT: "./config/certificates/apibuilder4elastic.crt"

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2121
- Added Quartely- and Yearly-API-Request dashboars in addition to the existing Real-Time Dashboard
2222
- Added support for Transactions [#83](https://github.com/Axway-API-Management-Plus/apigateway-openlogging-elk/issues/83)
2323
- If Current-User request to ANM fails, API-Builder is now trying it again [#135](https://github.com/Axway-API-Management-Plus/apigateway-openlogging-elk/issues/135)
24+
- New optional parameter: DROP_TRACE_MESSAGE_LEVELS to skip indexing of certain trace messages [#XXX](https://github.com/Axway-API-Management-Plus/apigateway-openlogging-elk/issues/XXX)
2425

2526
## [3.3.2] 2021-08-30
2627
### Fixed

UPDATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ On the other hand, the API builder Docker image, as a central component of the s
5555
| 3.3.0 | [X](#api-builderlogstashmemcached) | [X](#api-builderlogstashmemcached) | - | - | - | - | [X](#parameters)|- | 7.12.1 | |
5656
| 3.3.1 | [X](#api-builderlogstashmemcached) | - | - | - | - | - | [X](#parameters)|- | 7.12.1 | |
5757
| 3.3.2 | [X](#api-builderlogstashmemcached) | - | - | - | - | - | - |- | 7.12.1 | |
58-
| 3.4.0 | [X](#api-builderlogstashmemcached) | [X](#api-builderlogstashmemcached) | - | - | - | [X](#dashboards)| - |[X](#elastic-config)| 7.14.0 | Unreleased |
58+
| 3.4.0 | [X](#api-builderlogstashmemcached) | [X](#api-builderlogstashmemcached) | - | - | - | [X](#dashboards)| [X](#parameters)|[X](#elastic-config)| 7.14.0 | Unreleased |
5959

6060
### Update from Version 1.0.0
6161

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ services:
2222
- API_BUILDER_URL=${API_BUILDER_URL}
2323
- API_BUILDER_SSL_CERT=${API_BUILDER_SSL_CERT}
2424
- MEMCACHED=${MEMCACHED}
25+
- DROP_TRACE_MESSAGE_LEVELS=${DROP_TRACE_MESSAGE_LEVELS}
2526
ports:
2627
- 5044:5044
2728
volumes:

env-sample

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,22 @@ ELASTIC_VERSION=7.14.0
358358
# PAYLOAD_HANDLING_ENABLED=false
359359

360360
# ----------------------------------------------------------------------------------------------
361-
# Disables the Elasticsearch setup flows in API-Builder that are used to configure.
361+
# By default, all generated trace messages are forwarded to Elasticsearch. No matter if DEBUG
362+
# or DATA.
363+
# If you do not want this, you can configure which trace levels should be dropped.
364+
# For example, if you set DEBUG,DATA these two log levels will not be stored in ElasticSearch.
365+
# Please note that this will of course result in the messages not appearing in the
366+
# API Gateway traffic monitor. Also it is not possible to change this parameter afterwards and
367+
# expect Trace-Messages are re-processed.
368+
# Used-By: Logstash for Traffic and General-Trace messages
369+
# Defaults to all levels are forwarded.
370+
# DROP_TRACE_MESSAGE_LEVELS=DEBUG,DATA
371+
372+
# ----------------------------------------------------------------------------------------------
373+
# Disables the setup flows in API-Builder that are used to configure Elasticsearch.
362374
# If you run more than one API builder, you can set this parameter to true, as it is not
363-
# necessary. However, it is technically not a problem to have multiple API builders running
364-
# with setup flow enabled.
375+
# necessary. However, it is technically not a problem to have multiple API-Builders running
376+
# with setup flows enabled.
365377
# Used-By: API-Builder
366378
# Defaults to false.
367379
# DISABLE_SETUP_FLOWS=true

helm/templates/elasticApimLogstash/logstash-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ data:
2424
ELASTICSEARCH_HOSTS: {{ required "The value global.elasticsearchHosts is missing." .Values.global.elasticsearchHosts | quote }}
2525
ELASTICSEARCH_CERT: {{ required "The path to the CA for Logstash to Elasticsearch communication is missing" .Values.global.elasticsearchCa | quote }}
2626
API_BUILDER_URL: "https://{{ include "apim4elastic.fullname" . }}-apibuilder4elastic:{{ .Values.apibuilder4elastic.port }}"
27+
DROP_TRACE_MESSAGE_LEVELS: {{ .Values.logstash.dropTraceMessageLevels | quote }}
2728
API_BUILDER_SSL_CERT: {{ required "The path to the CA for Logstash to Elasticsearch communication is missing" .Values.global.elasticsearchCa | quote }}
2829
MEMCACHED: localhost:11211
2930
LOG_LEVEL: info

helm/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ logstash:
206206
# See parameter LS_JAVA_OPTS in env-sample for more details
207207
logstashJavaOpts: "-Xmx6g -Xms6g"
208208
fullnameOverride: "axway-elk-apim4elastic"
209+
dropTraceMessageLevels: "DEBUG|DATA"
209210
# Number of replicas for Logstash
210211
replicas: 2
211212
# Injects the environment variables from the ConfigMaps and Secrets into the

logstash/pipelines/TraceMessagesPipeline.conf

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ input { pipeline { address => "TraceMessages" } }
44
filter {
55
# The logtype has been set by Filebeat to distinct between OpenLog and TraceLog
66
if [message] =~ /^#/ {
7-
drop { }
7+
drop { id => "Drop comments" }
88
}
99
if [message] =~ /^\s*$/ {
10-
drop { }
10+
drop { id => "Drop empty lines" }
1111
}
1212
grok {
1313
match => { "message" => "%{LOGLEVEL:level}%{SPACE}(?<loggedDate>\d{2}\/.{3}\/\d{4}:\d{2}:\d{2}:\d{2}\.\d{3})%{SPACE}\[%{WORD:fluff}\:%{WORD:correlationId}\]\s?%{GREEDYDATA:body}" }
1414
}
15+
mutate {
16+
add_field => { "[@metadata][dropLevels]" => "${DROP_TRACE_MESSAGE_LEVELS}" }
17+
}
18+
if( [level] in [@metadata][dropLevels] ) {
19+
drop { id => "Log-Level based drop" }
20+
}
21+
1522
date {
1623
# LoggedDate is provided like so 13/Jul/2020:15:26:35.108
1724
match => [ "loggedDate", "dd/MMM/yyyy:HH:mm:ss.SSS" ]

logstash/test/http/test-tracemessages.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,28 @@
6262
{
6363
"description": "Trace line causing Logstash to fail and stop responding",
6464
"input": [
65-
"DEBUG 03/Mar/2021:14:22:51.073 [19607:988d3f603f0063aef0c65174] Event Log config [enabled=true, configFile= NotDefined, outputDir=/opt/axway/apigateway/events, header={\"type\":\"header\", \"logCreationTime\":\"2021-03-03 14:22:51.073\", \"hostname\":\"api-gateway\", \"domainId\":\"fb69e91d-123b-49bc-a964-d76b8a30a810\", \"groupId\":\"group-2\", \"groupName\":\"EXP_GROUP_INT\", \"serviceId\":\"instance-1\", \"serviceName\":\"EXP_API_GW_INT_1\", \"version\":\"v7.7.0-Internal\"}, writeSystemEventFreqSecs=60, customMessageAttributes=[], customSelectorAttributes=[${http.headers[\"X-CorrelationID\"]}, ${http.headers[\"User-Agent\"]}]]"
65+
"INFO 03/Mar/2021:14:22:51.073 [19607:988d3f603f0063aef0c65174] Event Log config [enabled=true, configFile= NotDefined, outputDir=/opt/axway/apigateway/events, header={\"type\":\"header\", \"logCreationTime\":\"2021-03-03 14:22:51.073\", \"hostname\":\"api-gateway\", \"domainId\":\"fb69e91d-123b-49bc-a964-d76b8a30a810\", \"groupId\":\"group-2\", \"groupName\":\"EXP_GROUP_INT\", \"serviceId\":\"instance-1\", \"serviceName\":\"EXP_API_GW_INT_1\", \"version\":\"v7.7.0-Internal\"}, writeSystemEventFreqSecs=60, customMessageAttributes=[], customSelectorAttributes=[${http.headers[\"X-CorrelationID\"]}, ${http.headers[\"User-Agent\"]}]]"
6666
],
6767
"expected": [
6868
{
6969
"@timestamp": "2021-03-03T14:22:51.073Z",
7070
"correlationId": "988d3f603f0063aef0c65174",
71-
"level": "DEBUG",
71+
"level": "INFO",
7272
"message": " Event Log config [enabled=true, configFile= NotDefined, outputDir=/opt/axway/apigateway/events, header={\"type\":\"header\", \"logCreationTime\":\"2021-03-03 14:22:51.073\", \"hostname\":\"api-gateway\", \"domainId\":\"fb69e91d-123b-49bc-a964-d76b8a30a810\", \"groupId\":\"group-2\", \"groupName\":\"EXP_GROUP_INT\", \"serviceId\":\"instance-1\", \"serviceName\":\"EXP_API_GW_INT_1\", \"version\":\"v7.7.0-Internal\"}, writeSystemEventFreqSecs=60, customMessageAttributes=[], customSelectorAttributes=[${http.headers[\"X-CorrelationID\"]}, ${http.headers[\"User-Agent\"]}]]",
7373
"processInfo": {
7474
"gatewayName": "API-Gateway 2",
7575
"gatewayRegion": "EU"
7676
}
7777
}
7878
]
79+
},
80+
{
81+
"description": "A trace message on level debug should be dropped",
82+
"input": [
83+
"DEBUG 03/Mar/2021:14:22:51.073 [19607:988d3f603f0063aef0c65174] A sample message on level DATA"
84+
],
85+
"expected": [
86+
]
7987
}
8088
]
8189
}

0 commit comments

Comments
 (0)