Skip to content

Instantly share code, notes, and snippets.

@eperdeme
Forked from specialops/gist:6177708
Last active December 20, 2015 18:48
Show Gist options
  • Select an option

  • Save eperdeme/6178320 to your computer and use it in GitHub Desktop.

Select an option

Save eperdeme/6178320 to your computer and use it in GitHub Desktop.
timestamp:
2013-08-07T19:18:07.115Z
event:
<133>Aug 7 19:18:06 server03 app-log at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.9.1.jar:2.9.1]
##############
logstash.conf:
##############
input {
tcp {
port => 5544
type => syslog
}
udp {
port => 5544
type => syslog
}
}
filter {
grok {
type => "syslog"
pattern => [ "<%{NONNEGINT:syslog_pri}>%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_app} %{GREEDYDATA:syslog_message}" ]
add_field => [ "received_at", "%{@timestamp}" ]
add_field => [ "received_from", "%{@source_host}" ]
}
syslog_pri {
type => "syslog"
}
date {
type => "syslog"
match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ]
}
mutate {
type => "syslog"
exclude_tags => "_grokparsefailure"
replace => [ "@source_host", "%{syslog_hostname}" ]
replace => [ "@message", "%{syslog_message}" ]
}
mutate {
type => "syslog"
remove => [ "syslog_hostname", "syslog_message", "syslog_timestamp" ]
}
grok {
type => "syslog_message"
pattern => [ "(^.+Exception: .+)|(^\s+at .+)|(^\s+... \d+ more)|(^\s*Caused by:.+)" ]
drop_if_match => true
}
}
output {
elasticsearch { embedded => true }
}
OR
##############
logstash.conf:
##############
input {
tcp {
port => 5544
type => syslog
}
udp {
port => 5544
type => syslog
}
}
filter {
grok {
type => "syslog"
pattern => [ "<%{NONNEGINT:syslog_pri}>%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_app} %{GREEDYDATA:syslog_message}" ]
add_field => [ "received_at", "%{@timestamp}" ]
add_field => [ "received_from", "%{@source_host}" ]
}
grok {
type => "syslog"
match => [ "syslog_message", "(^.+Exception: .+)|(^\s+at .+)|(^\s+... \d+ more)|(^\s*Caused by:.+)" ]
drop_if_match => true
}
syslog_pri {
type => "syslog"
}
date {
type => "syslog"
match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ]
}
mutate {
type => "syslog"
exclude_tags => "_grokparsefailure"
replace => [ "@source_host", "%{syslog_hostname}" ]
replace => [ "@message", "%{syslog_message}" ]
}
mutate {
type => "syslog"
remove => [ "syslog_hostname", "syslog_message", "syslog_timestamp" ]
}
}
output {
elasticsearch { embedded => true }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment