logstash获取北京时间-创新互联
由于logstash会自动将@timestamp时间转成UTC时间,网上搜了很多种方法无果后。只好从日志中提取年月日来进行按北京时间分表。
创新互联建站IDC提供业务:成都西信服务器托管,成都服务器租用,成都西信服务器托管,重庆服务器租用等四川省内主机托管与主机租用业务;数据中心含:双线机房,BGP机房,电信机房,移动机房,联通机房。日志格式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" } }另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网页题目:logstash获取北京时间-创新互联
当前路径:http://azwzsj.com/article/gioij.html