If you enable the Legend on a specific Graph then the chosen “measurement” will be displayed per default. (Graph -> Legend -> Options -> Show)
But how I can change this, not to show the name of the measurement, instead to show the specific tag value, that is part of each SQL Metric ?
Example:
Metric A : SELECT “value” FROM “4weeks”.“BASIC_STATS” WHERE “cluster” = 'Cluster-1’
Metric B : SELECT “value” FROM “4weeks”.“BASIC_STATS” WHERE “cluster” = ‘Cluster-2’
Now I want to show as a Legend Cluster-1 Cluster-2
Use a GROUP BY and the ALIAS BY field. The alias by field uses the following convention: $tag_yourtagname. In your case, you want to group by cluster (then you only need one query rather than two) and then $tag_cluster in the ALIAS BY field.
Can this be extended so that the “tagname” in “$tag_tagname” is a template variable?
For example, I have a template variable $GroupBy, which is set up as Custom with the possible values Application and ClientLabel (each of which correspond to tags in the data). I’m able to use $GroupBy in the panel title, as well as the GROUP BY clause. Ideally I’d like to also use it in ALIAS BY, something like
$tag_$GroupBy
so the legend will show the value of either the Application or ClientLabel tag, depending on which is selected. As is, this doesn’t work. Is there a way to do this?
But that shows the value of GroupBy, not the value of $GroupBy tag. For example, if GroupBy = Application, I’d like the legend to show Rcv1 (the value of the Application tag), not Application.
OK, I got it working. Using the non-edit mode, the query ends up being
SELECT non_negative_derivative(sum("messages_sent"), 1s) FROM "metric" WHERE "Type" = 'application' AND $timeFilter GROUP BY time($__interval), "/^$GroupBy$/" fill(null)
and with an ALIAS BY $tag_$GroupBy, I get “undefined” for each label.
However, if I switch into edit mode and use
SELECT non_negative_derivative(sum("messages_sent"), 1s) FROM "metric" WHERE "Type" = 'application' AND $timeFilter GROUP BY time($__interval), $GroupBy fill(null)
(manually changing "/^$GroupBy$/" to $GroupBy), then the labels appear correctly (e.g., the actual value of the $GroupBy tag for each series is shown).
I can set the GROUP BY field() value manually (using the construction interface) to $GroupBy (instead of /^$GroupBy$/) and it seems to stick.
Perhaps a little quirky, or I don’t fully grok something quite yet.
Hello daniellee , I am using grafana url in react-native android mobile app , it is showing all details with graph but i am not able to select portion of graph on device,how i can achieve this ?