# Logstash if condition in output not working

**URL:** <https://discuss.elastic.co/t/logstash-if-condition-in-output-not-working/129466>\
**Category:** Logstash\
**Created:** [April 25, 2018, 11:12am UTC](https://discuss.elastic.co/t/logstash-if-condition-in-output-not-working/129466 "2018-04-25T11:12:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jellydragon](https://avatars.discourse-cdn.com/v4/letter/j/977dab/32.png) [@jellydragon](https://discuss.elastic.co/u/jellydragon)\
**Post date:** [April 25, 2018, 11:12am UTC](https://discuss.elastic.co/t/logstash-if-condition-in-output-not-working/129466/1 "2018-04-25T11:12:19Z")

</div>

Hi, i'm trying to conditionally redirect logs to different outputs based on the presence of the tag "ERROR". Here is the code i'm using:

```
output {
  if "ERROR" in [tags] {
    kafka {
      bootstrap_servers => "localhost:9092"
      codec => json
      topic_id => 'error'
      id => 'kafka_error'
    }
  } else {
    elasticsearch {
      hosts => ["http://localhost:9200"]
      manage_template => false
      index => "%{project}-%{type}-%{+YYYY.MM.dd}"
      id => 'elasticsearch'
      document_id => "%{[fingerprint]}"
    }
  }
}

```

However, this does not seem to work as the logs are being sent to both outputs at the same time. How can i possibly fix/debug this ? Thank you!

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 25, 2018, 11:31am UTC](https://discuss.elastic.co/t/logstash-if-condition-in-output-not-working/129466/2 "2018-04-25T11:31:09Z")

</div>

> However, this does not seem to work as the logs are being sent to both outputs at the same time.

That's impossible with the configuration you've shown us. I think you have another configuration file somewhere. Perhaps an old backup file or something in /etc/logstash/conf.d or wherever your configuration files reside?

---

<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:** [May 23, 2018, 11:31am UTC](https://discuss.elastic.co/t/logstash-if-condition-in-output-not-working/129466/3 "2018-05-23T11:31:32Z")

</div>

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