Created nested host when proxying metrics with influxdb_listener

Hello all,

I have a Management server that controls various appliances. It collects metrics both from itself, and it also receives proxied influxdb format metrics remotely from the appliance. All of them output to a remote graphite. It looks like this:

[agent]
  hostname = "${MANAGEMENT_ID}"
  omit_hostname = false

[[outputs.graphite]]
  ## TCP endpoint for your graphite instance.
  ## If multiple endpoints are configured, the output will be load balanced.
  ## Only one of the endpoints will be written to with each iteration.
  servers = ["${GRAPHITE_URL}"]

  ## Prefix metrics name
  prefix = "application"

  ## Graphite output template
  ## see https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
  template = "host.tags.measurement.field"

  ## timeout in seconds for the write connection to graphite
  timeout = 2

[[inputs.influxdb_listener]]
  service_address = ":8186"

##....    
## VARIOUS OTHER INPUTS

The metrics coming from the influxdb_listener have a different host tag from the MANAGEMENT_ID set in agent. For those metrics output to graphite, I want to have a nested hierarchy, that would look like this:

Metric originating from Management with id mgmt_number1:
application.mgmt_number1.cpu0.cpu.usage

Metric originating from appliance with id *appliance_no1":
application.mgmt_number1.appliances.appliance_no1.cpu0.cpu.usage

My question is whether it is possible to edit the host tag in such a way? By default, what I get on the Graphite is appliance metrics that look like this:
application.appliance_no1.cpu0.cpu.usage

I did various manipulations, with tagexclude (resulting in the host part of the metric being dropped altogether) and name_prefix (which added my desired prefix way later inside the metric, ahead of the measurement name).
Is there something that would allow to morph a new host value out of the two?

Hello @borisdan,
I think you might need to use the execd processor plugin.

It makes telegraf extensible in any language and allows you to process your incoming line protocol however you need.
Here’s an example used to generate forecasts.

Thank you @Anaisdg. execd did prove useful for troubleshooting purposes, but in the end I did something else:

Finally, here’s what I did:

[agent]
  hostname = "${MANAGEMENT_ID}"
  omit_hostname = false

[[outputs.graphite]]
  servers = ["${GRAPHITE_URL}"]
  prefix = "application"
  template = "host.source.appliance.tags.measurement.field"
  timeout = 2

[[inputs.influxdb_listener]]
  service_address = ":8186"
  [inputs.influxdb_listener.tags]
      source = "appliances"

[[processors.rename]]
  order = 1
  [[processors.rename.replace]]
    tag = "host"
    dest = "appliance"

[[processors.override]]
  order = 2
  [processors.override.tags]
    host = "${MANAGEMENT_ID}"
1 Like