# Condition on value in array?

**URL:** <https://discuss.elastic.co/t/condition-on-value-in-array/76967>\
**Category:** Logstash\
**Created:** [March 1, 2017, 11:00am UTC](https://discuss.elastic.co/t/condition-on-value-in-array/76967 "2017-03-01T11:00:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asp](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@asp](https://discuss.elastic.co/u/asp)\
**Post date:** [March 1, 2017, 11:00am UTC](https://discuss.elastic.co/t/condition-on-value-in-array/76967/1 "2017-03-01T11:00:51Z")

</div>

Hi,

I have following fields in my event:

```
...
 "stage": [
      "shared",
      "QA",
      "dev_trunk"
    ],
...

```

I want to set a new meta field to to _staging_, if the stage filed contains, QA, dev\_trunk or PreProd.

I have tried with following sniplet:

```
# process the stage
	if [stage] == "Production"
	{
		mutate
		{
			 add_field => { "[@metadata][indexCluster]" => "prod" }
		}
	}
	#elseif [stage] in ["QA", "dev_trunk", "PreProd"]
	elseif "QA" in [stage] or "dev_trunk in [stage] or "PreProd" in [stage]
	{
		mutate
		{
			add_field => { "[@metadata][indexCluster]" => "staging" }
		}
	}
	else
	{
		mutate
		{
			add_field => { "[@metadata][indexCluster]" => "no_stage_defined" }
		}
	}

```

The event above is resulting in "no\_stage\_defined".

How can I correct this?

I am using logstash 5.2.0  
Thanks, Andreas

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 29, 2017, 11:01am UTC](https://discuss.elastic.co/t/condition-on-value-in-array/76967/2 "2017-03-29T11:01:17Z")

</div>

Closed on March 29, 2017, 11:01am UTC

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