logstash date插件介绍

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               
时间处理(Date)之前章节已经提过,filters/date 插件可以用来转换你的日志记录中的时间字符串,变成 LogStash::Timestamp 对象,然后转存到 @timestamp 字段里output {      if   [type] == "zj_frontend_access"{         elasticsearch {                hosts => "192.168.32.80:9200"                index => "logstash-zjzc-frontend-%{+YYYY.MM.dd}"        }  stdout {   codec => rubydebug  }      }        else if  [type] == "wj_frontend_access"{      elasticsearch {                hosts => "192.168.32.81:9200"                index => "logstash-wj-frontend-%{+YYYY.MM.dd}"        }                stdout {                        codec => rubydebug                }     }}注意:因为在稍后的 outputs/elasticsearch 中常用的 %{+YYYY.MM.dd} 这种写法必须读取 @timestamp 数据,所以一定不要直接删掉这个字段保留自己的字段,而是应该用 filters/date 转换后删除自己的字段![elk@zjtest7-frontend config]$ ../bin/logstash -f stdin02.conf Settings: Default pipeline workers: 1Pipeline main started12/Sep/2016:21:32:33 +0800{       "message" => "12/Sep/2016:21:32:33 +0800",      "@version" => "1",    "@timestamp" => "2016-09-13T02:00:19.890Z",          "host" => "0.0.0.0",       "logdate" => "12/Sep/2016:21:32:33 +0800"}[elk@zjtest7-frontend config]$ cat stdin02.conf input {    stdin {    }}filter {    grok {        match => ["message", "%{HTTPDATE:logdate}"]    }#    date {#        match => ["logdate", "dd/MMM/yyyy:HH:mm:ss Z"]#        add_field =>["response_time","%{logdate}"]#    }}output { stdout {  codec=>rubydebug{}   } }  使用date插件: [elk@zjtest7-frontend config]$ cat stdin02.conf input {    stdin {    }}filter {    grok {        match => ["message", "%{HTTPDATE:logdate}"]    }    date {        match => ["logdate", "dd/MMM/yyyy:HH:mm:ss Z"]        add_field =>["response_time","%{logdate}"]    }}output { stdout {  codec=>rubydebug{}   } }[elk@zjtest7-frontend config]$ ../bin/logstash -f stdin02.conf Settings: Default pipeline workers: 1Pipeline main started12/Sep/2016:21:32:33 +0800{          "message" => "12/Sep/2016:21:32:33 +0800",         "@version" => "1",       "@timestamp" => "2016-09-12T13:32:33.000Z",             "host" => "0.0.0.0",          "logdate" => "12/Sep/2016:21:32:33 +0800",    "response_time" => "12/Sep/2016:21:32:33 +0800"}

           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
这里写图片描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值