Prometheus metrics
The app can serve its device and network data for Prometheus to collect, for graphs in Grafana or similar tools. It's off until you set it up.
Turning it on
- On the app's Configuration tab, set
metrics_tokento a long random string, 16 characters or more. - On the same tab, under Network, give port
9099/tcpa host port, for example9099. - Restart the app.
The endpoint stays off while metrics_token is empty or shorter than 16 characters, or the port isn't mapped. The app's log says so when the token is too short.
With the Docker image, set metrics_token in /data/options.json, publish the port in your compose file ("9099:9099" under ports), and restart the container.
Scrape config
Add a scrape job to Prometheus:
scrape_configs:
- job_name: z2m_tracker
authorization:
credentials: <your metrics_token>
static_configs:
- targets: ["homeassistant.local:9099"]
Use your Home Assistant host's name or address (or the Docker host's), and the host port you mapped.
Every request must send the token, or it gets 401. The endpoint serves only /metrics and changes nothing. The data includes device names and areas, so keep the token private.
What it serves
Each active device has these gauges, with ieee, name and network labels. network is the base topic for a Zigbee2MQTT network, zha for ZHA and matter for Matter.
| Metric | What it is |
|---|---|
z2m_tracker_device_online | 1 online, 0 offline. Missing when availability isn't tracked for the device. |
z2m_tracker_device_linkquality | Last reported link quality (0–255). |
z2m_tracker_device_linkquality_24h | Average link quality over the last 24 hours. |
z2m_tracker_device_battery_percent | Last reported battery level. |
z2m_tracker_device_battery_days_left | Estimated days until the battery runs low. See Batteries. |
z2m_tracker_device_last_seen_timestamp_seconds | When the device last sent anything (Unix time). |
z2m_tracker_device_messages_24h | Messages received in the last 24 hours. |
z2m_tracker_device_uptime_30d_percent | Share of the last 30 days the device was online. |
z2m_tracker_device_issues | Open health issues for the device. |
z2m_tracker_device_info | Always 1. Adds type, power_source, vendor, model and area labels. |
A gauge with no value, such as battery on a mains device, is left out.
And these totals:
| Metric | What it is |
|---|---|
z2m_tracker_network_devices | Devices per network and status. The coordinator isn't counted. |
z2m_tracker_network_online | 1 when that network is online, 0 when it's offline. |
z2m_tracker_network_mesh_score | The network's mesh score, 0–100, as shown on Health. |
z2m_tracker_issues | Open health issues per check and severity, with check and severity labels. |
z2m_tracker_alerts_paused | 1 while alerts are paused. |
z2m_tracker_info | Always 1, with the app version as a label. |
Devices of a network the app no longer listens to are frozen and left out of every metric, including the device counts. See ZHA and Matter.