Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
/graph needs a way to select the "top 5" or similar #586
I have a timeseries with about 40 or so values for a label. I want to show a graph of the top 5 of them. If I simply plot
then this picks the top five for each time in the graph, resulting in at most 5 non-zero lines per vertical slice of time, but there's still around 30 or so plots overall.
Instead, the selection of the "top five" needs to be done after the entire set of values is collected ready for display by the graph generator. It would have to be an argument to the graph generator itself.
Additionally, it would be really nice if the remaining buckets could be summed into an "everything else" plot, so that I could draw a stacked area graph showing the top 5 in the time period, and all the rest as one final area, so that the total is still representative.
@juliusv Yes I understand that and topk makes sense as it. Still, having something similar to topk which returns the timeseries with the highest average value over the queried range would be super useful. I think it's a common thing to have dashboards with the top n of some things and with topk you get basically just garbage if the metrics are spiky.
PS: This btw also happens if all timeseries are 0, in that case topk looks pretty random. Maybe we can improve that specific case easily? Guess we could look at the labels or something if the value is the same.
You could do things like
That would at each point display the top 5 metrics based on the average over the last 5m. That helps in some cases, but it's still not "fixed for exactly the displayed period, take the top5 metrics over that period". For that, we needed a way to select a fixed (not relative) time range in the expression language).
referenced this issue
Jul 20, 2016
Just wanted to mention some workarounds to achieve parts of what the OP wants that have gone unmentioned here:
In Prometheus, the Table view presents only the "current" topk which should only be the k you entered. You can use offset to explore temporally. This should never show more records than the given k.
If you are only wanting to see the history of the current topk, use the table view to grab the currents and then query not for the topk but for just those k records.
IOTW, let's say you had
Note also you could handle the "rest" in a similar way via negated regexp
Since it hasn't been mentioned, even though it is an additional component, Grafana can do this quite easily as well. It can even happen accidentally on Panel types that prefer to only show "one" value if the dashboard designer isn't careful to use Prometheus' averaging functions and Grafana's "Current" value instead.
To be clear I am not recommended re-opening this issue, just wanting to provide some other options for people.
In my case I have a metric called
If I make a query like
pushed a commit
Oct 12, 2017
This is possible in Grafana 5.3.0: https://www.robustperception.io/graph-top-n-time-series-in-grafana