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

Commit 422be8e

Browse files
author
Chris Wiechmann
committed
Added Trace-Messages for local API-Lookup
1 parent cabf0b5 commit 422be8e

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ docker logs logstash -f
855855
When Logstash is successfully started you should see the following:
856856
```
857857
docker logs logstash
858-
Pipelines running {:count=>6, :running_pipelines=>[:".monitoring-logstash", :BeatsInput, :Events, :DomainAudit, :TraceMessages, :OpenTraffic], :non_running_pipelines=>[]}
858+
Pipelines running {:count=>6, :running_pipelines=>[:".monitoring-logstash", :DomainAudit, :Events, :TraceMessages, :BeatsInput, :OpenTraffic], :non_running_pipelines=>[]}
859859
Successfully started Logstash API endpoint {:port=>9600}
860860
```
861861
If you see the following or similar error message during processing of events the API-Builder Lookup-API cannot be reached. In case, please make sure the environment variable: `API_BUILDER_URL`is set correctly.
@@ -959,9 +959,12 @@ END
959959
```
960960
The example shows in the namespace ignoredAPIs that two entries are contained. So these are not queried again until they have expired.
961961
```
962-
stats cachedump 1 0
963-
ITEM index_status:openlog###N/A [4 b; 1609980429 s]
964-
ITEM index_status:trace###N/A [4 b; 1609980396 s]
962+
stats cachedump 2 0
963+
ITEM ignoredAPIs:###Health Check [19 b; 1610535266 s]
964+
ITEM ignoredAPIs:/healthcheck### [19 b; 1610535266 s]
965+
ITEM index_status:events###N/A [27 b; 1610538266 s]
966+
ITEM index_status:trace###N/A [27 b; 1610538266 s]
967+
ITEM index_status:openlog###N/A [27 b; 1610538266 s]
965968
END
966969
```
967970
This holds the index creation status used by API-Builder & Logstash to determine if an indicies needs to be created or not.

apibuilder4elastic/custom_flow_nodes/api-builder-plugin-axway-api-management/src/actions.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,11 @@ async function _getAPILocalProxies(params, options) {
234234
logger.error(`Error reading API-Lookup file: '${lookupFile}'. Error: ${ex}`);
235235
return;
236236
}
237+
options.logger.info(`Reading API-Details from local file: ${lookupFile}`);
237238
localAPIConfig = { ...localProxies };
238239
var filenames = await _getGroupRegionFilename(lookupFile, groupId, region);
239240
if(filenames.groupFilename) {
241+
options.logger.info(`Reading API-Details from local file: ${lookupFile}`);
240242
var groupProxies = JSON.parse(fs.readFileSync(filenames.groupFilename), null);
241243
localAPIConfig[groupId] = groupProxies;
242244
}
@@ -261,11 +263,14 @@ async function _getAPILocalProxies(params, options) {
261263
}
262264

263265
async function _getLocalProxy(localProxies, apiPath, policyName, options) {
264-
if(localProxies == undefined) return;
266+
if(localProxies == undefined) {
267+
options.logger.warn(`No configuration found in file.`);
268+
return;
269+
}
265270
var foundProxy;
266271
// If a policy is given, it is used separately for the lookup
267272
if(policyName != undefined && policyName != "") {
268-
options.logger.debug(`Looking up information based on policy name: ${policyName}`);
273+
options.logger.info(`Looking up information based on policy name: ${policyName}`);
269274
if(localProxies[`Policy: ${policyName}`]) {
270275
foundProxy = localProxies[`Policy: ${policyName}`];
271276
}
@@ -284,8 +289,10 @@ async function _getLocalProxy(localProxies, apiPath, policyName, options) {
284289
};
285290
// Perhaps, we have direct hit with the API-Path
286291
if(localProxies[apiPath]) {
292+
options.logger.info(`API-Details found based on API-Path: ${apiPath}`);
287293
foundProxy = localProxies[apiPath];
288294
} else {
295+
options.logger.info(`Try to find API-Details starting with: ${apiPath}`);
289296
// Iterate over all configured API-Proxies
290297
for (const [key, val] of Object.entries(localProxies)) {
291298
if(apiPath.startsWith(key)) {
@@ -295,9 +302,13 @@ async function _getLocalProxy(localProxies, apiPath, policyName, options) {
295302
}
296303
}
297304
// If we don't have a match return nothing
298-
if(foundProxy==undefined) return;
305+
if(foundProxy==undefined) {
306+
options.logger.warn(`No API-Details found for API-Path: ${apiPath}`);
307+
return;
308+
}
299309
// Take over the configuration, preserve the default values
300310
proxy = {...proxy, ...foundProxy};
311+
options.logger.warn(`Found API-Details for API-Path: ${JSON.stringify(apiPath)}`);
301312
var proxies = [];
302313
proxy.path = apiPath; // Copy the path, as it's normally returned by the API-Manager and used for caching
303314
proxies.push(proxy);

logstash/pipelines/BeatsInputPipeline.conf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ filter {
3131
}
3232
# If the version has just checked, add it to the cache to avoid further lookups
3333
if([@metadata][updateVersionCheckCache]=="true") {
34+
ruby {
35+
code => 'logger.info("Adding version check status to cache: ", "value" => event.get("[versionStatus]") );'
36+
}
3437
memcached {
3538
hosts => "${MEMCACHED}"
3639
namespace => "version_status"
@@ -90,7 +93,7 @@ filter {
9093
# If the API-Builder create index API has been called, create a cache entry to avoid further unneeded calls
9194
if([@metadata][updateCache]=="true") {
9295
ruby {
93-
code => 'logger.info("Adding index status to cache: ", "value" => event.get("[indicesStatus]"), "logtype" => event.get("[logtype]"), "region" => event.get("[gatewayRegion]"));'
96+
code => 'logger.info("Adding index status to cache: ", "value" => event.get("[indicesStatus]"), "logtype" => event.get("[logtype]"), "region" => event.get("[gatewayRegion]") );'
9497
}
9598
memcached {
9699
hosts => "${MEMCACHED}"

logstash/pipelines/OpenTrafficPipeline.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ filter {
5959
}
6060
# Drop the document if it should be ignored
6161
if ([isIgnoreAPI][ignore]) {
62+
ruby {
63+
code => 'logger.debug("Drop API/event as it should be ignored: ", "isIgnoreAPI" => event.get("[isIgnoreAPI]"), "ignoreLookupCacheKey" => event.get("[@metadata][ignoreLookupCacheKey]") );'
64+
}
6265
drop {}
6366
}
6467
# If the PolicyName or API-Path has been looked up right now add it to the cache
6568
if([@metadata][updateIsIgnoreCache]=="true") {
69+
ruby {
70+
code => 'logger.info("Adding ignore status to cache: ", "isIgnoreAPI" => event.get("[isIgnoreAPI]"), "ignoreLookupCacheKey" => event.get("[@metadata][ignoreLookupCacheKey]") );'
71+
}
6672
memcached {
6773
hosts => "${MEMCACHED}"
6874
namespace => "ignoredAPIs"
@@ -185,6 +191,9 @@ filter {
185191
}
186192
# If the API has been looked up add it to the cache
187193
if([@metadata][updateAPICache]=="true") {
194+
ruby {
195+
code => 'logger.info("Adding API-Lookup details to cache: ", "apiDetails" => event.get("[apiDetails]"), "apiCacheKey" => event.get("[apiCacheKey]") );'
196+
}
188197
memcached {
189198
hosts => "${MEMCACHED}"
190199
namespace => "api_details"

0 commit comments

Comments
 (0)