# Is it possible to create multiple index in single config file with different input locations?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-create-multiple-index-in-single-config-file-with-different-input-locations/64062>\
**Category:** Logstash\
**Created:** [October 26, 2016, 8:37pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-multiple-index-in-single-config-file-with-different-input-locations/64062 "2016-10-26T20:37:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![asac2](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@asac2](https://discuss.elastic.co/u/asac2)\
**Post date:** [October 26, 2016, 8:37pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-multiple-index-in-single-config-file-with-different-input-locations/64062/1 "2016-10-26T20:37:27Z")

</div>

**Is it possible to create multiple index in single config file with different input locations?**

---

<div class="post-metadata">

**Author:** ![eperry](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eperry/32/551_2.png) [@eperry](https://discuss.elastic.co/u/eperry)\
**Post date:** [October 26, 2016, 11:30pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-multiple-index-in-single-config-file-with-different-input-locations/64062/2 "2016-10-26T23:30:17Z")

</div>

yes  
inputs have no bearing on you creating indexes

[https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-index](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-index)

just like it uses in the eample logstash-%{yyyy.mmm.dd} you can %{filedname}-%{yyyy.mm.ddd} or wrap each elastisearch output in an if statement like

if [type] =~ /mytype/{  
elasticsearch {  
....  
.....  
index=\> "mytype-today"  
}  
}else{  
elasticsearch {  
....  
.....  
index=\>"allothertypes-today"  
}  
}

---

<div class="post-metadata">

**Author:** ![eperry](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eperry/32/551_2.png) [@eperry](https://discuss.elastic.co/u/eperry)\
**Post date:** [October 26, 2016, 11:34pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-multiple-index-in-single-config-file-with-different-input-locations/64062/3 "2016-10-26T23:34:11Z")

</div>

of course I think it would be better to use field names to sort your data. you can add a field on your file input

input {  
file {  
path=/var/log/message  
add\_field =\> { "dst\_index" , "myindex" }  
}  
file {  
path=\>/var/log/audit  
add\_field =\> {"dst\_index", "someotherindex"}  
}  
}

output{  
elasticsearch{  
....  
.....  
index=\>"%{dst\_index}-%{yyyy.mm.ddd}"  
}  
}

I like this way cause it provides the most flexibility,

---

<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:** [July 6, 2017, 4:32am UTC](https://discuss.elastic.co/t/is-it-possible-to-create-multiple-index-in-single-config-file-with-different-input-locations/64062/4 "2017-07-06T04:32:29Z")

</div>


