From bd4da144858c063be8b3c6b9600d85fe76144e02 Mon Sep 17 00:00:00 2001 From: Antoine Meillet Date: Fri, 19 Mar 2021 21:41:28 +0100 Subject: [PATCH] Add details about unavailable and unknown states for Prometheus (#17039) Co-authored-by: Franck Nijhof --- source/_integrations/prometheus.markdown | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/_integrations/prometheus.markdown b/source/_integrations/prometheus.markdown index b7b7623abe2..3e541e0aa0b 100644 --- a/source/_integrations/prometheus.markdown +++ b/source/_integrations/prometheus.markdown @@ -179,3 +179,16 @@ When looking into the metrics on the Prometheus side, there will be: - The [client library](https://github.com/prometheus/client_python) provided metrics, which are a bunch of **process_\*** and also a single pseudo-metric **python_info** which contains (not as value but as labels) information about the Python version of the client, i.e., the Home Assistant Python interpreter. Typically, you will only be interested in the first set of metrics. + +## Metrics in unavailable or unknown states + +When the Prometheus exporter starts (typically when Home Assistant starts), all non-excluded entities in an unavailable or unknown state are not be exported until they are available again. If the entity goes into state unavailable or unknown again, the value exported will always be the latest known one. + +While an entity is in those states, the `entity_available` corresponding metric is set to 0. This metric can be used to filter out values while the entity is unavailable or in an unknown state thanks to a [recording rule](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/). + +For example: + +```yaml +- record: "known_temperature_c" + expr: "temperature_c unless entity_available == 0" +```