prometheusgrafana

Sum over time of 1d, limit to last 7d, counter as a value


Let's suppose I have metric purchases_total. It's a counter ( which constantly increases ). I would like to make a table in Grafana which:

I try to make this query, but it returns nonsense:

sum_over_time(sum(increase(purchases_total{deviceType='ios'}[2m])/2)[7d:1d])

P.S 2m it's a scraping interval. Also, I put a "Min step" of 1d into a query configuration ( between the legend input field and resolution input field ) to limit a table view ( in Grafana ).

Any advice will be highly appreciated! Thanks


Solution

  • Your question isn't 100% clear, but I think you are looking for sum(increase(purchases_total{deviceType='ios'}[1d])) and then use a 1d step to the query_range API with start/end covering 7 days.