The following examples describe use cases and their respective configuration of the Log Parser Connector as specified by the monitoringParams parameter.
Example 1
Parse a log file to retrieve the maximum value of a metric called temperature
and the average value of a metric called humidity
.
>> Log File (log_file.log) Contents:
some text temperature=18 some text humidity=80
some other text temperature=19 some text humidity=82 text
>> monitoringParams:
--file log_file.log --parser metrics --metrics temperature humidity --aggfunctions max avg --template=":metric=(.*?)[\s]"
>> Result:
{"temperature": 19, "humidity":81}
Example 2
Parse a log file to retrieve the number of occurrences of the string findMe
.
>> Log File (log_file.log) Contents:
some text findMe some text findMe
some other text temperature=19 some findMe text humidity=82 text
>> monitoringParams:
--file log_file.log --parser matches --regex someRegex
>> Result:
{"count": 3}