# Outputting into different indices based on source

**URL:** <https://discuss.elastic.co/t/outputting-into-different-indices-based-on-source/201457>\
**Category:** Logstash\
**Created:** [September 27, 2019, 6:54pm UTC](https://discuss.elastic.co/t/outputting-into-different-indices-based-on-source/201457 "2019-09-27T18:54:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![d112](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@d112](https://discuss.elastic.co/u/d112)\
**Post date:** [September 27, 2019, 6:54pm UTC](https://discuss.elastic.co/t/outputting-into-different-indices-based-on-source/201457/1 "2019-09-27T18:54:47Z")

</div>

I want to create different indices based on the source of the data. I currently have:

```
input {
beats {
    port => 5044
}}

filter {
    if ([source] =~ "examiner.log") {
        json {
        source => "message"	
        add_tag => ["examiner"]
        }
    } else if ([source] =~ "temp.log") {
        mutate {
            add_tag => ["TEMP"]
        }
    }
}

output {
    if ([source] =~ "examiner.log") {
        elasticsearch {
        hosts => "localhost:9200"
        index => "examiner"
        }
    } else {
         elasticsearch {
        hosts => "localhost:9200"
        index => "data"
        }
    }
}

```

Only the data index gets created, I'm not sure why the first conditional is skipped in the output.

---

<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 25, 2019, 6:54pm UTC](https://discuss.elastic.co/t/outputting-into-different-indices-based-on-source/201457/2 "2019-10-25T18:54:50Z")

</div>

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