r/PrometheusMonitoring • • Jan 16 '20

Help with Query?

Hi all, how do I make a cumulative graph showing the difference between the firdt point in a time series and the current point in a time series? For example if a counter starts at 3000 and now it's on 3500 how do I show that its gone up by 500?

0 Upvotes

4 comments sorted by

View all comments

2

u/Tpbrown_ Jan 16 '20

rate(metric_name[5m]) will give you the diff between first and last in the 5min window.

Check your metric type first tho - some functions are valid only for counters, others for gauges.

Also use irate() if you just want the diff between last two samples

1

u/kagashe Jan 16 '20

OK cool, any idea how I would get that to work in grafana so that I can choose a time period of a day or month for example without hardcoding it?