Skip to content

Instantly share code, notes, and snippets.

@strarsis
Forked from TinLe/logstash.conf
Created December 7, 2016 22:59
Show Gist options
  • Save strarsis/3305701edad9c8799f16a0fd20f79ff1 to your computer and use it in GitHub Desktop.
Save strarsis/3305701edad9c8799f16a0fd20f79ff1 to your computer and use it in GitHub Desktop.
my logstash.conf file for postfix
input {
file {
path => "/var/log/maillog*"
exclude => "*.gz"
start_position => "beginning"
type => "maillog"
}
}
filter {
if [type] == "maillog" {
grok {
patterns_dir => ["/home/logstash/config/patterns"]
match => { "message" => ["%{PF}", "%{DOVECOT}" ] }
}
date {
match => [ "timestamp", "MMM dd HH:mm:ss", "MMM d HH:mm:ss" ]
}
}
# I wanted to monitor metrics and health of logstash
metrics {
meter => "events"
add_tag => "metric"
}
}
output {
if [type] == "maillog" {
elasticsearch {
index => "maillog-%{+YYYY.MM.dd}"
host => "localhost"
port => "9200"
protocol => "http"
flush_size => 1000
manage_template => true
template_overwrite => true
template => "/home/logstash/config/templates/maillog.json"
template_name => "maillog"
}
}
if "metric" in [tags] {
stdout {
codec => line {
format => "rate: %{events.rate_1m}"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment