Count Over A Time Series

653 views
Skip to first unread message

Emmanuel Yong

unread,
Sep 5, 2017, 12:20:45 AM9/5/17
to Prometheus Users
Dear All,

Currently trying to count number of blackbox probe_success = 0 over a period of 1 minute but seeing data inaccuracy. Using the below inside Prometheus rules

probe_success_nonzero = probe_success == 1
probe_success_zero = probe_success == 0

If i use count_over_time(probe_success}[1m]) i can see total of probe success in 1 minute but it does not show me how many is 1 or how many is 0

how should i go about achieving this

Thank You,
Emmanuel

Ben Kochie

unread,
Sep 5, 2017, 1:19:58 AM9/5/17
to Emmanuel Yong, Prometheus Users
The total number of 1s:

sum_over_time(probe_success[1m])

The total number of 0s:

count_over_time(probe_success[1m]) - sum_over_time(probe_success[1m])


--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/d4e7b6e1-43de-4b01-aa1b-f54c15c7a207%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Emmanuel Yong

unread,
Sep 5, 2017, 5:52:53 AM9/5/17
to Prometheus Users, yongem...@gmail.com
Hi Ben,

What i am trying to achieve is, in 1 minute how many probe_success = 1 and probe_success = 0

Can the below fulfill my requirements?

Thank You

On Tuesday, September 5, 2017 at 1:19:58 PM UTC+8, Ben Kochie wrote:
The total number of 1s:

sum_over_time(probe_success[1m])

The total number of 0s:

count_over_time(probe_success[1m]) - sum_over_time(probe_success[1m])

On Tue, Sep 5, 2017 at 6:20 AM, Emmanuel Yong <yongem...@gmail.com> wrote:
Dear All,

Currently trying to count number of blackbox probe_success = 0 over a period of 1 minute but seeing data inaccuracy. Using the below inside Prometheus rules

probe_success_nonzero = probe_success == 1
probe_success_zero = probe_success == 0

If i use count_over_time(probe_success}[1m]) i can see total of probe success in 1 minute but it does not show me how many is 1 or how many is 0

how should i go about achieving this

Thank You,
Emmanuel

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.

Emmanuel Yong

unread,
Sep 5, 2017, 6:31:30 AM9/5/17
to Prometheus Users, yongem...@gmail.com
Dear Ben,

Much Appreciated

Emmanuel Yong

unread,
Sep 5, 2017, 6:44:38 AM9/5/17
to Prometheus Users, yongem...@gmail.com
Just For Sharing

Query

count_over_time(probe_success[1m]) - sum_over_time(probe_success[1m])

Result

Query
sum_over_time(probe_success[1m])

Result

Ben Kochie

unread,
Sep 5, 2017, 7:04:32 AM9/5/17
to Emmanuel Yong, Prometheus Users
What I use for grafana is this query:

avg_over_time(probe_success[$__interval])

Then I set the y axis to percent 0.0 - 1.0

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/e7e0d9d3-4255-4224-a149-5cc94ea08f20%40googlegroups.com.

Emmanuel Yong

unread,
Sep 5, 2017, 9:02:01 AM9/5/17
to Ben Kochie, Prometheus Users
Hi Ben

Can explain why put y axis?

Or what does the query do?

Thank You

On Tue, 5 Sep 2017, 19:04 Ben Kochie <sup...@gmail.com> wrote:
What I use for grafana is this query:

avg_over_time(probe_success[$__interval])

Then I set the y axis to percent 0.0 - 1.0

On Sep 5, 2017 12:44, "Emmanuel Yong" <yongem...@gmail.com> wrote:
Just For Sharing

Query
count_over_time(probe_success[1m]) - sum_over_time(probe_success[1m])

Result

Query
sum_over_time(probe_success[1m])

Result

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.

Ben Kochie

unread,
Sep 5, 2017, 11:50:57 AM9/5/17
to Emmanuel Yong, Prometheus Users
The query will produce the "uptime" of your blackbox probes as a percent.  The value will be 0.0 to 1.0, so you need to change the display unit to "Percent"

See "Unit" here:

On Tue, Sep 5, 2017 at 3:01 PM, Emmanuel Yong <yongem...@gmail.com> wrote:
Hi Ben

Can explain why put y axis?

Or what does the query do?

Thank You


On Tue, 5 Sep 2017, 19:04 Ben Kochie <sup...@gmail.com> wrote:
What I use for grafana is this query:

avg_over_time(probe_success[$__interval])

Then I set the y axis to percent 0.0 - 1.0

On Sep 5, 2017 12:44, "Emmanuel Yong" <yongem...@gmail.com> wrote:
Just For Sharing

Query
count_over_time(probe_success[1m]) - sum_over_time(probe_success[1m])

Result

Query
sum_over_time(probe_success[1m])

Result

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.

Emmanuel Yong

unread,
Sep 5, 2017, 6:02:07 PM9/5/17
to Ben Kochie, Prometheus Users

Thank you Ben for sharing, the above queries helped in achieving packet loss calculation


Thank You


To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.

Maopuppets

unread,
Aug 27, 2021, 6:48:48 PM8/27/21
to Prometheus Users
How did you achieve packet loss?
Reply all
Reply to author
Forward
0 new messages