I am all new to grafana and flux. I’ve set up my homeassistant to log data into influxdb and have set up a few graphs. While it’s certainly more difficult to find examples for flux than for sql I’ve gotten most of my stuff set up and and I’m just going with the learning curve.
One thing I have so far failed to find anything about - probably due to a lack of knowledge about which terms to use - is the name of graphs. For instance, if I have 3 graphs on one chart for different temperatures in my rooms, the naming of the graphs is like temperature {domain="sensor", entity_id="livingroomsensor_temperature"}
I would really like this to be just Livingroom Temperature or whatever custom string I’d like to choose I am quite certain this is a very simple task but I struggle to find a simple answer.
Below is my query:
no i did not. I am also surprised that there was not a single reply. I’d actually think that this was a common task to do, also surprised how little activity there is in this forum …
Oh, no I have not. Unfortunately having no experience with neither grafana nor flux I find this documentation very uncomprehensible. How would I implement this in the above example? I’m sure once I see it it’s very obvious …
Hard to explain without creating a series of screenshots, but basically (assuming you’re on Grafana 7.x):
Open the panel editor and click on the “Overrides” tab on the right
Click the “Add an override for” button; select “Field with name”. In the drop-down select the current name of your field (as yielded by the query)
Click “Add an override property” and select “Display name”
Enter the name you would like to see
There is actually another (maybe preferable) way to do this inside the query itself - which also works for Grafana 6.x. See discussion here, which is basically a discussion of the issue you’re having. This approach involves adding a line like
Both ways work great! Thank you very much! A real pity the process to getting here was surprisingly counter intuitive. But makes me even happier I finally got this sorted
thank you!
Thanks for great explanation, but I cannot figure out how to deal with flux code and map function if we have more entities than 1. This is my example code, could you give some hint, thanks:
For the Overrides tab in Grafana, it is perfectly clear and working for me - one can add as much want fields to override their values with custom display name, but I would like to learn to do the same from your example in flux.
Thank you.
EDIT: Sorry for bump, I just noticed this post is 3 years old.
But I would like to learn to do this in flux language. To apply map function (sorry if this is not a function, first time installed InfluxDB yesterday ) as @svetb suggested above, but in case when I have multiple fields. @svetb example is working for case when we have one filed, but I cannot figure out the syntax and how to do this for multiple fields.
Thank you.
P.S. I am aware this question is more for some InfluxDB/flux forum or so, but since I saw it is already this topic here, i.e. Google search landed me here
So this may be possible to do via the map function in Flux, but I have never done it that way. Instead, when the legend labels look bad, I use Rename by Regex transformation in Grafana.
But in your case, I see you are using another language (vs the English language field names). Instead of using kitchen_temperature, etc. in your database, could you use kuhinja_temperatura?
I’m getting your point, didn’t know for this. These values are pulled from my Home Assistant, and I want to have it in English in my home, so unfortunately no go. On the other hand, dashboard is for some local showcase, so I named the fields in local (Serbian) language. Never mind, I will stick with Overrides in Grafana as for now, regex was also dark hole for me whole my life (but it would be worthy to play little bit and learn it). Thank you for your help, this dashboard is really for one time use, so all good.
EDIT: ChatGPT and me, after several queries, had success to generate a regex for this certain use case : ^value\s{domain="sensor",\sentity_id="(.*)(_humidity")}