How can I alias labels using a query (like SQL)?

  • What Grafana version and what operating system are you using?
    Grafana v9.3.2.2 on Azure Grafana

  • What are you trying to achieve?
    I have a line chart with labels of an ID. I also have an SQL table in which the IDs are mapped to simple strings. I want to alias the IDs in the label to the strings from the SQL

  • How are you trying to achieve it?
    I am trying to look for a transformation for the same. I found something related, but i don’t think I can use this - Ask Us Anything: How to Alias Dashboard Variables in Grafana in SQL | Grafana Labs

There is a transformation called “rename by regex”, but that will require me to hardcode for each case. Is there something similar to “rename by query”

If the above approach doesn’t work, can I hardcode with some keyvalue parirs?


What is the other datasource for the line chart?

I’m using an internal data source

1 Like

This is my table after dropping the first column with time. Can I transpose the table into something like this, so then I can do an outer join with my SQL table on the column IDNAME?

Hi @wordpressshobhit

I tried to reproduce this by mocking up your given data as CSV format. After that, I use the transformation and was able to get the result in the same way you wanted.

I attached a screencast (open it in a new window as will be easier to zoom in and view more clearly)


I hope this helps.