Considering that profile generates some revenue over a period of time and being pushed to Prometheus as a Counter, I need to find the top 5 performing profiles based on revenue. I tried with
topk(5,sum({__name__="ow_wt_revenue",pub_id="159409",profile_id=~""}) by (profile_id))&start=1676016000&end=1676098800&step=1h
However, it is not returning consistent results. Is there any way to get topk record based on given time range in Prometheus?
Try sending the following query to /api/v1/query:
topk(5, sum(increase(ow_wt_revenue{pub_id="159409"}[1h]) by (profile_id)))
This query should return top5 profiles with the biggest revenue during the last hour (see 1h
in square brackets) ending at the timestamp specified via time
query arg passed to /api/v1/query
. It is assumed that the ow_wt_revenue
is a counter.