Rename legend (currently 'unknown')

Hi,

I’m new to Grafana, and I really love it!
How can I change the description in the legend? In every graph I make (based on Mysql data) it says ‘Unknown’ next to the colored line.

Can you please give me a hint? :wink:

Thanks!

Hi,

Please refer to Using MySQL in Grafana documentation.

Must be a column named metric representing the time series name.

So if you have a mysql query you need to provide a column named metric, e.g.

SELECT
  $__timeGroup(time_date_time,'5m') as time_sec,
  min(value_double) as value,
  metric_name as metric
FROM test_data
WHERE $__timeFilter(time_date_time)
GROUP BY 1, metric_name
ORDER BY 1

Where the value of metric_name above will be used as metric column name and the value will be the legend/series name.

If you don’t have any column to use for the metric name you could do like this as well:

SELECT
  $__timeGroup(time_date_time,'5m') as time_sec,
  value_double as value,
  'my label value' as metric
FROM test_data
WHERE $__timeFilter(time_date_time)
GROUP BY 1
ORDER BY 1

And the the label/series name will be rendered as my label in the graph.

Marcus

1 Like

Works like a charm! Thank you very much! (I used the second option)