Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logstash config: conditional with list not working if [field] in ["list item 1"]

I am using Logstash to process some flow data. Now I came across a problem while tagging the data using a conditional.

If I write the following in the logstash config

if [myfield] == "abc"{ mutate { add_tag => ["mytag"] } }
else { mutate { add_tag => ["not_working"] } }

everything works just fine, but now I want to use a list like

if [myfield] is in ["abc"]{ mutate { add_tag => ["mytag"] } }
else { mutate { add_tag => ["not_working"] } }

and only get a not_working tag.

Any suggestions? Thanks in advance!

like image 867
Jashugan Avatar asked Dec 20 '22 02:12

Jashugan


1 Answers

It seems as if there has to be more than one value in the array/list. You could just duplicate the only value like

if [myfield] in ["abc", "abc"] { mutate { add_tag => ["mytag"] } }
else { mutate { add_tag => ["not_working"] } }

and it is working fine.

like image 179
Jashugan Avatar answered Jan 30 '23 03:01

Jashugan