Use Telegraf as a router

Is it possible to use Telegraf as a router? For example: to create a rule that, depending on the incoming metric, it would route it to an unique output.

Is there any documentation on this topic

I may be wrong, but I don’t believe so. One way to accomplish this could be to have a separate telegraf running with a different config for each metric input/output combo.

This can be done to some degree, the simplest version of this is routing based on a static tag.

This example selects the output based on a static tag that is added in the input and then removed in the output before writing (example thanks to @phemmer):

    influxdb_database = "other"

  urls = [""]
  database = "db_default"
    influxdb_database = ["*"]

  urls = [""]
  database = "db_other"
  tagexclude = ["influxdb_database"]
    influxdb_database = ["other"]

You can take this further by using processors to create the tags, for example instead of defining the tag statically in the configuration, add the tag in the regex processor based on an existing value and use these to route the metrics.

1 Like