Skip to content

Prometheus metrics ​

The speaker offers its metrics to Prometheus on the home network: the web server, the board and the speaker itself, each under its own address. Grafana, or anything else that reads Prometheus, can then chart them.

They are off until the owner turns them on under Settings → System → Offer metrics to Prometheus; off, all three answer 404.

The three addresses ​

AddressSourceWhat it contains
http://boombox.local/metricsCaddy / FrankenPHPRequests, response times and status codes, the PHP workers
http://boombox.local/metrics/systemnode_exporterCPU, memory, temperature, the microSD card, network, load
http://boombox.local/metrics/speakerthe agentWhat plays, Bluetooth, volume, playlists, recordings, Wi-Fi, display

All three use the Prometheus text format (text/plain; version=0.0.4). boombox.local is the speaker's network name; use yours if you renamed it.

Scraping ​

yaml
scrape_configs:
  - job_name: boombox-web
    metrics_path: /metrics
    static_configs: [{ targets: ['boombox.local'] }]
  - job_name: boombox-system
    metrics_path: /metrics/system
    static_configs: [{ targets: ['boombox.local'] }]
  - job_name: boombox-speaker
    metrics_path: /metrics/speaker
    static_configs: [{ targets: ['boombox.local'] }]

If Prometheus runs in Docker and cannot resolve .local names, use the speaker's IP address instead.

Several speakers: list each one under every job.

yaml
    static_configs: [{ targets: ['kitchen.local', 'garden.local', '192.168.1.40'] }]

Grafana dashboard ​

boombox-grafana-dashboard.json is a starter dashboard for any number of speakers. Download it, then in Grafana go to Dashboards → New → Import, upload the file, and pick your Prometheus data source at the top of the dashboard.

RowWhat it shows
OverviewSpeakers up, targets down, a table with one row per speaker (version, uptime, temperature, Wi-Fi, volume, what plays, phones, recording), and which targets answered over time
PlaybackWhat plays per speaker, the volume and its limit, connected phones, and a timeline of amplifier, mute, headphones and recording
HealthTemperature (lines at 70 and 80 °C), Wi-Fi signal (red below 30 %), uptime, recordings waiting
BoardCPU, memory, the microSD card, network, load
WebPHP requests by status, the 95th percentile response time, busy FrankenPHP workers

Speaker at the top picks one speaker, several or all. The dashboard expects the job names above: boombox-speaker for the table's Agent column, and names starting with boombox for Targets down and Reachable. Keep them, or adjust those three queries.

It was made and tried with Grafana 11. Wi-Fi shows no data for a speaker on Ethernet or on its setup network: it has no signal to report.

The speaker's metrics ​

All are gauges. A part the speaker does not have, or has not reported yet, leaves its metrics out.

MetricMeaning
boombox_up1: the agent answers
boombox_info{hostname,agent,kernel,bluez}Always 1; the labels name the speaker and its versions
boombox_uptime_secondsSeconds since the speaker started
boombox_temperature_celsiusThe system on a chip's temperature
boombox_volume_percentThe volume
boombox_volume_limit_percentThe volume limit that applies now (speakers or headphones)
boombox_muted1: muted
boombox_amplifier_on1: the amplifier is switched on
boombox_listen_on_headphones1: listening on headphones or line out, the speakers off
boombox_playing{source}1 per source that plays: bluetooth, playlist, stream
boombox_bluetooth_devices{state}Phones the speaker knows (paired) and those connected
boombox_bluetooth_pairing_open1: new phones can pair
boombox_playlistsPlaylists on the speaker
boombox_recording_enabled1: recording what phones play is on
boombox_recording_active1: a song is being recorded
boombox_recordings_pendingRecordings waiting to be stored
boombox_recording_error1: the last recording could not be stored
boombox_wifi_connected1: connected to a Wi-Fi network as a client (0 on the setup network)
boombox_wifi_signal_percentThe Wi-Fi signal
boombox_display_present1: the e-Paper display is set up
boombox_knob_present1: the knob is set up

Useful alerts: boombox_temperature_celsius > 80, boombox_recording_error == 1, boombox_wifi_signal_percent < 30, and up{job=~"boombox.*"} == 0 for a speaker that is gone.

Security ​

  • The addresses answer private, loopback and link-local addresses only (10/8, 172.16/12, 192.168/16, fc00::/7 and the like), but not the setup network (10.42.0.0/24), whose guests are anyone near the speaker with its label. Anyone else gets 403. There is no password, as usual for Prometheus targets.
  • Caddy's own metrics listener (127.0.0.1:9180) and node_exporter (127.0.0.1:9100) listen on the speaker itself only. The web app answers for them, so the rule above and the switch in Settings cover all three.
  • The metrics contain no song titles, phone names or network names: only numbers, the host name and versions.
AnswerMeaning
200The metrics
403The request did not come from a private address
404Metrics are off (the default): turn them on under Settings → System
503The agent, Caddy's listener or node_exporter does not answer

How it is built ​

PartWhere
The three addresses, the address check, the switchpackages/boombox-speaker/Classes/Middleware/MetricsMiddleware.php
The speaker's metricspackages/boombox-agent/src/Metrics/SpeakerMetrics.php, Service/MetricsService.php (op metrics.get, metrics.settings.set)
Caddy's metrics on 127.0.0.1:9180deploy/device/files/Caddyfile.device (global metrics option and a :9180 site)
node_exporter on 127.0.0.1:9100install.sh, step Metrics: the prometheus-node-exporter package and /etc/default/prometheus-node-exporter

Development ​

DDEV runs the same setup: Caddy's metrics via CADDY_GLOBAL_OPTIONS and CADDY_EXTRA_CONFIG in .ddev/docker-compose.frankenphp_extra.yaml, node_exporter as a web daemon in .ddev/config.yaml.

bash
curl -s https://boombox.ddev.site/metrics/speaker
ddev boombox-agent client metrics.settings.set '{"enabled":false}'

The Playwright spec metrics.spec.ts checks all three addresses and the switch.

Troubleshooting ​

SymptomCause and fix
403 from PrometheusPrometheus reaches the speaker through a public address, a VPN or a proxy that is not in a private range. Scrape from inside the LAN.
404Metrics are off: turn on Offer metrics to Prometheus under Settings → System.
503 on /metrics/systemnode_exporter is not running: systemctl status prometheus-node-exporter; run install.sh again to install it.
503 on /metricsThe Caddyfile lacks the metrics option or the :9180 site (an edited shared/Caddyfile). Compare it with Caddyfile.device.