# Elasticsearch template created by logstash uses wrong name

**URL:** <https://discuss.elastic.co/t/elasticsearch-template-created-by-logstash-uses-wrong-name/48594>\
**Category:** Logstash\
**Created:** [April 27, 2016, 8:14pm UTC](https://discuss.elastic.co/t/elasticsearch-template-created-by-logstash-uses-wrong-name/48594 "2016-04-27T20:14:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattnworb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattnworb/32/9443_2.png) [@mattnworb](https://discuss.elastic.co/u/mattnworb)\
**Post date:** [April 27, 2016, 8:14pm UTC](https://discuss.elastic.co/t/elasticsearch-template-created-by-logstash-uses-wrong-name/48594/1 "2016-04-27T20:14:02Z")

</div>

My logstash config (version 2.3.1) has an output section like

```auto
  elasticsearch {
    hosts => ...
    index => 'foobar-%{+YYYY.MM.dd}'
    template_name => 'foobar'
  }

```

However the template created with this name does not refer to the `foobar` index as I would have imagined, but instead to `logstash-*`:

```auto
$ curl logelask.company.net:9200/_template/foobar
{"foobar":{"order":0,"template":"logstash-*", ...

```

If I understand correctly, then this means that ElasticSearch never applies the template to events in the `foobar-YYYY.MM.dd` indices.

Am I configured this wrong, or misunderstanding something? I would have expected the `template` inside the template to refer to my index pattern.

---

<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:** [April 30, 2016, 3:26pm UTC](https://discuss.elastic.co/t/elasticsearch-template-created-by-logstash-uses-wrong-name/48594/2 "2016-04-30T15:26:18Z")

</div>

This is expected. The `template_name` only controls the name of the template. The index name pattern is still hardwired into the template file. You'll have to create your own template file with the desired index name pattern.

---

<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 6, 2017, 4:59am UTC](https://discuss.elastic.co/t/elasticsearch-template-created-by-logstash-uses-wrong-name/48594/3 "2017-07-06T04:59:52Z")

</div>


