Skip to content

Instantly share code, notes, and snippets.

@boeboe
Created July 6, 2016 07:18
Show Gist options
  • Save boeboe/3f7503b1246b8d963debe7208e3dd86f to your computer and use it in GitHub Desktop.
Save boeboe/3f7503b1246b8d963debe7208e3dd86f to your computer and use it in GitHub Desktop.
Logstash configuration file
input {
beats {
port => 5044
}
}
filter {
if [type] == "syslog" {
grok {
match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
add_field => [ "received_at", "%{@timestamp}" ]
add_field => [ "received_from", "%{host}" ]
}
syslog_pri { }
date {
match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ]
}
}
}
filter {
if [type] == "nginx-access" {
grok {
patterns_dir => ["/etc/logstash/conf.d/patterns"]
match => { "message" => "%{NGINXACCESS}" }
}
} else if [type] == "nginx-error" {
grok {
patterns_dir => ["/etc/logstash/conf.d/patterns"]
match => [
"message", "%{NGINXERROR1}",
"message", "%{NGINXERROR2}",
"message", "%{NGINXERROR3}"
]
}
}
}
output {
elasticsearch {
hosts => ["http://elk-elasticsearch01.romcore.rom:9200"]
manage_template => false
index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment