Grafana: Sort order of legends

Created on 1 Sep 2015  ·  5Comments  ·  Source: grafana/grafana

Hi Torkel

I am not sure if I am missing an obvious setting, but I googled around and couldn't find a conclusive answer.

I am using grafana-2.1.0-1.x86_64 and InfluxDB 0.9.3

On all my panels, I am struggling to order the legends in a consistent way. Every time I (re)load the page, the legends appear in a different order. Eg:
image

It would be ideal if I could specify somehow to order by [ none | alphabetically asc | alphabetically desc ]

I think the ideal place to put this would be Edit Panel -> Axis & Grid -> Legend -> Sort Order

However, optionally I would also like to override the sort order. For example, in the image above, I would like to have the order as:
total
dead
disk-sleep
idle
locked
running
sleeping
waiting
zombie

So you can see the order is sorted alphabetically, but I promoted the "total" legend to be first.
For me, it would make sense the add this option to Display Styles -> Series specific option:
image

Something like "sort order override". Then I can put "total" as 1st, and the rest of the series are ordered alphabetically asc or desc.

Hope this makes sense!
Thanks again!

typquestion

Most helpful comment

there is no metric name header to click to sort on, seems like a no-brainer of a choice to do it

All 5 comments

you can specify sort order by clicking on the legend column headers.

Also I would heavily advice against showing avg, min, max on the same legend as these will in many cases be incorrect. For example say your query is select mean(value) ...

That is InfluxDB is going to apply average to get the number of values down to one value per pixel. The legend values are calculated by Grafana client side, so if your query has the mean function then you can show avg in the legend, if you have max then the max legend value will be accurate.

But they cannot be accurate at the same time.

there is no metric name header to click to sort on, seems like a no-brainer of a choice to do it

@torkelo maybe I'm missing something but I think this should be reopened - if the legend only contains the metric names, there is no column header that can be clicked to sort them...

By editing the json for a panel directly I can add "sort": "current", "sortDesc": false under legend, which sorts both my legend and the stack order of series in my chart. There really needs to be an independent way to sort the stack order and the legend order.

I want to be able to define the stack order based on values (e.g. largest on top) but sort the legend consistently between charts (e.g. sort aliases alphabetically).

Can this be re-opened? Doesn't seem to be fixed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

german-bortoli picture german-bortoli  ·  95Comments

darox picture darox  ·  105Comments

torkelo picture torkelo  ·  168Comments

gsaray101 picture gsaray101  ·  122Comments

costimuraru picture costimuraru  ·  162Comments