Use _field as a tag in query


I’m reading data from InfluxDB in Grafana, and I want to do alerts using multiple values.
My data has unique _field, but no unique tag. This is an issue in Grafana Alerts, and I would like to somehow set the _field as a tag as well (copy).

I tried this approach:

But I’m not looking to write this to a new bucket, but rather have my query return with the extra tag.

Any tips?

Hello @OdneOksavik,
You can use the duplicate function()

But I’m not sure that this will produce tags in Grafana. (I don’t think it will).
You might have to then group by the _field duplicated column.

But there isn’t a way to add a tag without writing data to the database with a tag.

Thank you.

I did some more research and found a post describing the same issue, and a solution:
By adding the following to the end of my Flux query

|> rename(columns: {_value: "something"})

we get unique tags, and the Grafana alert works as intended.

Hi @OdneOksavik

It appears you were able to solve your problem, but as @Anaisdg said, the only way to get a tag into InfluxDB is the write a tag. In your case, I believe the way Grafana parses the result from InfluxDB is that if a _value column is found, it is assumed to be a time-series. The workaround is to add the following:

|> rename(columns: {_value: "something"})