Skip to content

Instantly share code, notes, and snippets.

@xorpaul
Last active December 23, 2015 08:39
Show Gist options
  • Save xorpaul/6609064 to your computer and use it in GitHub Desktop.
Save xorpaul/6609064 to your computer and use it in GitHub Desktop.
logstash conditional on logsource

Logstash 1.2.1 config

Should add the log events to different elasticsearch indices based on the logsource field

output {
  if [fields][logsource] =~ /^foobar/ {
    # only server foobar01 and foobar1338
    elasticsearch {
      host => "<%= elasticsearch_host %>"
      cluster => "my_es_cluster"
      node_name => "logstash@<%= fqdn %>"
      index => "foobar-%{+YYYY.MM.dd}"
    }
  } else {
    # everything else
    elasticsearch {
      host => "<%= elasticsearch_host %>"
      cluster => "my_es_cluster"
      node_name => "logstash@<%= fqdn %>"
      index => "logstash-%{+YYYY.MM.dd}"
    }
  }
}
@xorpaul
Copy link
Author

xorpaul commented Sep 19, 2013

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