I add the variable to the query in the following way:
This works as expected and it adds a entry to the graph for each selected value of the custom variable.
My problem is that the names of the entries in the graph aren’t very readable, these for example result in: base_devices.mean {name: 0_Meter}
I would like to change it such that the entries are named according to the keys set in the custom variable (eg Basecase and Basecase Heat), but I can’t figure out how to achieve this.
I tried setting the Alias field to ${variable:text} but this just results in “Basecase + Basecase Heat”. Is there a way to make the query select the matching value from the custom variable?
Thanks in advance! If you need any additional information, please let me know. I am using Grafana v8.5.13.
Thank you for the quick response. I have looked into that and it works fine. However I am looking for a way to automate the naming of the display names. Using the override, we still have to change the naming for each variable entry manually.
Yes, I manage to extract for example base_devices with the regex rename. Is it possible to use this value to get the corresponding key? Or if I switch the values and keys in the variable around, use “base_devices” as the key to get the corresponding value from variable?
To elaborate a bit more on this. I would like the display names to have to correct value automatically.
So either that I can insert the variable name (with some additional formatting if necessary) in the Alias field. Such that when the query generates multiple graphs from the multi-valued variable values, the corresponding text of the variable is used as the display name.
Or by renaming the display names using the text from variable. And then somehow get the correct text from a given value (which might be extracted from the display names using regex). So for the example, you could use “base_devices” to get “Basecase”.
If you’re using repeating visualisations based on the variable, you can use the ${variable_name:text} formatter as the Alias value to convert the raw variable value into it’s display name representation.
If you’re not using repeated visualisations then I do not believe there is currently a way to convert the multi-value into individual display names, apart from the more manual regex approach that @grant2 suggested.