# How to handle multiple inputs with Logstash to different indices

**URL:** <https://discuss.elastic.co/t/how-to-handle-multiple-inputs-with-logstash-to-different-indices/24541>\
**Category:** Logstash\
**Created:** [June 29, 2015, 11:21am UTC](https://discuss.elastic.co/t/how-to-handle-multiple-inputs-with-logstash-to-different-indices/24541 "2015-06-29T11:21:02Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [June 29, 2015, 12:54pm UTC](https://discuss.elastic.co/t/how-to-handle-multiple-inputs-with-logstash-to-different-indices/24541/2 "2015-06-29T12:54:27Z")

</div>

Use the [grok filter](https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html) to extract the project name from the input file path (stored in the `path` field), then reference that field when setting the index pattern of the [elasticsearch output](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html).

```
elasticsearch {
  ...
  index => "logstash-%{project}-%{+YYYY.MM.dd}"
}

```

---

_[View the full topic](https://discuss.elastic.co/t/how-to-handle-multiple-inputs-with-logstash-to-different-indices/24541)._
