Last active
August 29, 2015 14:00
-
-
Save tureki/11038609 to your computer and use it in GitHub Desktop.
Nginx's Log to Elasticsearch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input { | |
file { | |
type => "nginx_access" | |
codec=>json | |
path => ["/var/log/nginx/**"] | |
exclude => ["*.gz", "error.*"] | |
discover_interval => 10 | |
sincedb_path => "/opt/logstash/.sincedb" | |
} | |
} | |
filter { | |
grok { | |
match => [ "message","%{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{TIMESTAMP_ISO8601:timestamp}\] \"(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})\" %{NUMBER:response} (?:%{NUMBER:bytes}|-) %{QS:referrer} %{QS:agent}"] | |
} | |
} | |
output { | |
elasticsearch { | |
host => "HOSTNAME" | |
index=>"ngx-access-%{+YYYY.MM.DD}" | |
index_type => "nginx" | |
cluster=>"ELASTICSEARCH CLUSTER NAME" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment