# I need to have multiple index based on the path of log file

**URL:** <https://discuss.elastic.co/t/i-need-to-have-multiple-index-based-on-the-path-of-log-file/283667>\
**Category:** Elasticsearch\
**Created:** [September 8, 2021, 1:23pm UTC](https://discuss.elastic.co/t/i-need-to-have-multiple-index-based-on-the-path-of-log-file/283667 "2021-09-08T13:23:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![akhilkandari](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@akhilkandari](https://discuss.elastic.co/u/akhilkandari)\
**Post date:** [September 8, 2021, 1:23pm UTC](https://discuss.elastic.co/t/i-need-to-have-multiple-index-based-on-the-path-of-log-file/283667/1 "2021-09-08T13:23:46Z")

</div>

**we have 2 environment one dev & one prod storing logs in dev path & prod path so how can i have 2 separate index for both of these based on path**

```auto
input {
    stdin{
        type => "stdin-type"
		}
    file{
        type => "json"
        path => ["/var/files/prod/*.log","/var/files/prod/**/*.log"]
        start_position => "beginning"
		tags => "prod"
		} file{
        type => "json"
        path => ["/var/files/dev/*.log","/var/files/dev/**/*.log"]
        start_position => "beginning"
		tags => "dev"
		}	}
filter {
    grok {
        match => {
            "message" => ["%{JSON:payload_raw}"]
        }
        pattern_definitions => {
            "JSON" => "{.*$"
        } }
    json {
        source => "payload_raw"
        target => "payload"
    } mutate {
        remove_field => ["payload_raw","message"]
    } date {
                match => ["[payload][datetime]", "yyyy-MM-dd HH:mm:ss,SSS" ]
                target => "@timestamp"
        }}
output {
    stdout {
        codec => rubydebug }
	if tags == "prod"
	{ elasticsearch {
        hosts => "localhost:9200"
		index => "prod-logs" }	}
	if tags == "dev"
	{
    elasticsearch {
        hosts => "localhost:9200"
		index => "dev-logs" }	}}

```

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [September 8, 2021, 1:26pm UTC](https://discuss.elastic.co/t/i-need-to-have-multiple-index-based-on-the-path-of-log-file/283667/2 "2021-09-08T13:26:27Z")

</div>

Hello,

Can you explain what you are trying to do and what is not working? You just pasted your configuration without any explanation what is the issue.

---

<div class="post-metadata">

**Author:** ![akhilkandari](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@akhilkandari](https://discuss.elastic.co/u/akhilkandari)\
**Post date:** [September 9, 2021, 4:52am UTC](https://discuss.elastic.co/t/i-need-to-have-multiple-index-based-on-the-path-of-log-file/283667/3 "2021-09-09T04:52:37Z")

</div>

hi  
i have define 2 path to store logs one for dev & other for prod,  
i want to have 2 separate index for dev & prod.  
this is my conf file but logs are not parse with this  
how can i achieve this

---

<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:** [October 7, 2021, 4:53am UTC](https://discuss.elastic.co/t/i-need-to-have-multiple-index-based-on-the-path-of-log-file/283667/4 "2021-10-07T04:53:27Z")

</div>

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