Skip to content

Commit

Permalink
prometheus: Document new behavior of unavailable or unknown entities
Browse files Browse the repository at this point in the history
  • Loading branch information
agoode committed Sep 28, 2024
1 parent b93ea91 commit f29823c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions source/_integrations/prometheus.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,25 @@ 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.
When the Prometheus exporter starts (typically when Home Assistant starts), all non-excluded entities in an unavailable or unknown state are not exported until they are available and known.

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/).
If an available entity goes into state unavailable or unknown, then metrics will automatically be unexported and return again automatically when available and known.

For example:
{% note %}
Prior to Home Assistant 2024.11, this component would continue to export the latest known value when an entity became unavailable or unknown, and set its corresponding `entity_available` metric to 0.

To filter out these stale values, `entity_available` could be used in a query or recording rule. For example:

```yaml
- record: "known_temperature_c"
expr: "temperature_c unless entity_available == 0"
```

This is no longer necessary, since all such metrics are now unexported.

For compatibility with previously written queries, all `entity_available` metrics now have the value 1.
{% endnote %}

## Supported metrics

Metrics are exported only for the following domains:
Expand Down

0 comments on commit f29823c

Please sign in to comment.