How to show series name in Time Series chart legend

  • What Grafana version and what operating system are you using?

    • grafana version 12.1.0
    • OS: Raspberry Pi OS lite Bookworm
  • What are you trying to achieve?

    • Create a dashboard to monitor my lan performance metrics
  • How are you trying to achieve it?

    • Python script populates influxdb. Grafana for visualization
    • I have created a dashboard and a visualization panel in that dashboard. The panel has a query to fetch the data from the db. The data is fetched correctly.
    • I have also, based on instructions online, created a dashboard “variable”.
  • What happened?

    • Data is accessible. I’m attempting to create a Time series chart for ping measurement to various servers. The DB contains “tags” for each server
    • If I don’t use any template variable, the legend displays the full content of the db value (f.e.: ping_monitor.latency_avg { target: amazon_com })
    • If I use the dashboard variable, it shows a dropdown on the top-left above the chart where I can select one or more series. If I use the variable in the “Alias by Name” field, all the legend options show the value selected in the drop-down.
  • What did you expect to happen?

    • The different “tag” series are shown as their own time-series lines in the chart.
    • The legend displays the tag name correctly
  • Can you copy/paste the configuration(s) that you are having problems with?

    • N/A
  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    ** N/A

  • Did you follow any online instructions? If so, what is the URL?

Screenshots:

Hi, did you try setting Display Name (a setting on the right panel, closer to the bottom end of the settings) to ${__series.name}? That should work. You can also check other stuff you can write there in Data Links section, just type $ sign in the link section and there will be a popup with all the fields you can use, but the one I said I think would work for you

Hello,
Thank you for the tip. I tried this but it did not work for me. The legend is still showing in the form “ping_monitor.jitter { target: quad9_dns }”

I didn’t quite get it about the data links section. When I go to that section, click on add link, it asks me for a title and a link. Trying to type $ in the Title field doesn’t show any popup.

Ok, I’m also not very fluent in InfluxDB, but wouldn’t your query need something like WHERE target = $target? And not using alias as the variable? In PromQL you would need to pass the variable to the query, not to the legend.

But wouldn’t that only show the graph for the selected value of the variable (for example amazon_com as in the screenshot). What I want to do is display the latency for all the “targets” in a single graph

I still think using it in Alias field is what causing all the legends to be called that. Can you delete it and see what happens? Then can you share a screenshot of table view toggled (right beside the time picker)?

It shows the full “tag”
Removed the $target from the alias field and this is how it appears:

Do I understand correctly that you want to see the name of the “target” in the legend, not the metric name? So you’d like to have your legend be of labels “amazon_com”, “cloudflare_dns_primary” etc? If so, try typing $tag_target in the Alias by input.