In our case it would be very valuable to be able to dynamically set the template path especially in order to consolidate down to one elasticsearch output
You cannot dynamically assign a template, because templates are uploaded only once, at initialization. Without the flow of traffic, deterministic variable completion does not happen. Since there is no traffic flow during initialization, there is nothing there which can "fill in the blank" for %{application}.
Index templates are only used when a new index is created, and so it is that templates are not uploaded every time a document reached the Elasticsearch output block in Logstash (can you imagine how much slower it would be if Logstash had to do that?). If you intend to have multiple templates, they need to be preexistent, and uploaded to Elasticsearch before any data gets sent there. You can do this with a script of your own making using curl and Elasticsearch API calls. This also permits you to update templates without having to restart Logstash. You could run the script any time before index rollover, and when the new indices get created, they'll have the new template settings.
Logstash can send data to a dynamically configured index name, just as you have above. The template must be pre-existent in Elasticsearch before that is attempted, or Elasticsearch will create a best-guess mapping, rather than what you wanted to send in a template. Honestly, templates can and ought to be completely independent of Logstash. We only added this functionality for an improved out-of-the-box experience for brand new users. The default template is less than ideal for advanced use cases, and Logstash is not a good tool for template management if you have more than one index template.
If you manage the templates outside of Logstash, then this:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.