Elasticsearch template created by logstash uses wrong name

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

  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-*:

$ 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.

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.