Search code examples
logstashlogstash-grok

pytest logs parsing in logstash


I have some pytest logs to process.

example of the log line is

"== 5 failed, 2 passed, 11 deselected, 7 xfailed, 2 xpassed in 1155.95 seconds =="

I need to filter this type of log lines and make key value pairs as below failed

passed=2,deselected=11and xfailed=7

Please help me to write filter in logstash config file


Solution

  • You don't provide any information that you've tried to do this yourself, but...

    The general idea is to use the grok{} filter to parse the line into fields. Here's a start:

    grok {
        match => [ "message", "== %{NUMBER:failed} failed," ]
    }
    

    This will create a field called 'failed' that would contain the value '5' from your sample data. Continue that idea with the other interesting data.