Performing a function if a value is inside an array

This is my array:

"device_tag": [
"DeviceA",
"DeviceB"
]

Essentially I want to do something if tag is Device A and something else if Device is tag B.

if [device_tag] == "DeviceA" {
mutate { do something here  } }

if [device_tag] == "DeviceB" {
mutate { do something else here  } }

But this doesn't seem to work, any ideas?

Also tried

if [device_tag] =~ /DeviceA/ {
mutate { do something here  }

You can test array membership using in

if "DeviceA" in [device_tag] {

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.