# Logstash output IF conditions not working with JMS input

**URL:** <https://discuss.elastic.co/t/logstash-output-if-conditions-not-working-with-jms-input/224906>\
**Category:** Logstash\
**Tags:** windows\
**Created:** [March 24, 2020, 6:18pm UTC](https://discuss.elastic.co/t/logstash-output-if-conditions-not-working-with-jms-input/224906 "2020-03-24T18:18:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhruvp](https://avatars.discourse-cdn.com/v4/letter/d/7c8e57/32.png) [@dhruvp](https://discuss.elastic.co/u/dhruvp)\
**Post date:** [March 24, 2020, 6:18pm UTC](https://discuss.elastic.co/t/logstash-output-if-conditions-not-working-with-jms-input/224906/1 "2020-03-24T18:18:13Z")

</div>

Hi I am new to ELK Stack and I have working solutions for logstash for one index output but now i have multiple microservices sending logs to same JMS JNDI Name using Solace queue but I want to output them in separate indexes in logstash

I have two questions:

1. How can i make IF Else condition work in Logstash Output?
2. How do i add one of the field named xyz which has description of which microservice this logs belongs to in IF condition so we can separate them in diff indexes?

Please help me. Thank you  
**SampleLOG:**  
{  
"Date": "3/23/2020 7:22:13 PM",  
"Level": "WARN",  
"xyz": "generator",  
"Message": "Route matched with {action = "GetState", controller = "Service"}",  
"Location": "Some Path for file location (file:///C://repo//testsolution//appender//log4net//generator.cs):70)"  
}  
{  
"Date": "3/22/2020 7:26:13 PM",  
"Level": "INFO",  
"xyz": "publisher",  
"Message": "Route matched with {action = "GetState", controller = "Service"}",  
"Location": "Some Path for file location (file:///C://repo//testsolution//appender//log4net//publisher.cs):70)"  
}

**Logstash CONF:**  
input {  
jms {  
# Logstash Configuration Settings.  
include\_header =\> true  
include\_properties =\> true  
include\_body =\> true  
use\_jms\_timestamp =\> false  
destination =\> "QUEUE\_NAME"  
pub\_sub =\> false  
# JNDI Settings  
jndi\_name =\> "JNDI\_NAME"  
jndi\_context =\> {  
JNDI\_CONTEXT  
}   
require\_jars =\> [JAR PATH]  
}  
}  
filter {  
json {  
source =\> "message"  
target =\> "log"  
}  
}  
output {   
if [log][xyz] == "generator" {  
elasticsearch{  
hosts =\> [HOST]  
index =\> "generator-"  
}  
}   
Else if [log][xyz] == "publisher"{  
elasticsearch{  
hosts =\> [HOST]  
index =\> "publisher-"  
}  
}  
}`

---

<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:** [April 21, 2020, 6:18pm UTC](https://discuss.elastic.co/t/logstash-output-if-conditions-not-working-with-jms-input/224906/2 "2020-04-21T18:18:17Z")

</div>

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