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

Commit aaf28ad

Browse files
author
Chris Wiechmann
authored
Merge pull request #21 from Axway-API-Management-Plus/scheduled-policies
Adding support to show Scheduled policies in Traffic-Monitor
2 parents c3f6663 + 334c470 commit aaf28ad

File tree

7 files changed

+78
-23
lines changed

7 files changed

+78
-23
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ API_BUILDER_URL=http://elk-traffic-monitor-api:8080
2626
# The Connection/URL to the Admin-Node-Manager.
2727
# !!!! IMPORTANT NOTE !!!!
2828
# This URL must be reachable/resolveable from within the API-Builder Docker-Container!
29-
ADMIN_NODE_MANAGER=https://api-env:8090
29+
ADMIN_NODE_MANAGER=https://172.17.0.1:8090
3030

3131
# ----------------------------------------------------------------------------------------------
3232
# The Connection/URL to the API-Manager. If not given, the same as Admin-Node-Manager URL with
3333
# port 8075 is used.
3434
# !!!! IMPORTANT NOTE !!!!
3535
# This URL must be reachable/resolveable from within the API-Builder Docker-Container!
36-
# API_MANAGER=https://api-env:8075
36+
# API_MANAGER=https://172.17.0.1:8075
3737

3838
# ----------------------------------------------------------------------------------------------
3939
# This user is used by API-Builder to lookup APIs & User-Information in API-Manager.

.github/workflows/api-utils-flow-node.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@
44

55
name: API-Builder API-Utils Flow-Node
66

7-
8-
on:
9-
push:
10-
branches: [ master ]
11-
pull_request:
12-
branches: [ master ]
13-
release:
14-
types: [ published ]
7+
on: [push, pull_request]
158

169
jobs:
1710
build:

.github/workflows/traffic-monitor-api.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@
44

55
name: Traffic-Monitor API
66

7-
8-
on:
9-
push:
10-
branches: [ master ]
11-
pull_request:
12-
branches: [ master ]
13-
release:
14-
types: [ published ]
7+
on: [push, pull_request]
158

169
jobs:
1710
build:

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ services:
9393

9494
# This is the API-Builder project exposing the API-Gateway Manager REST-API
9595
elk-traffic-monitor-api:
96-
image: cwiechmann/elk-traffic-monitor-api:v0.0.9
96+
image: cwiechmann/elk-traffic-monitor-api:latest
9797
links:
9898
- elasticsearch1
9999
environment:

logstash/config/traffic_details_index_template.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"index_patterns": [
3-
"apigw-traffic-details-*",
4-
"apigw-traffic-errors-*"
3+
"apigw-traffic-*"
54
],
65
"settings": {
76
"number_of_shards": 5,

logstash/pipeline/pipeline.conf

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,25 @@ filter {
2121
mutate {
2222
remove_field => ["host", "timestamp"]
2323
}
24+
# Schedule-Policy event - Most of the properties are NULL
25+
if([correlationId]!="000000000000000000000000" and ![circuitPath] and ![transactionElement] and ![transactionSummary][path] and ![transactionSummary][protocol] and ![transactionSummary][protocolSrc]) {
26+
mutate {
27+
add_field => {
28+
"[type]" => "scheduledPolicy"
29+
"[transactionSummary][serviceContext][service]" => "Scheduled policy"
30+
"[transactionSummary][serviceContext][method]" => "N/A"
31+
"[transactionElements][leg0][operation]" => "N/A"
32+
"[transactionElements][leg0][duration]" => "-1"
33+
"[transactionElements][leg0][finalStatus]" => "Pass"
34+
"[transactionElements][leg0][protocolInfo][http][uri]" => "N/A"
35+
"[transactionElements][leg0][protocolInfo][http][status]" => "901"
36+
"[transactionElements][leg0][protocolInfo][http][statusText]" => "OK"
37+
"[transactionElements][leg0][protocolInfo][http][method]" => "N/A"
38+
}
39+
remove_field => "[transactionSummary][serviceContexts]"
40+
}
2441
# If a transactionElement event is received it must be re-arragended to support up-serts into ES
25-
if([transactionElement]) {
42+
} else if([transactionElement]) {
2643
ruby {
2744
code => "
2845
leg = event.get('transactionElement');
@@ -134,13 +151,18 @@ output {
134151
} else if [type] == 'errorEvent' {
135152
elasticsearch {
136153
hosts => "elasticsearch1:9200"
137-
index => "apigw-traffic-errors-%{+YYYY}"
154+
index => "apigw-traffic-errors-%{+YYYY.MM.dd}"
138155
template => "${HOME}/config/traffic_details_index_template.json"
139156
template_overwrite => true
140157
document_id => "%{correlationId}"
141158
action => "update"
142159
doc_as_upsert => true
143160
}
161+
} else if [type] == "scheduledPolicy" {
162+
elasticsearch {
163+
hosts => "elasticsearch1:9200"
164+
index => "apigw-traffic-scheduled-%{+YYYY.MM.dd}"
165+
}
144166
} else {
145167
elasticsearch {
146168
hosts => "elasticsearch1:9200"

logstash/test/test-openlog-events.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,54 @@
313313
]
314314
}
315315
]
316+
},
317+
{
318+
"description": "A scheduled policy",
319+
"input": [
320+
"{\"timestamp\":1598271030003,\"correlationId\":\"36ae435faa3e258ee1092b60\",\"processInfo\":{\"hostname\":\"api-env\",\"domainId\":\"ed992442-c363-4d36-963a-9e6314b0f421\",\"groupId\":\"group-2\",\"groupName\":\"QuickStart Group\",\"serviceId\":\"instance-1\",\"serviceName\":\"QuickStart Server\",\"version\":\"7.7.20200730\"},\"transactionSummary\":{\"path\":null, \"protocol\":null, \"protocolSrc\":null, \"status\":\"success\", \"serviceContexts\":[]}}"
321+
],
322+
"expected": [
323+
{
324+
"@timestamp": "2020-08-24T12:10:30.003Z",
325+
"correlationId": "36ae435faa3e258ee1092b60",
326+
"logtype": "openlog",
327+
"processInfo": {
328+
"hostname": "api-env",
329+
"domainId": "ed992442-c363-4d36-963a-9e6314b0f421",
330+
"groupId": "group-2",
331+
"groupName": "QuickStart Group",
332+
"serviceId": "instance-1",
333+
"serviceName": "QuickStart Server",
334+
"version": "7.7.20200730"
335+
},
336+
"transactionElements": {
337+
"leg0": {
338+
"operation": "N/A",
339+
"finalStatus": "Pass",
340+
"duration": "-1",
341+
"protocolInfo": {
342+
"http": {
343+
"uri": "N/A",
344+
"status": "901",
345+
"statusText": "OK",
346+
"method": "N/A"
347+
}
348+
}
349+
}
350+
},
351+
"transactionSummary": {
352+
"path": null,
353+
"protocol": null,
354+
"protocolSrc": null,
355+
"status": "success",
356+
"serviceContext": {
357+
"method": "N/A",
358+
"service": "Scheduled policy"
359+
}
360+
},
361+
"type": "scheduledPolicy"
362+
}
363+
]
316364
}
317365
]
318366
}

0 commit comments

Comments
 (0)