Push specific metrics to a different measurement


I’m using Telegraf version 1.21 and the gNMI input plugin to subscribe to sensors on a network device.

I’m receiving the following metrics from the interfaces sensor:


Everything is being written to the “interfaces” measurement.

Is there any way to create a new measurement named “optics” on the fly when a metric that starts with “optics” is seen?

In the end, I would like to have two measurements (interfaces, optics) and have all the metrics starting with “optics” stored under the “optics” measurement.


It sounds like you have successfully obtained measurements, and are interested in splitting them into two distinct measurements based on path or name?

One option would be to have two gNMI input plugins where you use one to collect state and the other to collect optics and then rename each input plugin’s measurements using the alias option.

The other option would be to use starlark to see about creating a new measurement as well.

the gNMI input plugin has some built-in options to define measurements names, see the docs in GitHub.

I’ve never used it, but I think even just the “static” name should do the trick, see the key name under the [[inputs.gnmi.subscription]] section.
There is also a node that allows some sort of expression to define aliases [inputs.gnmi.aliases] but it’s not totally clear to me how it works.

I suggest exploring those options first.

1 Like