logstash获取北京时间
由于logstash会自动将@timestamp时间转成UTC时间,网上搜了很多种方法无果后。只好从日志中提取年月日来进行按北京时间分表。
在东安等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供网站建设、网站设计 网站设计制作按需策划设计,公司网站建设,企业网站建设,品牌网站建设,全网整合营销推广,外贸网站制作,东安网站建设费用合理。
日志格式JSON:
{"@timestamp":"2016-08-22T09:13:06.024Z",......}
input { redis { host => "192.168.1.21" port => "6379" key => "filebeat" data_type => "list" password => "nginx_pass" threads => 50 } } filter { mutate { gsub => ["message", "\\x", "\\\x"] } if [type] == "nginxacclog" { json { source => "message" } ruby { code => "event['ctime'] = event['@timestamp'].time.localtime" #code => "event['ctime'] = event['@timestamp'].time.localtime + 8*60*60" } grok{ match => { "ctime" => ["%{INT:years_dik3k}-%{INT:months_dik3k}-%{INT:days_dik3k}T*"]} } grok { add_field => ["type_xi09wnk", "nginxacclog"] match => ["requesturi", "%{URIPATH:baseurl}(?:\?%{NOTSPACE:request})"] remove_tag => "requesturi" } kv { source => "request" field_split => "&?" value_split => "=" } kv { source => "post_requ" field_split => "&?" value_split => "=" } } } output { if [type_xi09wnk] == "nginxacclog" { MongoDB{ collection => "nginx_log%{years_dik3k}%{months_dik3k}%{days_dik3k}" isodate => true database => "logdb" uri => "mongodb://user:pass@10.10.1.102:27017/logdb" } }
名称栏目:logstash获取北京时间
转载来源:http://hbruida.cn/article/ppepii.html