Influx v2 - flux query not returning data when filters using tag filters

Hello!

I hope someone can give some light to this problem.

I am collecting telemetry data using the telegraf jti_openconfig_telemetry input plugin and storing in an influx v2 database.
I have some tags that I am trying to use as filters, but for some reason, the queries don’t return data when these filters are used.

Example:

Query that does not return data:

from(bucket: "telemetry")
  |> range(start: v.timeRangeStart, stop:v.timeRangeStop)
  |> filter(fn: (r) =>
    r._measurement == "/interfaces/" and
    r._field == "/interfaces/interface/subinterfaces/subinterface/state/counters/in-octets"
  )
  |> filter(fn: (r) => r["device"] == "csp1")
  |> filter(fn: (r) => r["/interfaces/interface/@name"] == "et-0/1/1")

But when I use a more broader query (removing the tag filters), I have data being presented. Like this:

from(bucket: "telemetry")
  |> range(start: v.timeRangeStart, stop:v.timeRangeStop)
  |> filter(fn: (r) =>
    r._measurement == "/interfaces/" and
    r._field == "/interfaces/interface/subinterfaces/subinterface/state/counters/in-octets"
  )

For reference:

Tag values:

Hello @Guilherme_Ladvocat,
It looks like you wrote that as a field not as a tag. You’d want to filter this way:

from(bucket: "telemetry")
  |> range(start: v.timeRangeStart, stop:v.timeRangeStop)
  |> filter(fn: (r) =>
    r._measurement == "/interfaces/" and
    r._field == "/interfaces/interface/subinterfaces/subinterface/state/counters/in-octets"
  )
  |> filter(fn: (r) => r["_value"] == "et-0/1/1")

Didn’t work :frowning:

The only way I see data is when I remove the interface filter.

“/interfaces/interface/@name” is a tag:

I don’t know if this is a bug related to special chars in the tag name…

@Guilherme_Ladvocat,
Can you please share the output of:

import "influxdata/influxdb/schema"

schema.tagValues(bucket: "example-bucket", tag: "/interfaces/interface/@name")

Thank you!

Hi @Anaisdg.

I renamed the problematic tag to a value without special character and it worked fine.
So I think the problem was the “@” in the tag value.

Thank you anyway!

Hi @Guilherme_Ladvocat,

I found this thread because I’m facing the exact same problem. Could you please share how did you solve this problem?

Did you perform the rename operation within Telegraf, before data is written to the database?

Thanks!

Hi @makurek .

Yes, I did a config in the telegraf.conf to rename the tag with special char to a new one.

[[processors.rename]]
[[processors.rename.replace]]
tag = “/interfaces/interface/@name
dest = “intname”

Thank you! I have done similar thing but using starlark :slight_smile: