Skip to content

Instantly share code, notes, and snippets.

@spuder
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save spuder/edd6058ca969aa484a94 to your computer and use it in GitHub Desktop.

Select an option

Save spuder/edd6058ca969aa484a94 to your computer and use it in GitHub Desktop.
Troubleshoot logstash grok logs
#This config does not work, it never enters the if [tag] == derp block
input {
stdin {}
}
filter {
grok {
#match => [ "message", ".*" ]
match => [ "message", "%{GREEDYDATA}" ]
add_tag => [ "derp" ]
}
}
output {
# Why does this if statement not work?
if [tag] == "derp" {
stdout {}
email {
to => "spuder@foo.com"
from => "logstash@foo.com"
subject => "herp"
body => "herp a derp %{message}"
via => "sendmail"
}
}
# IF I change tag to type => foo, then logstash works properly, it seems that you can perform conditionals on tags.
}
@spuder

spuder commented May 1, 2014

Copy link
Copy Markdown
Author

because tags are an array, you need to use the following (thanks coolacid in irc)

if "derp" in [tags]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment