Show InfluxDB record field as the key in the legend

I’m pushing to InfluxDB records that look like this

{
    "value": 20.0,
    "name": "Thermometer 0"
}

To a table called temperature.

The tag field is not used anymore.

I’m trying to have a Time Series that shows the temperatures grouped by the name key.

I tried by grouping by the name field and then aliasing to $tag_name but doesn’t appear to be working.

I tried with a bunch of posts of how to do this but I could not find a solution.

Posts I tried to follow to no avail:

(There where other 3 but I cannot post them, since there’s a limit of 2 links per post)

How can I do this?

Hi @quiquelluc

Can you share a sample dataset (5 to 10 records) including the time? The record below does not include time.

{
    "value": 20.0,
    "name": "Thermometer 0"
}

Yeah, sorry for the delay. The JSON was just a representation of the data. I’m using the rust influxdb crate.

The code I’m using to push the data looks like this, although I’m not sure how useful this is.

let query = WriteQuery::new(Timestamp::Milliseconds(Utc::now().timestamp_millis(), "temperature")
    .add_field("name", name)
    .add_field("value", temperature);

As you can see in the images, when querying the two different fields Grafana shows them in different tables, which I can switch between in the dropdown at the center of the screen.

I don’t know what’s up with the name, or why there is a json with an empty tag field. That as far as I know has nothing to do with my code.

please post your data as csv or line protocol, not as images.

do you only have fields name and value and no tags in your measurement of temperature?

do you only have fields name and value and no tags in your measurement of temperature?

Yeah so apparently I suck at influxdb. I did not know that I was supposed to use tag for the thermometer name. Using a tag for the name allowed me to use the $tag_name syntax in Grafana and it worked perfectly fine. Thanks.

1 Like