Change legend of time series graph

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

  • What are you trying to achieve?
    I’m trying to plot 3 different variables in one Times Series graph.

  • How are you trying to achieve it?
    I use following KQL code :

adt_history
| project temperature = todouble(Value), SourceTimeStamp, Id, Key
| where $__timeFilter(SourceTimeStamp)
| where Id == ‘MTR.CMP.06’
| where Key == ‘oven1.temperature’ or Key == ‘oven2.temperature’ or Key == ‘oven3.temperature’
| order by SourceTimeStamp asc

  • What happened?
    I get a correct times series graph, but my legend is not correctly named, see screenshot…

Have you tried using a field override, like this?

1 Like

This works, thanks!

Are there other ways also?

I still have to learn alot and all tips are welcome!

hello,

I made changes to my dashboard and that causes this solution not to work anymore :frowning:

I use a variable on my dashboard to select which oven I want to visualize : oven 1, oven 2 or oven 3

I use a key/value inside my variable : oven 1 : MTR.CMP.06, oven 2 : MTR.CMP.10, oven 3 : MTR.CMP.15

MTR.CMP.06 / 10 / 15 is then used in my KQL statement :

adt_history
| project temperature = todouble(Value), SourceTimeStamp, Id, Key
| where $__timeFilter(SourceTimeStamp)
| where Id == '$Lijst_ovens'
| where Key == 'oven1.temperature' or Key == 'oven2.temperature' or Key == 'oven3.temperature'
| order by SourceTimeStamp asc

Now my legend override doesn’t work anymore for oven 2 & 3 because the override is not correct anymore :frowning:

So I was thinking about using overrides with a name matching regex, but I don’t know how to do this. The manual is not really clear about this.
So how do I change the legend with “oven1.temperature” to “sectie 1” and “oven2.temperature” tot “sectie 2”, …

Hi @stevennoppe

I am no Regex ninja, but playing around on play.grafana.org, I think a simple Regex like /02/ might work:


1 Like