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

Commit 0bcf325

Browse files
author
Chris Wiechmann
committed
Error-Handling added if API can't be looked up.
1 parent 365f849 commit 0bcf325

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

logstash/pipeline/pipeline.conf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ filter {
7575
}
7676
remove_field => [ "apiDetails", "headers" ]
7777
}
78+
# If the API-Lookup failed - Clone the event which is send to an Error index and shown in Traffic-Monitor
79+
if("_httprequestfailure" in [tags]) {
80+
clone {
81+
clones => ['errorEvent']
82+
}
83+
mutate { replace => { "[transactionElements][leg0][protocolInfo][http][status]" => "XXX" } }
84+
mutate { replace => { "[transactionElements][leg0][protocolInfo][http][statusText]" => "ERROR" } }
85+
mutate { replace => { "[transactionElements][leg0][protocolInfo][http][authSubjectId]" => "ID: %{[correlationId]}" } }
86+
mutate { replace => { "[transactionSummary][serviceContext][vhost]" => "Logstash Error" } }
87+
mutate { replace => { "[transactionSummary][serviceContext][method]" => "check the logs" } }
88+
}
7889
}
7990
#}
8091
}
@@ -113,7 +124,7 @@ output {
113124
hosts => "elasticsearch1:9200"
114125
index => "apigw-traffic-trace-%{+YYYY.MM.dd}"
115126
}
116-
} else if "_httprequestfailure" in [tags] {
127+
} else if [type] == 'errorEvent' {
117128
elasticsearch {
118129
hosts => "elasticsearch1:9200"
119130
index => "apigw-traffic-details-err-%{+YYYY}"

logstash/test/test-openlog-events.json

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
]
6060
},
6161
{
62-
"description": "Test transactionSummary event",
62+
"description": "Test transactionSummary event with existing API",
6363
"input": [
6464
"{\"timestamp\":1594670847467,\"correlationId\":\"ffbe0c5f95da03f602a6e587\",\"processInfo\":{\"hostname\":\"ip-172-31-62-146.ec2.internal\",\"domainId\":\"e1ff3aab-3b11-4820-a1be-3763da2beda4\",\"groupId\":\"group-2\",\"groupName\":\"group-a\",\"serviceId\":\"instance-3\",\"serviceName\":\"instance-3\",\"version\":\"7.7.20200530\"},\"transactionSummary\":{\"path\":\"/petstore/v2/user/Chris\", \"protocol\":\"https\", \"protocolSrc\":\"8065\", \"status\":\"success\", \"serviceContexts\":[{\"service\":\"Petstore\", \"monitor\":true, \"client\":null, \"org\":null, \"app\":null, \"method\":\"getUserByName\", \"status\":\"success\", \"duration\":2}]}}"
6565
],
@@ -100,6 +100,44 @@
100100
}
101101
]
102102
},
103+
{
104+
"description": "Test transactionSummary event with unknwon API that cannot be looked up",
105+
"input": [
106+
"{\"timestamp\":1594670847467,\"correlationId\":\"OMG-UNKNOWN-API\",\"processInfo\":{\"hostname\":\"ip-172-31-62-146.ec2.internal\",\"domainId\":\"e1ff3aab-3b11-4820-a1be-3763da2beda4\",\"groupId\":\"group-2\",\"groupName\":\"group-a\",\"serviceId\":\"instance-3\",\"serviceName\":\"instance-3\",\"version\":\"7.7.20200530\"},\"transactionSummary\":{\"path\":\"/petstore/v2/user/Chris\", \"protocol\":\"https\", \"protocolSrc\":\"8065\", \"status\":\"success\", \"serviceContexts\":[{\"service\":\"Petstore\", \"monitor\":true, \"client\":null, \"org\":null, \"app\":null, \"method\":\"getUserByName\", \"status\":\"success\", \"duration\":2}]}}"
107+
],
108+
"expected": [
109+
{
110+
"@timestamp": "2020-07-13T20:07:27.467Z",
111+
"correlationId": "OMG-UNKNOWN-API",
112+
"logtype": "openlog",
113+
"processInfo": {
114+
"hostname": "ip-172-31-62-146.ec2.internal",
115+
"domainId": "e1ff3aab-3b11-4820-a1be-3763da2beda4",
116+
"groupId": "group-2",
117+
"groupName": "group-a",
118+
"serviceId": "instance-3",
119+
"serviceName": "instance-3",
120+
"version": "7.7.20200530"
121+
},
122+
"transactionSummary": {
123+
"path": "/this/api/is/unknown",
124+
"protocol": "https",
125+
"protocolSrc": "8065",
126+
"status": "success",
127+
"serviceContext": {
128+
"service": "A unknown API",
129+
"monitor": true,
130+
"client": null,
131+
"appOrg": null,
132+
"app": null,
133+
"method": "getUserByName",
134+
"status": "success",
135+
"duration": 2
136+
}
137+
}
138+
}
139+
]
140+
},
103141
{
104142
"description": "Test transactionSummary without ServiceConext event",
105143
"input": [

0 commit comments

Comments
 (0)