Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
926b8ee
First test
Mar 28, 2022
4bb28b2
Update OpenTrafficPipeline.conf
Mar 28, 2022
69cc594
Update OpenTrafficPipeline.conf
Mar 28, 2022
fc9c1a9
Update OpenTrafficPipeline.conf
Mar 28, 2022
5d77c9e
Update OpenTrafficPipeline.conf
Mar 28, 2022
f1310bd
Update OpenTrafficPipeline.conf
Mar 28, 2022
229f399
Update OpenTrafficPipeline.conf
Mar 28, 2022
b3b5733
Update OpenTrafficPipeline.conf
Mar 28, 2022
7f53bf7
Update OpenTrafficPipeline.conf
Mar 28, 2022
6174cf5
Update OpenTrafficPipeline.conf
Mar 28, 2022
5bbe691
Update OpenTrafficPipeline.conf
Mar 28, 2022
867ed18
Update OpenTrafficPipeline.conf
Mar 28, 2022
46df310
Update OpenTrafficPipeline.conf
Mar 28, 2022
a3e0e2b
Update OpenTrafficPipeline.conf
Mar 28, 2022
1f4fc5e
Update OpenTrafficPipeline.conf
Mar 28, 2022
937e537
Update OpenTrafficPipeline.conf
Mar 28, 2022
424e932
Update OpenTrafficPipeline.conf
Mar 28, 2022
5cdd82f
Update OpenTrafficPipeline.conf
Mar 28, 2022
8fde3b3
Update OpenTrafficPipeline.conf
Mar 28, 2022
d8aa82f
Update OpenTrafficPipeline.conf
Mar 28, 2022
421081c
Update OpenTrafficPipeline.conf
Mar 28, 2022
513193c
Update OpenTrafficPipeline.conf
Mar 28, 2022
5df7858
Update OpenTrafficPipeline.conf
Mar 28, 2022
5ca8ef0
Update OpenTrafficPipeline.conf
Mar 28, 2022
5c8a3f4
Update OpenTrafficPipeline.conf
Mar 28, 2022
23f4130
Update OpenTrafficPipeline.conf
Mar 28, 2022
c28cf38
Update OpenTrafficPipeline.conf
Mar 28, 2022
74306d1
Update OpenTrafficPipeline.conf
Mar 28, 2022
5ce7f52
Update OpenTrafficPipeline.conf
Mar 28, 2022
33d970f
Update logstash.yml
Mar 28, 2022
0647c43
Test with a more valid configuration
Mar 28, 2022
882cd77
Update logstash.yml
Mar 28, 2022
9f2c0b7
Update OpenTrafficPipeline.conf
Mar 28, 2022
429f6e3
Update OpenTrafficPipeline.conf
Mar 28, 2022
22e3db3
Update OpenTrafficPipeline.conf
Mar 28, 2022
8aecb2d
Added documentation for new parameter CACHE_API_PATHS
Mar 29, 2022
ea2c47f
Reactived all Logstash pipeline tests
Mar 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/logstash.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
# echo Using API_BUILDER_URL: $API_BUILDER_URL
# echo Using MEMCACHED: $MEMCACHED
# echo Using GEOIP_ENABLED: $GEOIP_ENABLED, GEOIP_CUSTOM_ATTRIBUTE: ${GEOIP_CUSTOM_ATTRIBUTE}, GEOIP_CACHE_SIZE: ${GEOIP_CACHE_SIZE}
# ./logstash-filter-verifier --diff-command="diff -y" --logstash-output --keep-env=API_BUILDER_SSL_CERT --keep-env=API_BUILDER_URL --keep-env=MEMCACHED --keep-env=GEOIP_ENABLED --keep-env=GEOIP_CUSTOM_ATTRIBUTE --keep-env=GEOIP_CACHE_SIZE --keep-env=EVENTLOG_CUSTOM_ATTR ./logstash/test/http/test-events.json ./logstash/pipelines/EventsPipeline.conf
# ./logstash-filter-verifier --diff-command="diff -y" --logstash-output --keep-env=API_BUILDER_SSL_CERT --keep-env=API_BUILDER_URL --keep-env=MEMCACHED --keep-env=CACHE_API_PATHS ./logstash/test/http/test-opentrafficlog.json ./logstash/pipelines/OpenTrafficPipeline.conf

run: |
echo Using API_BUILDER_URL: $API_BUILDER_URL
Expand All @@ -54,7 +54,7 @@ jobs:
./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
./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
./logstash-filter-verifier --diff-command="diff -y" --keep-env=API_BUILDER_SSL_CERT --keep-env=API_BUILDER_URL --keep-env=MEMCACHED --keep-env=GEOIP_ENABLED --keep-env=GEOIP_CUSTOM_ATTRIBUTE --keep-env=GEOIP_CACHE_SIZE --keep-env=EVENTLOG_CUSTOM_ATTR ./logstash/test/http/test-events.json ./logstash/pipelines/EventsPipeline.conf
./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
./logstash-filter-verifier --diff-command="diff -y" --keep-env=API_BUILDER_SSL_CERT --keep-env=API_BUILDER_URL --keep-env=MEMCACHED --keep-env=CACHE_API_PATHS./logstash/test/http/test-opentrafficlog.json ./logstash/pipelines/OpenTrafficPipeline.conf
./logstash-filter-verifier --diff-command="diff -y" --keep-env=API_BUILDER_SSL_CERT --keep-env=API_BUILDER_URL --keep-env=MEMCACHED ./logstash/test/filetransfer/test-opentrafficlog-filetransfer.json ./logstash/pipelines/OpenTrafficPipeline.conf
./logstash-filter-verifier --diff-command="diff -y" --keep-env=API_BUILDER_SSL_CERT --keep-env=API_BUILDER_URL --keep-env=MEMCACHED ./logstash/test/domainAudit/test-domain-audit-events.json ./logstash/pipelines/DomainAuditPipeline.conf
env:
Expand All @@ -70,6 +70,7 @@ jobs:
# This is not relevant as we test with HTTP
# But it's required by Logstash to be a valid certificate
API_BUILDER_SSL_CERT: "./config/certificates/apibuilder4elastic.crt"
CACHE_API_PATHS: "/petstore/v2, /api/v1/banana, /api/v2/banana"
- name: API-Builder Logs
if: ${{ always() }}
run: |
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Wait 5 instead of 2 seconds, before trying to attach ILM-Policy to Index-Template
- It may take a bit longer to obtain Custom-Properties from API-Manager for the Index-Template

### Added
- Added support to cache APIs with Path-Parameter more efficiently to reduce document ingest latency
- See the new parameter: `CACHE_API_PATHS` for more details.

## [4.3.0] 2022-03-11
### Added
- Added Geo-Location map of API-Requests
Expand Down
1 change: 1 addition & 0 deletions UPDATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ On the other hand, the API builder Docker image, as a central component of the s

| Ver | API-Builder | Logstash | Memcached | Filebeat | ANM-Config | Dashboards | Params |Elastic-Config | ELK-Ver. | Notes |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: |:---: | :---: | :--- |
| 4.4.0 | [X](#api-builderlogstashmemcached) | [X](#api-builderlogstashmemcached) | - | - | - | - | [X](#parameters)|- | [7.17.1](#update-elastic-stack-version) | |
| 4.3.0 | [X](#api-builderlogstashmemcached) | [X](#api-builderlogstashmemcached) | - | - | - | [X](#dashboards)| [X](#parameters)|[X](#elastic-config)| [7.17.1](#update-elastic-stack-version) | |
| 4.2.0 | [X](#api-builderlogstashmemcached) | - | - | - | - | [X](#dashboards)| [X](#parameters)|- | [7.17.0](#update-elastic-stack-version) | |
| 4.1.0 | [X](#api-builderlogstashmemcached) | - | - | - | - | - | [X](#parameters)|[X](#elastic-config)| [7.16.3](#update-elastic-stack-version) | |
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ services:
- GEOIP_CUSTOM_ATTRIBUTE=${GEOIP_CUSTOM_ATTRIBUTE:-xForwardedFor}
- xpack.geoip.download.endpoint=${GEOIP_DOWNLOAD_ENDPOINT}
- EVENTLOG_CUSTOM_ATTR=${EVENTLOG_CUSTOM_ATTR}
- CACHE_API_PATHS=${CACHE_API_PATHS}
ports:
- 5044:5044
volumes:
Expand Down
18 changes: 18 additions & 0 deletions env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,24 @@ MEMCACHED=memcached:11211
# Used-By: Logstash, API-Builder
# LOOKUP_CACHE_TTL=1200

# ----------------------------------------------------------------------------------------------
# In case an API contains path parameters (e.g. /api/v2/pet/123456789), it may be advisable to
# configure them here to optimize caching. Especially if the path parameter is very variable
# (e.g. customer IDs). Due to the fact that the API request path is then always different
# Logstash cannot cache the looked up API-Details efficiently.
# Therefore, you configure a list of comma separated API paths here. The Logstash pipeline
# checks if the received API request path starts with one of the configured paths, if so, the
# API details are cached with the configured path (/api/v2/pet) instead of the received
# API path (/api/v2/pet/123456789).
# It is recommended to configure the most frequently called paths first in the list to avoid
# unnecessary iterations.
# You can also configure a shorter path. It is important to understand that based on this
# configured API path the API details are cached and of course there should not be any overlap
# between two actually different APIs.
# Defaults to null
# Used-By: Logstash
# CACHE_API_PATHS=/api/v2/petstore, /api/v1/user, ...

# ----------------------------------------------------------------------------------------------
# The maximum heap memory for ES. Xmx should be configured to 50% of the available memory, when
# running ES on a dedicated node. Both values should be same.
Expand Down
1 change: 1 addition & 0 deletions helm/templates/elasticApimLogstash/logstash-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ data:
{{- if .Values.logstash.lookupCacheTTL }}
LOOKUP_CACHE_TTL: {{ default "" .Values.logstash.lookupCacheTTL | quote }}
{{- end }}
CACHE_API_PATHS: {{ default "" .Values.logstash.cacheAPIPaths | quote }}
GEOIP_ENABLED: {{ default "true" .Values.logstash.geoip.enabled | quote }}
GEOIP_CACHE_SIZE: {{ default "1000" .Values.logstash.geoip.cacheSize | quote }}
GEOIP_CUSTOM_ATTRIBUTE: {{ default "true" .Values.logstash.geoip.customAttribute | quote }}
Expand Down
4 changes: 4 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ logstash:
# https://www.elastic.co/guide/en/logstash/current/plugins-filters-geoip.html#plugins-filters-geoip-manage_update
# downloadEndpoint: "http://some-custom-endpoint"

# Configures a list of API-Paths that should be used for caching instead of the complete request path.
# Check the env-sample parameter: CACHE_API_PATHS for more details.
# cacheAPIPaths: "/api/v2/petstore, /api/v1/user, ..."

# Injects the environment variables from the ConfigMaps and Secrets into the
# Logstash container. Specify your own ConfigMaps or Secrets if you don't
# provide Configuration and Secrets as part of this values.yaml.
Expand Down
32 changes: 29 additions & 3 deletions logstash/pipelines/OpenTrafficPipeline.conf
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,40 @@ filter {
if([transactionSummary] and [transactionSummary][protocol] in ["http", "https"]) {
# Check, if an apiName is given (not the case for native APIs such as /healthcheck) to be used for the lookup
if([transactionSummary][serviceContext][service]) {
mutate { add_field => { "[@metadata][apiName]" => "%{[transactionSummary][serviceContext][service]}" } }
mutate {
add_field => { "[@metadata][apiName]" => "%{[transactionSummary][serviceContext][service]}" }
add_field => { "[@metadata][cacheAPIPaths]" => "${CACHE_API_PATHS:''}" }
}
} else {
# Without an API name, only API path is used for the API lookup.
mutate { add_field => { "[@metadata][apiName]" => "" } }
}
# Create a key for the API
# Create a cache key for the API either based on the received request path or the configured path.
# For example: /v1/get/pet/687687678 --> CACHE_API_PER_NAME = /v1/get/pet makes sure the API is cached based on the API-Name
ruby {
code => '
cacheAPIPaths = event.get("[@metadata][cacheAPIPaths]");
apiRequestPath = event.get("[transactionSummary][path]");
if (cacheAPIPaths.nil? || cacheAPIPaths.empty?)
event.set("[@metadata][apiCacheKeyPrefix]", apiRequestPath);
return;
end
apiName = event.get("[transactionSummary][serviceContext][service]");
logger.info("Configured paths and current API-Request path: ", { "cacheAPIPaths" => cacheAPIPaths, "apiRequestPath" => apiRequestPath } );
event.set("[@metadata][apiCacheKeyPrefix]", apiRequestPath);
for configuredPath in cacheAPIPaths.split(",") do
if(apiRequestPath.start_with?(configuredPath) )
logger.info("Using configured path as primary cache key as it matches to request path. ", { "configuredPath" => configuredPath, "apiRequestPath" => apiRequestPath });
event.set("[@metadata][apiCacheKeyPrefix]", configuredPath);
break;
end
end
'
}
mutate {
add_field => { "apiCacheKey" => "%{[transactionSummary][path]}###%{[processInfo][groupId]}###%{[processInfo][gatewayRegion]}" }
add_field => {
apiCacheKey => "%{[@metadata][apiCacheKeyPrefix]}###%{[processInfo][groupId]}###%{[processInfo][gatewayRegion]}"
}
}
# Lookup the cache with the created API-Key (API-Name---API-Path)
memcached {
Expand Down