Error parsing tagpass in telegraf.conf

Hi, newbie user/developer here. I’m having a problem with my telegraf installation failing to start up with the following error:

20T22:14:08Z E! [telegraf] Error running agent: Error loading config file /etc/telegraf/telegraf.conf: error parsing influxdb_v2 array, line 106:{4405 4428}: found unexpected format while parsing “tagpass”, expecting string array/slice format on each entry

My tagpass config looks like this:

  ## The URLs of the InfluxDB cluster nodes.
  ## Multiple URLs can be specified for a single cluster, only ONE of the
  ## urls will be written to each interval.
  ##   ex: urls = [""]
  urls = ["http://localhost"]

  ## Token for authentication.
  token = "obfuscated"

  ## Organization is the name of the organization you wish to write to; must exist.
  organization = "test-customer-002"

    org = ["test-customer-002"]

  ## Destination bucket to write into.
  bucket = "default"

Any ideas what I’ve done wrong here?

I think it should be:

# [outputs.influxdb_v2.tagpass]  # IMHO this is not necessary for tagpass
namepass = ["test-customer-002"]

Thanks @Franky1 isn’t namepass a different function? I need to get a tag value from an input, and then have the output check that tag before processing. Each message from an input could have a different value for the tag (so I can’t hard code it at the input level).

Ehm sorry, you are right… :blush:

Second try, i think you have to put the whole section with tagpass at the end of the output plugin config:

#  your whole plugin config here
# ....
  bucket = "default"
  # tagpass section at the end
    org = ["test-customer-002"]

Thanks @Franky1 I’ll try that. Out of curiosity I just tried changing it to [[outputs.influxdb_v2.tagpass]] (double square brackets) and it starts up ok now. Seems like the docs showing a single bracket notation are wrong. Either that or I’ll find out later it doesn’t work with the double brackets…

Hi @Franky1, I had another issue with “bucket not found” which was resolved by moving my tagpass section to the end of the output config as you suggested, or so I thought… Found out that telegraf was writing every input to both influxdb2 outputs, whether the tag matched or not. So now I’m really confused about tagpass. Does it work the way I’m expecting it to?

In my mqtt_consumer input, I get the tag “org” from the message topic using topic parsing. I know this works because I can see the org tag and values in the data. I have set up 2x influxdb2 outputs, each one with a tagpass section specifying the value that the org tag must have before writing the data (see my original post for config). As mentioned, if I put the tagpass at the end of the plugin config, it seems to write first before evaluating the tag. If I put it at the top of the config, I get a bunch of errors because it tries to output with no connection or bucket info. So I’m stuck. Where do I put it so it only writes data when the tag passes?

Sorry, turns out I got the double brackets part wrong. The docs are correct about the single brackets and you were right about putting the tagpass at the end of the output plugin config (not sure if the docs mention that?). Thanks for your help, all working now.