You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 14, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: elk-traffic-monitor-api/flows/trafficMonitorApi-trace.json
+8-1Lines changed: 8 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,13 @@
86
86
"value": "$.index",
87
87
"metaName": "index",
88
88
"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."
89
96
}
90
97
],
91
98
"outputs": {
@@ -121,7 +128,7 @@
121
128
{
122
129
"name": "code",
123
130
"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;\"",
125
132
"metaName": "code",
126
133
"metaDescription": "A JavaScript function body. Supports `await` and returning promises"
0 commit comments