# Unable to change output index according to event fields

**URL:** https://discuss.elastic.co/t/unable-to-change-output-index-according-to-event-fields/107240
**Category:** Logstash
**Created:** [November 10, 2017, 9:05pm UTC](https://discuss.elastic.co/t/unable-to-change-output-index-according-to-event-fields/107240 "2017-11-10T21:05:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pravj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pravj/32/20386_2.png) [@pravj](https://discuss.elastic.co/u/pravj)
#### Post date: [November 10, 2017, 9:05pm UTC](https://discuss.elastic.co/t/unable-to-change-output-index-according-to-event-fields/107240/1 "2017-11-10T21:05:25Z")

</div>

I want to use different indices for "filebeat" and "metricbeat" input sources, shipping events to the logstash.

Here is the **logstash.conf** we are using.

```auto
input
{
    beats
    {
        ssl => false
        host => "0.0.0.0"
        port => 5044
    }
    gelf
    {
        host => "0.0.0.0"
        port => 12201
    }
    http
    {
        ssl => false
        host => "0.0.0.0"
        port => 8888
    }
    tcp
    {
        mode => "server"
        host => "0.0.0.0"
        port => 5010
    }
    udp
    {
        host => "0.0.0.0"
        port => 5000
    }
}

output
{
    if [fields][beat] == "metricbeat" {
        elasticsearch {
            hosts => ["127.0.0.1:9200"]
            document_id => "%{logstash_checksum}"
            index => "%{[fields][beat]}-%{+YYYY.MM.dd}"
        }
    } else {
        elasticsearch {
            hosts => ["127.0.0.1:9200"]
            document_id => "%{logstash_checksum}"
            index => "logstash-%{+YYYY.MM.dd}"
        }
    }
}

```

The index is being created but only one event is inserted in the index.

The metricbeat configuration has a decicated field named **beat**.

```auto
fields:
    beat: metricbeat

```

Here is the listing of all the indices.

```auto
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open logstash-2017.11.10 SCPT2qBJTsK1Hdgh3sOOCQ 5 1 8933 1 7.8mb 7.8mb
yellow open metricbeat-2017.11.10 RGWdtyJFS76bSfeA-lLAZg 5 1 1 55 87.4kb

```

I'm having a hard time routing the beat events in separate indices.  
Please help me figure it out.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [November 10, 2017, 9:52pm UTC](https://discuss.elastic.co/t/unable-to-change-output-index-according-to-event-fields/107240/2 "2017-11-10T21:52:18Z")

</div>

> [@pravj](#):
>
> %{logstash\_checksum}

How is `logstash_checksum` calculated? Could it be that it does not exist or always evaluates to the same thing for Metricbeat records, causing the same record to be updated over and over again?

---

<div class="post-metadata">

### Author: ![pravj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pravj/32/20386_2.png) [@pravj](https://discuss.elastic.co/u/pravj)
#### Post date: [November 11, 2017, 7:58am UTC](https://discuss.elastic.co/t/unable-to-change-output-index-according-to-event-fields/107240/3 "2017-11-11T07:58:52Z")

</div>

Removing this key worked, partially. Thank you!  
It was present in the default configuration file that I found in my bitnami based setup.

Now the events are being indexed in the **metricbeat-** \* index but still, some of the metricbeat generated events are sent to the **logstash-** \* index too.

I'm afraid I might miss some events if I keep observing the dedicated index for events ( **metricbeat-** \*)

Edit:  
It looks like all the metricbeat events are indexed in the **logstash-** \* index too, can't get my head around it.

---

<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: [November 14, 2017, 6:25am UTC](https://discuss.elastic.co/t/unable-to-change-output-index-according-to-event-fields/107240/4 "2017-11-14T06:25:46Z")

</div>

Show an example event. Copy/paste from the JSON tab in Kibana.

---

<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: [December 12, 2017, 6:27am UTC](https://discuss.elastic.co/t/unable-to-change-output-index-according-to-event-fields/107240/5 "2017-12-12T06:27:06Z")

</div>

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