0
Logstash 1.4.1 설치가 간단하고 데이터가 stdout에서는 정확하지만 ES/Kibana에서는 "message"필드를 덮어 쓰지 않습니다.Logstash Grokked 데이터가 ElasticSearch에 도달하지 않습니다.
logstash.conf
input {
file {
path => "/var/log/nginx/access.log"
type => "nginx_access"
}
}
filter {
if [type] == "nginx_access" {
grok {
match => [ "message", "%{NGINXACCESS}" ]
overwrite => [ "message" ]
}
}
}
output {
elasticsearch {
protocol => "http"
}
stdout { codec => rubydebug }
}
Nginx의 패턴
NGUSERNAME [a-zA-Z\.\@\-\+_%]+
NGUSER %{NGUSERNAME}
NGINXACCESS %{IPORHOST:clientip} %{NGUSER:ident} %{NGUSER:auth} \[%{HTTPDATE:timestamp}\] "%{WORD:verb} %{URIPATHPARAM:request} HTTP/%{NUMBER:httpversion}" %{NUMBER:response} (?:%{NUMBER:bytes}|-) (?:"(?:%{URI:referrer}|-)"|%{QS:referrer}) %{QS:agent}
표준 출력
{
"message" => "127.0.0.1 - - [27/Nov/2014:13:43:53 +0100] \"GET /favicon.ico HTTP/1.1\" 502 574 \"-\" \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36\"",
"@version" => "1",
"@timestamp" => "2014-11-27T12:43:54.230Z",
"type" => "nginx_access",
"host" => "laptop",
"path" => "/var/log/nginx/access.log",
"clientip" => "127.0.0.1",
"ident" => "-",
"auth" => "-",
"timestamp" => "27/Nov/2014:13:43:53 +0100",
"verb" => "GET",
"request" => "/favicon.ico",
"httpversion" => "1.1",
"response" => "502",
"bytes" => "574",
"agent" => "\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36\""
}
내가 잘못 뭐하는 거지? 어떻게 디버깅 할 수 있습니까?
편집
가져 오기 API는 필드가 인덱싱되지 않습니다 _source,에 그이 보이고있다. 무엇을해야합니까?
{
"_index":"logstash-2014.11.27",
"_type":"nginx_access4",
"_id":"AUnxR34Z5DzKTB-2TeuG",
"_version":1,
"found":true,
"_source":{
"message":"127.0.0.1 - - [27/Nov/2014:13:43:53 +0100] \"GET/HTTP/1.1\" 502 574 \"-\" \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36\"",
"@version":"1",
"@timestamp":"2014-11-27T12:43:54.230Z",
"type":"nginx_access",
"host":"laptop",
"path":"/var/log/nginx/access.log",
"clientip":"127.0.0.1",
"ident":"-",
"auth":"-",
"timestamp":"27/Nov/2014:13:43:53 +0100",
"verb":"GET",
"request":"/",
"httpversion":"1.1",
"response":"502",
"bytes":"574",
"agent":"\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36\""
}
}