# Conditional in the output is ignored

**URL:** https://discuss.elastic.co/t/conditional-in-the-output-is-ignored/294343
**Category:** Logstash
**Created:** [January 13, 2022, 11:59pm UTC](https://discuss.elastic.co/t/conditional-in-the-output-is-ignored/294343 "2022-01-13T23:59:02Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![edster](https://avatars.discourse-cdn.com/v4/letter/e/da6949/32.png) [@edster](https://discuss.elastic.co/u/edster)
#### Post date: [January 13, 2022, 11:59pm UTC](https://discuss.elastic.co/t/conditional-in-the-output-is-ignored/294343/1 "2022-01-13T23:59:02Z")

</div>

The conditional statement in my logstash configuration is being ignored. It is being skipped over no matter what I put in it. I have 4 elasticsearch options in the output divided by an if and else statement. I've tried using the following conditional statements:

> if "tag\_name" in [tags] {  
> elasticsearch {  
> .....  
> }  
> elasticsearch {  
> .......  
> }  
> } else {  
> elasticsearch {  
> .....  
> }  
> elasticsearch {  
> .......  
> }  
> }

I've also tried to use `if [tags] == ["tag_name"]`.

I've it with incorrect values for the tag\_name and somehow it still skips over and just drops into the first elasticsearch output.

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [January 14, 2022, 12:16am UTC](https://discuss.elastic.co/t/conditional-in-the-output-is-ignored/294343/2 "2022-01-14T00:16:20Z")

</div>

> [@edster](#):
>
> I've also tried to use `if [tags] == ["tag_name"]`

I do not think that will ever match. See [this](https://github.com/elastic/logstash/issues/9932) issue.

What is the value of [tags] field in elasticsearch? Does it contain the tag you are testing?

---

<div class="post-metadata">

### Author: ![edster](https://avatars.discourse-cdn.com/v4/letter/e/da6949/32.png) [@edster](https://discuss.elastic.co/u/edster)
#### Post date: [January 14, 2022, 12:26am UTC](https://discuss.elastic.co/t/conditional-in-the-output-is-ignored/294343/3 "2022-01-14T00:26:50Z")

</div>

It should not. The tags field should be empty. I'm using this config for two processes. I set tags in one but do not in add tags in the other. There actually shouldnt be any tags added. Either way there is no issue showing for `if "tag_name" in [tags]` even if tag\_name is incorrect or if tags even exists as a field.

---

<div class="post-metadata">

### Author: ![edster](https://avatars.discourse-cdn.com/v4/letter/e/da6949/32.png) [@edster](https://discuss.elastic.co/u/edster)
#### Post date: [January 14, 2022, 2:08pm UTC](https://discuss.elastic.co/t/conditional-in-the-output-is-ignored/294343/4 "2022-01-14T14:08:02Z")

</div>

So I'm currently using 7.2.0 for logstash and Elasticsearch would removing the log4j class have anything to do with it?

---

<div class="post-metadata">

### Author: ![edster](https://avatars.discourse-cdn.com/v4/letter/e/da6949/32.png) [@edster](https://discuss.elastic.co/u/edster)
#### Post date: [January 18, 2022, 2:51pm UTC](https://discuss.elastic.co/t/conditional-in-the-output-is-ignored/294343/5 "2022-01-18T14:51:35Z")

</div>

I tried using the example in the linked issue and the "in" and "not in" syntax but still no success. There are actually no values for the tags field. For one index I add tags in the input but for the other index I do not add this line to the config. It seems to just skip over it. Whenever, I add a bad field or value no error or warning or anything, nothing comes up. Any ideas?

---

<div class="post-metadata">

### Author: ![edster](https://avatars.discourse-cdn.com/v4/letter/e/da6949/32.png) [@edster](https://discuss.elastic.co/u/edster)
#### Post date: [January 18, 2022, 3:15pm UTC](https://discuss.elastic.co/t/conditional-in-the-output-is-ignored/294343/6 "2022-01-18T15:15:22Z")

</div>

Could it be the way I run the config file. I just use /path/to/logstash -f /logstash/config/path. Are there other options I'm missing?

---

<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: [February 15, 2022, 3:15pm UTC](https://discuss.elastic.co/t/conditional-in-the-output-is-ignored/294343/7 "2022-02-15T15:15:51Z")

</div>

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