'Grafana Loki LogQL bar gauge order by total

I am using Grafana and Loki to analyze logs from my application, and have used the Bar Gauge in a few places already.

This is my query:

sum(count_over_time({namespace=~"$namespace", job=~"$namespace-logs"} 
|= "KPIExecuted" [$__interval])) by (namespace)

And I get:

enter image description here

I was wondering whether I can sort the results based on the metric result? Or if there is an alternative I could use to achieve a similar outcome?

Thanks.



Solution 1:[1]

You can use a Sort Transform to do this.

Next to the Query Tab is a Transform Tab. Click that and choose Sort By. You will most likely sort by Value #A

Documentation is here https://grafana.com/docs/grafana/latest/panels/transformations/types-options/#sort-by

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TXMikeD