How do I reference a query name as a variable for the display name?

Grafana V9.3.2
MacOS Ventura

  • My data source prevents writing KQL/SQL to directly name the queries. This leads to a default where the query labels to have a ‘multifabric-AB-total’ format.

I am able to override each query individually using field overrides to rename to just ‘AB’, ‘CD’, etc. but it would be ideal if I could reference the ‘query name’, which I can edit for each query, in the display name override under standard options.

When I try {$__series.name} i get {[object Object].name} for all of my query labels. {$__query.name} just returns {$__query.name} as a static name for all query labels.
I’ve tried referencing this document but am not finding any success. Has anyone found a way to do this? It feels like something that should have a standard reference.

Also interested! Did you manage to use the query name as a variable for your query?

Are you asking about chaining queries so that you can $query1 in $query2

No, altough that would be cool too.

My main case is that I hava multiple timestream query such as:
Query 1

SELECT 
  time,
  measure_value::double as $__measure_1
FROM $__database.$machine
WHERE $__timeFilter
  andmeasure_group = 'group_1'  
  and measure_name = '$__measure'

Query 2

SELECT 
  time,
  measure_value::double as $__measure_2
FROM $__database.$machine
WHERE $__timeFilter
  and measure_group = 'group_2'  
  and measure_name = '$__measure'

Now I manually edit group $__measure_X and group_X. If I could get the name of the query, i.e. the number, i would only need to change it in the query name.