logstash从多行

时间:2017-07-31 12:25:24

标签: logstash logstash-grok logstash-configuration

我正在尝试编写logstash过滤器以从多个日志行中提取一些数据。

我想过使用multiline过滤器,但这似乎无法解决我的问题:

如果我基于一些常见模式合并线条,在这种情况下说0x000005fa,则有100条其他线条以模式0x000005fa开头。

我有以下日志行。

< p:0x000005fa P:STM t:0x00ba94f0 T:component M:file1.c F:func_1 L:2343 > module Helper library has reported: check on partition /dev/point1 failed errno=13
< p:0x000005fa P:STM t:0x00ba94f0 T:component M:file2.c F:func_2 L:1899 > %%%%Erasing HDD%%%%
< p:0x000005fa P:STM t:0x00ba94f0 T:component M:file3.c F:func_3 L:1433 > ...partition /dev/point1 format complete

我最终希望我的输出有以下数据:

mount_point:/dev/point1
error_code:13
format_string: Erasing HDD
format_status: complete

我试过跟随,即。有一个python脚本可以做一些grep,sed和awk的组合来获取所需的数据并将该数据设置为一个名为process_result的新事件,然后我们可以使用grok来获取精确的数据。但是,如果在大量数据集上运行,我认为这些命令的组合会降低我的logstash的速度吗?

ruby {
code => 'require "open3"
         file_path = event.get("C:\Users\sushiku2\Downloads\ELK\logstash-5.4.0\Logs\diag-logs\hdd-failure\DIAG_Sample_12345_00")
         #cmd =  "my_filter.py -f #{file_path}"
         cmd = "python my_filter.py"
         stdin, stdout, stderr = Open3.popen3(cmd)
         event.set("process_result", stdout.read)
         err = stderr.read
         if err.to_s.empty?
           filter_matched(event)
         else
           event.set("ext_script_err_msg", err)
         end'
  remove_field => ["file_path"]
}

0 个答案:

没有答案