Set a metric with no data on porpouse

33 views
Skip to first unread message

Humberto Ramos Costa

unread,
May 22, 2020, 8:12:10 PM5/22/20
to Prometheus Users
I'm using the Prometheus python lib to create a exporter.
This exporter gets data from another apllication running on the same machine.
There are some situations where i can't get the data and i woul like to set the metrics (Gauge in this case) with nodata (like None in python).

Julius Volz

unread,
May 23, 2020, 4:20:33 AM5/23/20
to Humberto Ramos Costa, Prometheus Users
The normal case in the situation where an exporter cannot reach a backend is to just not return the backend metrics at all, but expose a <mybackend>_up metric by the exporter that is set to 1 if the backend is reachable and 0 if it's down. For example, "haproxy_up" in the HAProxy Exporter or "mysql_up" in the MySQLd Exporter. Then you can alert on that.

If you really would like to keep exposing the backend time series even if you cannot gather data for them, then you could set them to NaN ("float('nan')" in Python).

--
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/4fb450f2-52a6-4a51-9177-0cb48fe66020%40googlegroups.com.


--
Julius Volz
PromLabs - promlabs.com

Julien Pivotto

unread,
May 23, 2020, 5:18:16 AM5/23/20
to Julius Volz, Humberto Ramos Costa, Prometheus Users
On 23 May 10:20, Julius Volz wrote:
> The normal case in the situation where an exporter cannot reach a backend
> is to just not return the backend metrics at all, but expose a
> <mybackend>_up metric by the exporter that is set to 1 if the backend is
> reachable and 0 if it's down. For example, "haproxy_up" in the HAProxy
> Exporter or "mysql_up" in the MySQLd Exporter. Then you can alert on that.
>
> If you really would like to keep exposing the backend time series even if
> you cannot gather data for them, then you could set them to NaN
> ("float('nan')" in Python).


Note that you need to implement a collector to not expose the data ; not update a
gauge.

>
> On Sat, May 23, 2020 at 2:12 AM Humberto Ramos Costa <1ber...@gmail.com>
> wrote:
>
> > I'm using the Prometheus python lib to create a exporter.
> > This exporter gets data from another apllication running on the same
> > machine.
> > There are some situations where i can't get the data and i woul like to
> > set the metrics (Gauge in this case) with nodata (like None in python).
> >
> > --
> > 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/4fb450f2-52a6-4a51-9177-0cb48fe66020%40googlegroups.com
> > <https://groups.google.com/d/msgid/prometheus-users/4fb450f2-52a6-4a51-9177-0cb48fe66020%40googlegroups.com?utm_medium=email&utm_source=footer>
> > .
> >
>
>
> --
> Julius Volz
> PromLabs - promlabs.com
>
> --
> 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/CAObpH5wMmrdaJGWZRY7M3-rKLTKFAzUcsAFChAdC6ROjg3Ztjg%40mail.gmail.com.

--
Julien Pivotto
@roidelapluie
Reply all
Reply to author
Forward
0 new messages