In Telegraf how to include only specific values of a tag

2k Views Asked by At

I am using a prometheus plugin in Telegraf to get the data from promitor and push it to InfluxDB. However, as per my requirement there is one tag named as "resource_name" and it contains multiple values let's say ["A", "B", "C", "D", "E", "F", "G", "H"]. Out of these values I only want ["A", "B", "C", "D", "E"] and these only values should be inserted into InfluxDB.

To achieve my requirement I am using below plugin and using tagpass to allow only specific values.

[[inputs.prometheus]]
  metric_version = 2
  name_suffix = "_promitor_abcd"
  urls = ["http://IP:Port/metrics"]
  tagexclude = [ "host", "url" ]
  [inputs.prometheus.tagpass]
    resource_name = [ "A", "B", "C", "D", "E" ]

After using this when I run this configuration file I am still able to see all the values in InfluxDB under "resource_name" tag or column and not the values which I specified above in my configuration file.

Can anybody help me to understand what went wrong here and how to push only specific values in influxDB?

1

There are 1 best solutions below

0
On

The tagpass parameter is one of the available metric filters in telegraf. tagpass is specific to the tag key and value. Metrics that contain keys and values specified by tagpass are emitted. So if you have a metric as follows:

metric,color=red,height=3 value=2
metric,color=red,width=4 value=2

For exmaple the following tagpass config:

  [[outputs.influxdb.tagpass]]
    height = ["*"]

Would pass any metrics with the height tag. You can place any value you want to filter on, with globs supported as well.

Thanks!