【发布时间】:2017-05-26 23:39:05
【问题描述】:
以下是我的Nginx日志格式
log_format timed_combined '$http_x_forwarded_for - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" ' '$request_time $upstream_response_time $pipe';
以下是Nginx日志条目(供参考)
- - test.user [26/May/2017:21:54:26 +0000] "POST /elasticsearch/_msearch HTTP/1.1" 200 263 "https://myserver.com/app/kibana" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" 0.020 0.008 .
以下是 logstash grok 模式
NGUSERNAME [a-zA-Z\.\@\-\+_%]+
NGUSER %{NGUSERNAME}
NGINXACCESS %{IPORHOST:clientip} - - \[%{HTTPDATE:timestamp}\] \"(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})\" %{NUMBER:response} (?:%{NUMBER:bytes}|-) %{QS:referrer} %{QS:agent} %{NUMBER:request_time} %{NUMBER:upstream_time}
logstash 日志中发现错误
"status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "原因"=>"无法解析 [时间戳]", "caused_by"=>{"type"=>"illegal_argument_exception", "reason"=>"无效 格式:\"26/May/2017:19:28:14 -0400\" 格式不正确 \"/May/2017:19:28:14 -0400\"
Issue: - Nginx logs are not getting grokked.
Requirement: - Timestamp should be filtered into a particular field.
我的配置有什么问题?如何修复此错误?
【问题讨论】:
标签: nginx logstash elastic-stack logstash-grok logstash-configuration