Use 'query name' as 'Display name' to label series in graph

I have a Time series graph, and in the legend, all of its lines are labelled as ‘Count’.
I’d like to use the query name which I specified in the input that says ‘Edit query name’ (‘foo’ in this screenshot’) as the labels in the legend.

I see that there’s a field called ‘Display name’ under ‘Standard options’. How can I use the query name?

welcome to the :grafana: forum, @markhand

try using one of these data links, like ${}:

Thanks, Matt. So far, that doesn’t appear to be having an effect for me. I’ve entered it thus and unfocused the Display-name field, but my legend still says ‘Count’. (If I enter an ordinary, static string and unfocus the Display-name field, then the static string shows up in the legend.)

  • I’ve tried hitting ‘Apply’, but that makes no difference.
  • If I use ${__series} instead of ${}, the legend reads ‘[object Object]’.

Do you have any idea what I might be missing?

I’m on Grafana v8.2.7 (d2cccfe91)

do you have more than one query? Have you tried adding an alias in the query editor?

Thanks, Matt. Yes, I have multiple queries (one line for each). Looks like adding an alias was the answer.

1 Like