您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
由于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" } }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。