# Advice needed to index multiple files from logstash to elastic search

**URL:** <https://discuss.elastic.co/t/advice-needed-to-index-multiple-files-from-logstash-to-elastic-search/38548>\
**Category:** Logstash\
**Created:** [January 6, 2016, 8:58pm UTC](https://discuss.elastic.co/t/advice-needed-to-index-multiple-files-from-logstash-to-elastic-search/38548 "2016-01-06T20:58:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![subbu.nv](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@subbu.nv](https://discuss.elastic.co/u/subbu.nv)\
**Post date:** [January 6, 2016, 8:58pm UTC](https://discuss.elastic.co/t/advice-needed-to-index-multiple-files-from-logstash-to-elastic-search/38548/1 "2016-01-06T20:58:38Z")

</div>

Hi All,

when i index a single file in logstash, as multiple threads are running , the indices pushed to elastic search in also multiple. instead can i control the order of indexing in logstash.

For example. i have the below logfiles.  
abc.log  
abc1.log  
abc2.log  
abc3.log

is there any logstash configuration to have the thread execute one logfile at a time. multiple threads are fine, but my requirement is to index one file /thread (not multiple threads on a single file)  
abc.log - thread 1  
abc1.log - thread 2  
abc2.log - thread 1  
abc3.log - thread 2 .. like this

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 6, 2016, 9:06pm UTC](https://discuss.elastic.co/t/advice-needed-to-index-multiple-files-from-logstash-to-elastic-search/38548/2 "2016-01-06T21:06:54Z")

</div>

Not unless you make LS single threaded.

---

<div class="post-metadata">

**Author:** ![subbu.nv](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@subbu.nv](https://discuss.elastic.co/u/subbu.nv)\
**Post date:** [January 6, 2016, 9:31pm UTC](https://discuss.elastic.co/t/advice-needed-to-index-multiple-files-from-logstash-to-elastic-search/38548/3 "2016-01-06T21:31:40Z")

</div>

thanks for your response.  
the main reason i am looking for such functionality is to achieve below.

1. search a regex in elastic search and get back results.
2. while fetch results, i should pull a snippet with few lines prior and after the results.

As the indexing is random, i could not get the correct snippet. if i use a timestamp as the identifier , it is giving instances from multiple places even in a single file.  
the above is working fine if i use a single thread. but in real time there could be more files and if i use single thread the indexing time would be longer.

Do you have some suggestions?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 6, 2016, 9:32pm UTC](https://discuss.elastic.co/t/advice-needed-to-index-multiple-files-from-logstash-to-elastic-search/38548/4 "2016-01-06T21:32:43Z")

</div>

Are the logs related, or do you want them to be completely separate.

---

<div class="post-metadata">

**Author:** ![subbu.nv](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@subbu.nv](https://discuss.elastic.co/u/subbu.nv)\
**Post date:** [January 6, 2016, 9:35pm UTC](https://discuss.elastic.co/t/advice-needed-to-index-multiple-files-from-logstash-to-elastic-search/38548/5 "2016-01-06T21:35:02Z")

</div>

the logs are related. they are placed as separate files and even i want them separate.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 6, 2016, 9:35pm UTC](https://discuss.elastic.co/t/advice-needed-to-index-multiple-files-from-logstash-to-elastic-search/38548/6 "2016-01-06T21:35:52Z")

</div>

The easiest way then would be to put them in separate indices.

---

<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, 5:16am UTC](https://discuss.elastic.co/t/advice-needed-to-index-multiple-files-from-logstash-to-elastic-search/38548/7 "2017-07-06T05:16:37Z")

</div>

Closed on July 6, 2017, 5:16am UTC


