# If statement in logstash output

**URL:** <https://discuss.elastic.co/t/if-statement-in-logstash-output/199885>\
**Category:** Logstash\
**Created:** [September 17, 2019, 9:36pm UTC](https://discuss.elastic.co/t/if-statement-in-logstash-output/199885 "2019-09-17T21:36:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_DiCola](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brian_dicola/32/54179_2.png) [@Brian\_DiCola](https://discuss.elastic.co/u/Brian_DiCola)\
**Post date:** [September 17, 2019, 9:36pm UTC](https://discuss.elastic.co/t/if-statement-in-logstash-output/199885/1 "2019-09-17T21:36:09Z")

</div>

Here is my filebeats config  
processors:

- add\_tags:  
tags: [web, dev]  
target: "environment"

#=========================== Filebeat inputs =============================

filebeat.inputs:

- type: log

filebeat.config.modules:

# Glob pattern for configuration loading

path: ${path.config}/modules.d/\*.yml

reload.enabled: false

output.logstash:  
hosts: ["localhost:5044"]

Here is my logstash config

input {  
beats {  
port =\> "5044"  
}  
}  
filter {  
grok {  
match =\> { "message" =\> "%{COMBINEDAPACHELOG}"}  
}  
geoip {  
source =\> "clientip"  
}  
}  
output{

if "dev" in [tags] {  
amazon\_es {  
hosts =\> ["[https://mydevcluster](https://mydevcluster)"]  
region =\> "us-east-1"  
}  
}

if "mit" in [tags] {  
amazon\_es {  
hosts =\> ["[https://mymitcluster](https://mymitcluster)"]  
region =\> "us-east-1"  
}  
}  
}

I'm not seeing any data go into ES with this configuration. I've tested with

stdout { codec =\> rubydebug }, and I can see the tags going in and coming out.

I've tested going to individual clusters. They work independently.

I just get no data into the clusters when it's like this.

Thanks

---

<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:** [September 17, 2019, 11:04pm UTC](https://discuss.elastic.co/t/if-statement-in-logstash-output/199885/2 "2019-09-17T23:04:43Z")

</div>

As I read it, in your filebeat configuration your are adding a [field called environment](https://www.elastic.co/guide/en/beats/filebeat/master/add-tags.html). However, in your logstash configuration you are testing a field called tags.

add\_tag is used to add an array of values to a named field.

---

<div class="post-metadata">

**Author:** ![Brian\_DiCola](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brian_dicola/32/54179_2.png) [@Brian\_DiCola](https://discuss.elastic.co/u/Brian_DiCola)\
**Post date:** [September 18, 2019, 1:03pm UTC](https://discuss.elastic.co/t/if-statement-in-logstash-output/199885/3 "2019-09-18T13:03:19Z")

</div>

I changed it to simply this:

processors:

- add\_tags:  
tags: [dev]

Seems to work.

---

<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:** [October 16, 2019, 1:03pm UTC](https://discuss.elastic.co/t/if-statement-in-logstash-output/199885/4 "2019-10-16T13:03:20Z")

</div>

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