You are not seeing two states simultaneously. You are seeing two
*timeseries:* one has value 0 and one has value 1.
foo{state="connected"} 0
foo{state="not connected"} 1
If the system became "connected" then they would change to
foo{state="connected"} 1
foo{state="not connected"} 0
Given that prometheus only stores numeric metrics, this is the standard way
of exposing an enumeration of states.
You could instead set the metric as a gauge value, in which case you'd have
to choose a numeric value to represent each state, for example
foo 0 # means not connected
foo 1 # means connected
If you do it that way, then you get a single timeseries. The front-end
application (e.g. grafana) can map those values to names and/or colours.
That also works.
On Friday, 11 February 2022 at 23:39:09 UTC [email protected] wrote:
> I have a measurement device that I can query over telnet with
> prometheus_client in python. I can report the value so Prometheus can see
> it, but when I try to report the status (connected/not connected) I somehow
> see both states at the same time?
>
> The python script is attached, and what I see in the Prometheus web
> console: https://imgur.com/a/ZFo8GnT
>
> Grafana also shows two solid lines for 0 and 1 for all times.
>
> What am I doing wrong with the prometheus_client.Enum?
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/906c5372-8bec-4b4a-af01-273f51489e6an%40googlegroups.com.