← Каталог
Справочник по Logstash — 1. Обработка Apache-логов
Фрагмент из «Справочник по Logstash»: 1. Обработка Apache-логов.
input {
file {
path => "/var/log/apache2/access.log"
start_position => "beginning"
sincedb_path => "/dev/null"
type => "apache_access"
}
}
filter {
if [type] == "apache_access" {
grok {
match => { "message" => "%{COMBINEDAPACHELOG}" }
}
date {
match => ["timestamp", "dd/MMM/yyyy:HH:mm:ss Z"]
}
geoip {
source => "clientip"
}
useragent {
source => "agent"
target => "user_agent"
}
mutate {
remove_field => ["message", "timestamp"]
}
}
}
output {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "apache-logs-%{+YYYY.MM.dd}"
}
stdout { codec => rubydebug }
} input {
file {
path => "/var/log/apache2/access.log"
start_position => "beginning"
sincedb_path => "/dev/null"
type => "apache_access"
}
}
filter {
if [type] == "apache_access" {
grok {
match => { "message" => "%{COMBINEDAPACHELOG}" }
}
date {
match => ["timestamp", "dd/MMM/yyyy:HH:mm:ss Z"]
}
geoip {
source => "clientip"
}
useragent {
source => "agent"
target => "user_agent"
}
mutate {
remove_field => ["message", "timestamp"]
}
}
}
output {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "apache-logs-%{+YYYY.MM.dd}"
}
stdout { codec => rubydebug }
}