Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logstash conditional to check if tag exists?

Tags:

logstash

Is there any way in logstash to use a conditional to check if a specific tag exists?

For example,

grok { match => [ "message", "Some expression to match|%{GREEDYDATA:NOMATCHES}" ] 

if NOMATCHES exists Do something.

How do I verify if NOMATCHES tag exists or not?

Thanks.

like image 411
CodeRunner Avatar asked Jan 29 '14 17:01

CodeRunner


1 Answers

Just so we're clear: the config snippet you provided is setting a field, not a tag.

Logstash events can be thought of as a dictionary of fields. A field named tags is referenced by many plugins via add_tag and remove_tag operations.

You can check if a tag is set:

if "foo" in [tags] {     ... } 

But you seem to want to check if a field contains anything:

if [NOMATCHES] =~ /.+/ {     ... } 

The above will check that NOMATCHES exists and isn't empty.

Reference: configuration file overview.

like image 117
rutter Avatar answered Oct 16 '22 20:10

rutter