# Can't separated elasticsearch index using logstash

**URL:** <https://discuss.elastic.co/t/cant-separated-elasticsearch-index-using-logstash/178661>\
**Category:** Logstash\
**Created:** [April 26, 2019, 2:30pm UTC](https://discuss.elastic.co/t/cant-separated-elasticsearch-index-using-logstash/178661 "2019-04-26T14:30:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LockyZ](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lockyz/32/45054_2.png) [@LockyZ](https://discuss.elastic.co/u/LockyZ)\
**Post date:** [April 26, 2019, 2:30pm UTC](https://discuss.elastic.co/t/cant-separated-elasticsearch-index-using-logstash/178661/1 "2019-04-26T14:30:43Z")

</div>

Hello Guys,

I'm trying to create separated indexes using logstash 6.7, basically I have a server running filebeat which sends two logs to a logstash which sends to a elasticsearch, below you may find my config files.

filebeat.yml  
#=========================== Filebeat inputs =============================

filebeat.prospectors:

- type: log  
paths:

- type: log  
paths:

#============================= Filebeat modules ===============================

filebeat.config.modules:

# Glob pattern for configuration loading

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

reload.enabled: false

#==================== Elasticsearch template setting ==========================

setup.template.name: "mdw\_filebeat"  
setup.template.pattern: "mdw\_filebeat\_\*"  
setup.template.fields: "fields.yml"  
setup.template.overwrite: false  
setup.template.settings:  
index.number\_of\_shards: 1  
index.codec: best\_compression

#----------------------------- Logstash output --------------------------------  
output.logstash:

# The Logstash hosts

hosts: ["logstash-server1:9500" , "logstash-server2:9500"]  
loadbalance: true

#================================ Processors =====================================

# Configure processors to enhance or manipulate events generated by the beat.

processors:

- add\_host\_metadata: ~
- add\_cloud\_metadata: ~

logstash config file

output {  
if [log\_type] == "rtdm-access" {  
elasticsearch {  
hosts =\> ["elasticsearch-server1:9200",elasticsearch-server2:9200]  
index =\> "access-rtdm"  
}  
}  
else if [log\_type] == "rtdm-gc" {  
elasticsearch {  
hosts =\> ["elasticsearch-server1:9200",elasticsearch-server2:9200]  
index =\> "gc-rtdm"  
}  
}  
#only for debugging  
stdout { codec =\> rubydebug }

}

Note.: If I remove the IF/Else and configure to create a standard index this it creates, but unfortunately this is not what I need, can anyone please explain what I'm doing wrong?

Filebeat / Logstash and ElasticSearch version is 6.7

thanks in advance,

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 29, 2019, 5:36am UTC](https://discuss.elastic.co/t/cant-separated-elasticsearch-index-using-logstash/178661/2 "2019-04-29T05:36:36Z")

</div>

I would recommend you look at the events being output to stdout. I would expect the `[log_type]` field to actually be stored as `[fields][log_type]`. You may therefore need to change your conditionals to reflect this.

---

<div class="post-metadata">

**Author:** ![LockyZ](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lockyz/32/45054_2.png) [@LockyZ](https://discuss.elastic.co/u/LockyZ)\
**Post date:** [April 29, 2019, 3:13pm UTC](https://discuss.elastic.co/t/cant-separated-elasticsearch-index-using-logstash/178661/3 "2019-04-29T15:13:51Z")

</div>

Christian\_Dahlqvist,

Thanks a lot mate, by modifying my logstash output from [log\_type] to [fields][log\_type] - I was able to see the indexes the way I wanted, thanks a lot for your help !

---

<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 27, 2019, 3:13pm UTC](https://discuss.elastic.co/t/cant-separated-elasticsearch-index-using-logstash/178661/4 "2019-05-27T15:13:51Z")

</div>

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