码迷,mamicode.com
首页 > 其他好文 > 详细

【ELK】Logstash 配置小记

时间:2019-01-17 12:46:24      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:代码调整   cal   match   failure   col   ESS   str   mes   fail   

Filter

grok:进行正则匹配

grok {
    match => [ "message" , "%{NGINXLOG} %{QS:upstream_addr} %{QS:upstream_response_time} %{QS:request_time} %{QS:body}"]
}
# 自定义正则匹配 grok { break_on_match
=> "false" patterns_dir => "./logstash/pat" match => [ "request" , "%{URIMATCH}" ] }

ruby:使用ruby代码调整输出内容

ruby {
    code => "event.set(‘timelocal‘, event.get(‘@timestamp‘).time.localtime + 8*60*60)"
}
ruby {
    code => "event.set(‘@timestamp‘,event.get(‘timelocal‘))"
}
ruby {
    code => "event.set(‘timeunix‘,event.get(‘@timestamp‘).to_i)"
}

kv:进行基于单一分隔符的键值匹配

kv {
    source => "message"
    field_split => "#"
    value_split => "~"
target => "msg_json"
}

date:时间匹配到·timestamp

date {
    match => ["timestamp", "UNIX"]
    remove_field => ["message","timestamp", "count", "fields", "input_type", "offset"]
}

mutate:调整输出

mutate {
lowercase => [ "loglevel" ] remove_field
=> [ "ident", "auth", "source", "beat", "message", "@version", "count", "fields", "input_type", "offset" ] }

 

Output

if "_grokparsefailure" not in [tags]

过滤掉匹配失败的日志

 

待续

【ELK】Logstash 配置小记

标签:代码调整   cal   match   failure   col   ESS   str   mes   fail   

原文地址:https://www.cnblogs.com/caizhifeng/p/10281570.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!