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

Commit fdf51bd

Browse files
author
Chris Wiechmann
committed
Update OpenTrafficPipeline.conf
1 parent 13bebca commit fdf51bd

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

logstash/pipelines/OpenTrafficPipeline.conf

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,28 @@ filter {
2727
# Create a cache key for the API either on the complete received request path or if configured, only using a specific part of the path.
2828
# This prevents API requests with path parameters from not being cached efficiently due to their variable parameter.
2929
# Example: API-Request: /v1/get/pet/687687678, Configured-Path: /v1/get/pet - API-Details cached based on Configured-Path (/v1/get/pet)
30-
ruby {
31-
id => "Set API-Cache-Key prefix"
32-
code => '
33-
cacheAPIPaths = event.get("[@metadata][cacheAPIPaths]");
34-
apiRequestPath = event.get("[transactionSummary][path]");
35-
if (cacheAPIPaths.nil? || cacheAPIPaths.empty?)
30+
if([transactionSummary] and [transactionSummary][path]) { # Only if a path is given (not given for instance for Scheduled-Policies)
31+
ruby {
32+
id => "Set API-Cache-Key prefix"
33+
code => '
34+
cacheAPIPaths = event.get("[@metadata][cacheAPIPaths]");
35+
apiRequestPath = event.get("[transactionSummary][path]");
36+
if (cacheAPIPaths.nil? || cacheAPIPaths.empty?)
37+
event.set("[@metadata][apiCacheKeyPrefix]", apiRequestPath);
38+
return;
39+
end
40+
apiName = event.get("[transactionSummary][serviceContext][service]");
41+
logger.debug("Configured paths and current API-Request path: ", { "configuredPaths" => cacheAPIPaths, "apiRequestPath" => apiRequestPath } );
3642
event.set("[@metadata][apiCacheKeyPrefix]", apiRequestPath);
37-
return;
38-
end
39-
apiName = event.get("[transactionSummary][serviceContext][service]");
40-
logger.debug("Configured paths and current API-Request path: ", { "configuredPaths" => cacheAPIPaths, "apiRequestPath" => apiRequestPath } );
41-
event.set("[@metadata][apiCacheKeyPrefix]", apiRequestPath);
42-
for configuredPath in cacheAPIPaths.split(",") do
43-
if(apiRequestPath.start_with?(configuredPath) )
44-
logger.debug("Using configured path as primary cache key because it matches to request path. ", { "configuredPath" => configuredPath, "apiRequestPath" => apiRequestPath });
45-
event.set("[@metadata][apiCacheKeyPrefix]", configuredPath);
46-
break;
43+
for configuredPath in cacheAPIPaths.split(",") do
44+
if(apiRequestPath.start_with?(configuredPath) )
45+
logger.debug("Using configured path as primary cache key because it matches to request path. ", { "configuredPath" => configuredPath, "apiRequestPath" => apiRequestPath });
46+
event.set("[@metadata][apiCacheKeyPrefix]", configuredPath);
47+
break;
48+
end
4749
end
48-
end
49-
'
50+
'
51+
}
5052
}
5153
# First, is to check if the document should be ignored/dropped (configured based on the apiPath or PolicyName)
5254
if([transactionSummary] and [transactionSummary][path]) { # Only if a path is given (not given for instance for Scheduled-Policies)

0 commit comments

Comments
 (0)