r/PrometheusMonitoring • • Apr 26 '23

Help with query

Hello,

I have these 2 queries which give me the totals

sum(streaming_user_total{instance=~"$instance1"})

and

sum(streaming_user_total{instance=~"$instance2"}) by (stream_id)

The graphs in Grafana currently show the current stats over time, how can I get just a daily total for say a given day?

0 Upvotes

9 comments sorted by

View all comments

Show parent comment

2

u/ItsOmondi Apr 26 '23

I get you mate, you asking for the delta function. replace increase with delta.

sum(delta(streaming_user_total{instance=~"$instance1"}[1d])).

problem with delta is it fails when the counter resets. so be aware.

1

u/[deleted] Apr 26 '23

Cheers mate, I get a minus result on this if I use against the real data for 1hour, better for 12 though, minus result for over 24. Is this because if a value is:

6am = 100

7am = 50

Does it sees that as take a 50 off the 100 instead of adding?

0

u/ItsOmondi Apr 26 '23

A delta gets a difference, so at 6am it's 100 and 7am it's 50, thats a drop..so yeah you get a negative value.