简体   繁体   English

pytest日志解析为logstash

[英]pytest logs parsing in logstash

I have some pytest logs to process. 我有一些pytest日志要处理。

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 请帮我在logstash配置文件中写过滤器

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. 通常的想法是使用grok {}过滤器将行解析为字段。 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. 这将创建一个名为“ failed”的字段,该字段将包含来自示例数据的值“ 5”。 Continue that idea with the other interesting data. 继续将这个想法与其他有趣的数据一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM