简体   繁体   English

如何在Logstash中编写grok过滤器以接受变量参数

[英]How to write grok filter in logstash to accept variable arguments

How to write grok filter rule, if message contains transactions of variable arguments. 如果消息包含可变参数的事务,如何编写grok过滤器规则。

For example: 例如:

22-Jun-2015 04:45:56 Transaction for Bill 123 item1=100 item2=200 item3=300
22-Jun-2015 05:45:23 Transaction for Bill 124 item1=200
22-Jun-2015 06:23:36 Transaction for Bill 125 item4=400 item2=200 item1=100 item5=500

We can match date, time, bill # in the above case but how to handle for variable arguments item here. 在上述情况下,我们可以匹配日期,时间,账单号,但此处如何处理可变参数项。

Finally I was able to do that using kv{} option of logstash 最终,我能够使用logstash的kv {}选项做到这一点

For example: 例如:

 item1=100&item2=200&item3=300
 item1=100&item2=200&item3=300&item4=400

I created two messages and then I got the below output; 我创建了两个消息,然后得到以下输出;

{
   "message" => "item1=100&item2=200&item3=300",
  "@version" => "1",
"@timestamp" => "2015-07-04T19:20:15.831Z",
      "host" => "viswesn-PC",
     "item1" => "100",
     "item2" => "200",
     "item3" => "300",
      "tags" => [
          [0] "true"
      ]
}
  {
   "message" => "item1=100&item2=200&item3=300&item4=400",
  "@version" => "1",
"@timestamp" => "2015-07-04T19:20:25.866Z",
      "host" => "viswesn-PC",
     "item1" => "100",
     "item2" => "200",
     "item3" => "300",
     "item4" => "400",
      "tags" => [
         [0] "true"
   ]
}

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

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