logstash定义表达式

例如: echo '[2018/02/02 08:34:43.032]' >> tomcat_catalina.out

过滤方式

"message" => "\[(?<log_time>%{NOTSPACE}%{SPACE}%{NOTSPACE})\]"

 

{
"log_time" => "2018/02/02 08:34:43.032",
"message" => "[2018/02/02 08:34:43.032]",
"prospector" => {
"type" => "log"
},
"source" => "/ali/logs/tomcat_catalina.out",
"offset" => 2313,
"@version" => "1",
"@timestamp" => 2018-02-03T07:06:48.983Z,
"fields" => {
"tag" => "log1"
},
"beat" => {
"name" => "iZwz9amcsywc3lxhketqdpZ",
"hostname" => "iZwz9amcsywc3lxhketqdpZ",
"version" => "6.1.2"
}
}

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

自定义grok表达式

语法:(?<field_name>the pattern here)

eg:

grok{
  match=>{
    "message"=>"%{IP:clientip}\s+(?<mypattern>[A-Z]+)"
  }
}

rs:

{
  "message" => "12.12.12.12 ABC",
  "@version" => "1",
  "@timestamp" => "2016-03-30T03:22:04.466Z",
  "host" => "master",
  "clientip" => "12.12.12.12",
  "mypattern" => "ABC"
}

转载于:https://www.cnblogs.com/liqing1009/p/8409530.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值