1
votes

Grafana is using InfluxDB as its data source. Each series in influx has two measurements: the true measurement ("temperature"), and a city name "denver". For each series, the city name never changes, but the series names themselves are geographic coordinates.

I am able to plot the temperature for each city over time, on grafana. I'd also like to use the city name somewhere, for example the legend, or a table under the graph. I don't want to use the city name exclusively - I still want the coordinates to be the main thing shown in the legend.

How can I access this other measurement and show it either in a table under the graph, or in the graph alongside the current legend? Would it be easier to store the city name elsewhere for referencing?

1
You can use a "singlestat" to display the cityname next to your graph.IIIIIIIIIIIIIIIIIIIIII

1 Answers

1
votes

Joining two measurements in InfluxDB is generally an anti-pattern. In this case, the city name should be stored as a tag in the temperature measurement. Your points would then look something like this (in InfluxDB line protocol):

temperature,city=denver,lat=1.0,long=2.0 value=32.0 1469923200000000000
temperature,city=chicago,lat=3.0,long=-2.0 value=46.0 1469923200000000000

Queries grouped by the series name can now be easily constructed in Grafana, which will show the series name (including city name) in the legend.

Note: If the sensors always have the same city name, then adding the city name as a tag will not increase cardinality. This assumes all the older series with the city in the measurement name are removed and rewritten with the new city tag.