# Removing duplications in output block

**URL:** <https://discuss.elastic.co/t/removing-duplications-in-output-block/91549>\
**Category:** Logstash\
**Created:** [July 2, 2017, 10:18am UTC](https://discuss.elastic.co/t/removing-duplications-in-output-block/91549 "2017-07-02T10:18:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BentCoder](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@BentCoder](https://discuss.elastic.co/u/BentCoder)\
**Post date:** [July 2, 2017, 10:18am UTC](https://discuss.elastic.co/t/removing-duplications-in-output-block/91549/1 "2017-07-02T10:18:35Z")

</div>

Hi,

Any way of slimming `output` down? Duplication looks ugly. For example `host`, `sniffing` and `manage_template` could be made common/shared.

Thanks

```
output {
    if [type] == "apache-access" {
        elasticsearch {
            hosts => ["localhost:9200"]
            sniffing => true
            manage_template => false
            index => "ap-index"
        }
    } else if [type] == "symfony-dev" {
        elasticsearch {
            hosts => ["localhost:9200"]
            sniffing => true
            manage_template => false
            index => "my-hello-index"
        }
    }
}
```

---

<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:** [July 3, 2017, 6:18am UTC](https://discuss.elastic.co/t/removing-duplications-in-output-block/91549/2 "2017-07-03T06:18:30Z")

</div>

As the only thing that differs is the index prefix, you can set the index prefix in a metadata parameter in the index block and then reference this in a single output as described [in this post](https://discuss.elastic.co/t/syntactic-error-on-logstash-config/91466/2). This means that you only need one elasticsearch output irrespective of index name, which in addition to clean up the configuration also can improve performance as a batch only will result in a single, larger bulk request.

---

<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 31, 2017, 6:18am UTC](https://discuss.elastic.co/t/removing-duplications-in-output-block/91549/3 "2017-07-31T06:18:49Z")

</div>

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