influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.51k stars 5.55k forks source link

Elasticsearch Output: Support using tag in template name #9695

Open kevisong opened 3 years ago

kevisong commented 3 years ago

Feature Request

Opening a feature request kicks off a discussion.

Proposal: Support using tag with notation {{tag_name}} in template name

Current behavior: index_name supports using tag as part of the name. But template_name can only be hardcoded.

[global_tags]
  monitor = "http"
[[outputs.elasticsearch]]
  urls = [ "http://127.0.0.1:9200" ]
  index_name = "telegraf-{{monitor}}-%Y.%m.%d"
  template_name = "telegraf-http"

Desired behavior: Both index_name and template_name support tag notation

[global_tags]
  monitor = "http"
[[outputs.elasticsearch]]
  urls = [ "http://127.0.0.1:9200" ]
  index_name = "telegraf-{{monitor}}-%Y.%m.%d"
  template_name = "telegraf-{{monitor}}"

Use case:

When the global_tags.monitor is changed, the hardcoded template_name = "telegraf-http" may be forgotten.

If template_name supports tag reference, we only need to change the global_tags.monitor and the template_name will be modified automatically.

reimda commented 2 years ago

Do you still need this functionality? Are you able to implement it and submit a PR? Thanks!

kevisong commented 2 years ago

Do you still need this functionality? Are you able to implement it and submit a PR? Thanks!

Yeah. This feature might be helpful when there is a fair amount of elasticsearch outputs using the same global_tags.

I can implement it and submit a PR later on.