...
Kodeblok |
---|
title | /etc/logstash/conf.d/30-elasticsearch-output.conf |
---|
|
output {
if [type] == "pinglog" {
elasticsearch {
hosts => ["localhost:9200"]
sniffing => true
manage_template => false
index => "pinglog-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
}
}
else
{
elasticsearch {
hosts => ["localhost:9200"]
sniffing => true
manage_template => false
index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
}
}
} |
As I have ensure ensured logs are pretty much key=value for the values I need to collect, I use "kv" to to get the fields, and a mutate to to ensure the string value for "pingtime=" becomes a float (otherwise it cant be used in a Visualization):
Kodeblok |
---|
title | /etc/logstash/conf.d/02-beats-input.conf |
---|
|
input {
beats {
port => 5044
ssl => true
ssl_certificate => "/etc/pki/tls/certs/logstash-forwarder.crt"
ssl_key => "/etc/pki/tls/private/logstash-forwarder.key"
}
}
filter {
if [type] == "apache" {
grok {
match => { "message" => "%{COMBINEDAPACHELOG}" }
}
date {
match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
}
geoip {
source => "clientip"
target => "geoip"
database => "/etc/logstash/GeoLiteCity.dat"
add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ]
add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}" ]
}
mutate {
convert => [ "[geoip][coordinates]", "float"]
}
}
else
{
if [type] == "pinglog" {
kv {}
mutate {
convert => { "pingtime" => "float" }
}
}
}
} |
...