Filter out zeros before applying an increase

7 views
Skip to first unread message

Tim Harrison

unread,
Jun 12, 2020, 4:30:04 PM6/12/20
to Prometheus Users
I have a "bad" counter that I'm trying to apply an increase to.  That counter occasionally does not appear on the exporter page for various reasons and so prometheus records it as a 0.  Due to this, the data appears to go 1000,0,2000,2500,0,3000,3500 and so on.  When I apply an increase, i get these huge spikes because every time a zero occurs, it thinks the increase is from 0 to 3000 rather than from 2500 to 3000.  I need to figure out if there's a way to filter out the zeros (or make them equal to the last non-zero value) before applying the increase function.  Thanks.

Julien Pivotto

unread,
Jun 13, 2020, 1:12:24 AM6/13/20
to Tim Harrison, Prometheus Users
rate((counter > 0)[20m:])

Subqueries can help but you will stumble upon many other issues with this. Please try to fix the exporter.

Le ven. 12 juin 2020 à 22:30, Tim Harrison <cav...@gmail.com> a écrit :
I have a "bad" counter that I'm trying to apply an increase to.  That counter occasionally does not appear on the exporter page for various reasons and so prometheus records it as a 0.  Due to this, the data appears to go 1000,0,2000,2500,0,3000,3500 and so on.  When I apply an increase, i get these huge spikes because every time a zero occurs, it thinks the increase is from 0 to 3000 rather than from 2500 to 3000.  I need to figure out if there's a way to filter out the zeros (or make them equal to the last non-zero value) before applying the increase function.  Thanks.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/1ef232e1-390e-482a-be71-9cf94f628500o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages