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

Commit a1f3173

Browse files
author
Chris Wiechmann
committed
Adjusting tests for the other endpoints
1 parent 33e72ae commit a1f3173

File tree

5 files changed

+591
-598
lines changed

5 files changed

+591
-598
lines changed

elk-traffic-monitor-api/flows/trafficMonitorApi-trace.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@
8686
"value": "$.index",
8787
"metaName": "index",
8888
"metaDescription": "Comma-separated list or wildcard expression of index names used to limit the request."
89+
},
90+
{
91+
"name": "sort",
92+
"type": "string",
93+
"value": "\"@timestamp:desc\"",
94+
"metaName": "sort",
95+
"metaDescription": "A comma-separated list of <field>:<direction> pairs."
8996
}
9097
],
9198
"outputs": {
@@ -121,7 +128,7 @@
121128
{
122129
"name": "code",
123130
"type": "string",
124-
"value": "\"let result = [];\\n \\n data.hits.map(function(entry) {\\n let traceObj = {};\\n let message = entry._source.message;\\n let dateObj = isoStringToDate(entry._source.timestampOriginal);\\n let dateObj2 = parseDate(entry._source.timestampOriginal);\\n\\t\\n // depth is the number of tabs befor start of the message. \\n // Calculated based on count of white spaces divided by 4\\n const depthRegex = /(?<=[\\\\]])\\\\s*/gm;\\n let depthMatch = depthRegex.exec(message);\\n\\tlet depth = 1;\\n \\n if (depthMatch !== null){\\n depth = Math.round(depthMatch[0].length/4);\\n }\\n \\n traceObj.level = entry._source.level;\\n traceObj.type = 'trace';\\n traceObj.time = dateObj.getTime();\\n traceObj.depth = depth;\\n traceObj.text = message.substring(message.lastIndexOf(\\\"]\\\")+1,message.length).trim();\\n \\n result.push(traceObj);\\n \\n });\\n\\n \\nfunction parseDate(input) {\\n var parts = input.match(/(\\\\d+)/g);\\n // new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])\\n return new Date(parts[0], parts[1]-1, parts[2]); // months are 0-based\\n}\\n\\n // Parse an ISO date string (i.e. \\\"2019-01-18T00:00:00.000Z\\\",\\n// \\\"2019-01-17T17:00:00.000-07:00\\\", or \\\"2019-01-18T07:00:00.000+07:00\\\",\\n// which are the same time) and return a JavaScript Date object with the\\n// value represented by the string.\\nfunction isoStringToDate( isoString ) {\\n\\n // Split the string into an array based on the digit groups.\\n var dateParts = isoString.split( /\\\\D+/ );\\n\\n // Set up a date object with the current time.\\n var returnDate = new Date();\\n\\n // Manually parse the parts of the string and set each part for the\\n // date. Note: Using the UTC versions of these functions is necessary\\n // because we're manually adjusting for time zones stored in the\\n // string.\\n returnDate.setUTCFullYear( parseInt( dateParts[ 0 ] ) );\\n\\n // The month numbers are one \\\"off\\\" from what normal humans would expect\\n // because January == 0.\\n returnDate.setUTCMonth( parseInt( dateParts[ 1 ] - 1 ) );\\n returnDate.setUTCDate( parseInt( dateParts[ 2 ] ) );\\n\\n // Set the time parts of the date object.\\n returnDate.setUTCHours( parseInt( dateParts[ 3 ] ) );\\n returnDate.setUTCMinutes( parseInt( dateParts[ 4 ] ) );\\n returnDate.setUTCSeconds( parseInt( dateParts[ 5 ] ) );\\n returnDate.setUTCMilliseconds( parseInt( dateParts[ 6 ] ) );\\n\\n // Track the number of hours we need to adjust the date by based\\n // on the timezone.\\n var timezoneOffsetHours = 0;\\n\\n // If there's a value for either the hours or minutes offset.\\n if ( dateParts[ 7 ] || dateParts[ 8 ] ) {\\n\\n // Track the number of minutes we need to adjust the date by\\n // based on the timezone.\\n var timezoneOffsetMinutes = 0;\\n\\n // If there's a value for the minutes offset.\\n if ( dateParts[ 8 ] ) {\\n\\n // Convert the minutes value into an hours value.\\n timezoneOffsetMinutes = parseInt( dateParts[ 8 ] ) / 60;\\n }\\n\\n // Add the hours and minutes values to get the total offset in\\n // hours.\\n timezoneOffsetHours = parseInt( dateParts[ 7 ] ) + timezoneOffsetMinutes;\\n\\n // If the sign for the timezone is a plus to indicate the\\n // timezone is ahead of UTC time.\\n if ( isoString.substr( -6, 1 ) == \\\"+\\\" ) {\\n\\n // Make the offset negative since the hours will need to be\\n // subtracted from the date.\\n timezoneOffsetHours *= -1;\\n }\\n }\\n\\n // Get the current hours for the date and add the offset to get the\\n // correct time adjusted for timezone.\\n returnDate.setHours( returnDate.getHours() + timezoneOffsetHours );\\n\\n // Return the Date object calculated from the string.\\n return returnDate;\\n}\\n \\n return result;\"",
131+
"value": "\"let result = [];\\n \\n data.hits.map(function(entry) {\\n let traceObj = {};\\n let message = entry._source.message;\\n let dateObj = isoStringToDate(entry._source['@timestamp']);\\n let dateObj2 = parseDate(entry._source['@timestamp']);\\n\\t\\n // depth is the number of tabs befor start of the message. \\n // Calculated based on count of white spaces divided by 4\\n const depthRegex = /(?<=[\\\\]])\\\\s*/gm;\\n let depthMatch = depthRegex.exec(message);\\n\\tlet depth = 1;\\n \\n if (depthMatch !== null){\\n depth = Math.round(depthMatch[0].length/4);\\n }\\n \\n traceObj.level = entry._source.level;\\n traceObj.type = 'trace';\\n traceObj.time = dateObj.getTime();\\n traceObj.depth = depth;\\n traceObj.text = message.substring(message.lastIndexOf(\\\"]\\\")+1,message.length).trim();\\n \\n result.push(traceObj);\\n \\n });\\n\\n \\nfunction parseDate(input) {\\n var parts = input.match(/(\\\\d+)/g);\\n // new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])\\n return new Date(parts[0], parts[1]-1, parts[2]); // months are 0-based\\n}\\n\\n // Parse an ISO date string (i.e. \\\"2019-01-18T00:00:00.000Z\\\",\\n// \\\"2019-01-17T17:00:00.000-07:00\\\", or \\\"2019-01-18T07:00:00.000+07:00\\\",\\n// which are the same time) and return a JavaScript Date object with the\\n// value represented by the string.\\nfunction isoStringToDate( isoString ) {\\n\\n // Split the string into an array based on the digit groups.\\n var dateParts = isoString.split( /\\\\D+/ );\\n\\n // Set up a date object with the current time.\\n var returnDate = new Date();\\n\\n // Manually parse the parts of the string and set each part for the\\n // date. Note: Using the UTC versions of these functions is necessary\\n // because we're manually adjusting for time zones stored in the\\n // string.\\n returnDate.setUTCFullYear( parseInt( dateParts[ 0 ] ) );\\n\\n // The month numbers are one \\\"off\\\" from what normal humans would expect\\n // because January == 0.\\n returnDate.setUTCMonth( parseInt( dateParts[ 1 ] - 1 ) );\\n returnDate.setUTCDate( parseInt( dateParts[ 2 ] ) );\\n\\n // Set the time parts of the date object.\\n returnDate.setUTCHours( parseInt( dateParts[ 3 ] ) );\\n returnDate.setUTCMinutes( parseInt( dateParts[ 4 ] ) );\\n returnDate.setUTCSeconds( parseInt( dateParts[ 5 ] ) );\\n returnDate.setUTCMilliseconds( parseInt( dateParts[ 6 ] ) );\\n\\n // Track the number of hours we need to adjust the date by based\\n // on the timezone.\\n var timezoneOffsetHours = 0;\\n\\n // If there's a value for either the hours or minutes offset.\\n if ( dateParts[ 7 ] || dateParts[ 8 ] ) {\\n\\n // Track the number of minutes we need to adjust the date by\\n // based on the timezone.\\n var timezoneOffsetMinutes = 0;\\n\\n // If there's a value for the minutes offset.\\n if ( dateParts[ 8 ] ) {\\n\\n // Convert the minutes value into an hours value.\\n timezoneOffsetMinutes = parseInt( dateParts[ 8 ] ) / 60;\\n }\\n\\n // Add the hours and minutes values to get the total offset in\\n // hours.\\n timezoneOffsetHours = parseInt( dateParts[ 7 ] ) + timezoneOffsetMinutes;\\n\\n // If the sign for the timezone is a plus to indicate the\\n // timezone is ahead of UTC time.\\n if ( isoString.substr( -6, 1 ) == \\\"+\\\" ) {\\n\\n // Make the offset negative since the hours will need to be\\n // subtracted from the date.\\n timezoneOffsetHours *= -1;\\n }\\n }\\n\\n // Get the current hours for the date and add the offset to get the\\n // correct time adjusted for timezone.\\n returnDate.setHours( returnDate.getHours() + timezoneOffsetHours );\\n\\n // Return the Date object calculated from the string.\\n return returnDate;\\n}\\n \\n return result;\"",
125132
"metaName": "code",
126133
"metaDescription": "A JavaScript function body. Supports `await` and returning promises"
127134
}

elk-traffic-monitor-api/test/documents/basic/circuitpath_test_documents.js

Lines changed: 77 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const getDate = require('../../util');
22

33
module.exports = [
4+
// Default API Proxy Routing policy with id: c8705e5ecc00adca32be7472
45
{
56
"processInfo": {
67
"groupName": "QuickStart Group",
@@ -11,19 +12,8 @@ module.exports = [
1112
"groupId": "group-2",
1213
"serviceName": "QuickStart Server"
1314
},
14-
"transactionSummaryContext": {
15-
"monitor": true,
16-
"service": "Petstore HTTP",
17-
"method": "findPetsByStatus",
18-
"status": "success",
19-
"duration": 775,
20-
"client": "Pass Through"
21-
},
2215
"@version": "1",
23-
"@timestamp": "2020-03-03T14:59:31.540Z",
24-
"tags": [
25-
"openlog"
26-
],
16+
"@timestamp": getDate('8m'),
2717
"circuitPath": [
2818
{
2919
"filters": [
@@ -152,100 +142,115 @@ module.exports = [
152142
}
153143
},
154144
"correlationId": "c8705e5ecc00adca32be7472",
155-
"timestampOriginal": getDate('8m'),
156145
"transactionSummary": {
157-
"serviceContexts": [
158-
{
159-
"monitor": true,
160-
"service": "Petstore HTTP",
161-
"method": "findPetsByStatus",
162-
"status": "success",
163-
"duration": 775,
164-
"client": "Pass Through"
165-
}
166-
],
146+
"serviceContext":
147+
{
148+
"monitor": true,
149+
"service": "Petstore HTTP",
150+
"method": "findPetsByStatus",
151+
"status": "success",
152+
"duration": 775,
153+
"client": "Pass Through"
154+
}
155+
,
167156
"path": "/v2/pet/findByStatus",
168157
"protocolSrc": "8065",
169158
"status": "success",
170159
"protocol": "https"
171160
}
172161
},
162+
// Healthcheck policy with ID: 4e645e5e4600bb590c881179
173163
{
174-
"transactionSummaryContext": null,
164+
"log": {
165+
"file": {
166+
"path": "/var/log/work/group-2_instance-1_traffic.log"
167+
},
168+
"offset": 20867173
169+
},
170+
"tags": [
171+
"beats_input_raw_event"
172+
],
173+
"ecs": {
174+
"version": "1.5.0"
175+
},
176+
"agent": {
177+
"type": "filebeat",
178+
"hostname": "b16e7c6b2be4",
179+
"name": "Filebeat Gateway",
180+
"id": "e1b8bbae-78b8-43ef-9b91-647a9ca1e424",
181+
"version": "7.8.0",
182+
"ephemeral_id": "6d5aa448-a23c-4ad6-a136-a0ca0daa07d7"
183+
},
175184
"correlationId": "4e645e5e4600bb590c881179",
176185
"circuitPath": [
177186
{
178-
"policy": "Health Check",
179187
"execTime": 0,
188+
"policy": "Health Check",
180189
"filters": [
181190
{
191+
"type": "ChangeMessageFilter",
192+
"espk": "DEFAULT_PRIMARY_VordelGateway_7.7.0:-1095086795812854131",
182193
"execTime": 0,
183-
"status": "Pass",
184-
"class": "com.vordel.circuit.conversion.ChangeMessageFilter",
185194
"name": "Set Message",
186-
"filterTime": 1583244366351,
187-
"espk": "DEFAULT_PRIMARY_VordelGateway_7.7.0:3321373268751955789",
188-
"type": "ChangeMessageFilter"
195+
"class": "com.vordel.circuit.conversion.ChangeMessageFilter",
196+
"filterTime": 1594837160744,
197+
"status": "Pass"
189198
},
190199
{
191-
"execTime": 0,
192-
"status": "Pass",
193200
"type": "ReflectFilter",
201+
"espk": "DEFAULT_PRIMARY_VordelGateway_7.7.0:-4282446533257395104",
202+
"execTime": 0,
203+
"name": "Reflect",
194204
"class": "com.vordel.circuit.net.ReflectFilter",
195-
"filterTime": 1583244366351,
196-
"espk": "DEFAULT_PRIMARY_VordelGateway_7.7.0:4710537086861623998",
197-
"name": "Reflect"
205+
"filterTime": 1594837160744,
206+
"status": "Pass"
198207
}
199208
]
200209
}
201210
],
211+
"processInfo": {
212+
"hostname": "api-env",
213+
"groupName": "QuickStart Group",
214+
"serviceName": "QuickStart Server",
215+
"version": "7.7.20200130",
216+
"serviceId": "instance-1",
217+
"domainId": "ed992442-c363-4d36-963a-9e6314b0f421",
218+
"groupId": "group-2"
219+
},
220+
"@timestamp": "2020-07-15T18:19:20.744Z",
202221
"@version": "1",
203-
"tags": [
204-
"openlog"
205-
],
222+
"logtype": "openlog",
206223
"transactionSummary": {
207-
"serviceContexts": [],
208224
"path": "/healthcheck",
225+
"protocol": "http",
226+
"serviceContexts": [],
209227
"protocolSrc": "8080",
210-
"status": "success",
211-
"protocol": "http"
228+
"status": "success"
212229
},
213230
"transactionElements": {
214231
"leg0": {
215-
"duration": 3,
216-
"finalStatus": "Pass",
232+
"duration": 1,
217233
"protocolInfo": {
218-
"recvHeader": "GET /healthcheck HTTP/1.1\r\nHost: api-env:8080\r\nUser-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\nUpgrade-Insecure-Requests: 1\r\nPragma: no-cache\r\nCache-Control: no-cache\r\n\r\n",
219-
"sentHeader": "HTTP/1.1 200 OK\r\nDate: Tue, 03 Mar 2020 14:06:06 GMT\r\nServer: Gateway\r\nConnection: close\r\nX-CorrelationID: Id-4e645e5e4600bb590c881179 0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nCache-Control: no-cache\r\nHost: api-env:8080\r\nPragma: no-cache\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0\r\nContent-Type: text/xml\r\n\r\n",
234+
"recvHeader": "GET /healthcheck HTTP/1.1\r\nHost: api-env:8080\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\nCookie: _ga=GA1.1.177509375.1593442001; iconSize=16x16; portal.logintypesso=false; portal.demo=off; portal.isgridSortIgnoreCase=on; layout_type=table; cookie_pressed_153=false; portal.slate.api=no; portal.slate.dev=no\r\nUpgrade-Insecure-Requests: 1",
220235
"http": {
221-
"statusText": "OK",
222-
"status": 200,
223-
"method": "GET",
224-
"bytesReceived": 366,
225236
"wafStatus": 0,
226-
"bytesSent": 464,
237+
"bytesReceived": 563,
227238
"localPort": "8080",
228-
"remoteName": "192.168.65.145",
239+
"method": "GET",
240+
"statusText": "OK",
241+
"remotePort": "62131",
242+
"bytesSent": 661,
243+
"localAddr": "192.168.65.129",
229244
"uri": "/healthcheck",
230-
"remotePort": "40578",
231-
"remoteAddr": "192.168.65.145",
232-
"localAddr": "192.168.65.145"
233-
}
245+
"remoteName": "192.168.65.1",
246+
"remoteAddr": "192.168.65.1",
247+
"status": 200
248+
},
249+
"sentHeader": "HTTP/1.1 200 OK\r\nDate: Wed, 15 Jul 2020 18:19:20 GMT\r\nServer: Gateway\r\nConnection: close\r\nX-CorrelationID: Id-a8480f5f4d2d6bdc093f6b6d 0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nCookie: _ga=GA1.1.177509375.1593442001; iconSize=16x16; portal.logintypesso=false; portal.demo=off; portal.isgridSortIgnoreCase=on; layout_type=table; cookie_pressed_153=false; portal.slate.api=no; portal.slate.dev=no\r\nHost: api-env:8080\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0\r\nContent-Type: text/xml"
234250
},
235-
"leg": 0
251+
"finalStatus": "Pass"
236252
}
237-
},
238-
"timestampOriginal": getDate('65m'),
239-
"processInfo": {
240-
"groupName": "QuickStart Group",
241-
"hostname": "api-env",
242-
"serviceName": "QuickStart Server",
243-
"groupId": "group-2",
244-
"version": "7.7.20200130",
245-
"serviceId": "instance-1",
246-
"domainId": "8064faa2-54d2-42aa-b549-af5a0b289284"
247-
},
248-
"@timestamp": "2020-03-03T14:16:56.280Z"
253+
}
249254
},
250255
{
251256
"transactionElements": {
@@ -275,9 +280,7 @@ module.exports = [
275280
}
276281
},
277282
"@version": "1",
278-
"transactionSummaryContext": null,
279283
"correlationId": "bb30715e5300e189d1da43fc",
280-
"timestampOriginal": getDate('30000h'),
281284
"circuitPath": [
282285
{
283286
"execTime": 1,
@@ -317,13 +320,10 @@ module.exports = [
317320
"path": "/healthcheck",
318321
"status": "success",
319322
"protocol": "http",
320-
"serviceContexts": [],
323+
"serviceContext": null,
321324
"protocolSrc": "8080"
322325
},
323-
"@timestamp": "2020-03-17T20:19:20.945Z",
324-
"tags": [
325-
"openlog"
326-
],
326+
"@timestamp": getDate('30000h'),
327327
"processInfo": {
328328
"groupId": "group-2",
329329
"serviceId": "instance-1",
@@ -334,6 +334,7 @@ module.exports = [
334334
"domainId": "8064faa2-54d2-42aa-b549-af5a0b289284"
335335
}
336336
},
337+
// Test without circuit path information
337338
{
338339
"transactionElements": {
339340
"leg0": {
@@ -376,6 +377,7 @@ module.exports = [
376377
"hostname": "api-env"
377378
}
378379
},
380+
// API Manager Protection Policy
379381
{
380382
"transactionElements": {
381383
"leg0": {
@@ -547,10 +549,6 @@ module.exports = [
547549
]
548550
}
549551
],
550-
"tags": [
551-
"openlog"
552-
],
553-
"timestampOriginal": "2020-03-17T11:23:06.838Z",
554552
"processInfo": {
555553
"groupName": "QuickStart Group",
556554
"serviceName": "QuickStart Server",

0 commit comments

Comments
 (0)