We have a bunch of sensors (e.g. 25-30 ESPs running Tasmota) sending different measurements to MQTT - Influx - Grafana; works real nice. In the legend in the moment the ID of the devices is displayed:
My end users would like to see a more human readable description like “machine x/hall y” instead of “DF6B09”. Of course I could to the lookup on the import side but that would store a lot of redundant text for millions of measurements and arises problems if one of the descriptions will change (which for sure will be happen…).
I tried to add a mysql table with the mappings to Grafana (works), to define a variable (works; let’s me choose between “all devices” and a selection of devices using the human readable description) but I have no idea how to replace the IDs in the legend with the lookup.
Thank you Grant, works like a charme. Next step: it would be a real burden to do that manually in many dashboards/panels for dozens of sensors - particularly because I could to all the mappings automatically. So I dig “a little bit” into the Grafanas data structures and made a proof of concept Python-script which I could/would extend to automize the process of defining the overrides. If anybody is interested:
I have seen other questions on this forum asking for an “automated” way of renaming their series to more “human friendly” text. I will see if I can find them and link to your solution.
Hi @msedv it looks like you found a good solution! If you are still interested in dynamically mapping device IDs to device names stored in a SQL database or similar, that is also possible. I wrote a thread on it here: Using SQL data to label time series (via v7 transformations?). Although the last post in that thread is about me struggling to get it to work, it does actually work these days since the bug that I mentioned was fixed some time ago.
@all who stumble about this post: in the already mentioned Github-project GitHub - msedv/Grafana you can now find two tools:
showgrafana.py: formatted output of the Grafana-Dashboard-definitions (JSON) to ease analyzing it.
parsegrafana.py: changing the labels/ids based on a lookup-table stored in parsegrafana.csv (sample provided). Could maybe also useful for other tasks where the Grafana-configuration should be changed programmatically.
Grafana Overrides.md: a more detailed and illustrated description of the overrides-definition lined out by Grant.