Skip to content

feat(metrics): Prometheus-compatible /metrics endpoint#81

Open
iceice400 wants to merge 1 commit into
KMX415:mainfrom
iceice400:feat/prometheus-metrics
Open

feat(metrics): Prometheus-compatible /metrics endpoint#81
iceice400 wants to merge 1 commit into
KMX415:mainfrom
iceice400:feat/prometheus-metrics

Conversation

@iceice400
Copy link
Copy Markdown
Contributor

Summary

  • Adds optional GET /metrics in Prometheus text 0.0.4 format (zero-dependency writer)
  • Exposes packet counts, node totals, RSSI/SNR averages, noise floor, relay stats, per-channel duty (ToA), SX1302 CRC counters, and uptime from in-memory state
  • Disabled by default (metrics.enabled: false); optional metrics.require_auth for LAN scrapers

Why

Operators running Prometheus/Grafana on the LAN need a standard scrape target without polling multiple JSON API routes. Default-off keeps upgrade behaviour unchanged.

Type

  • Feature
  • Bug fix
  • Docs
  • Refactor
  • UI
  • Installer
  • Region support
  • Hardware change

Testing

  • python -m unittest tests.test_metrics_routes -v (6 tests, pass)
  • Tested on hardware with Prometheus scrape
  • Dashboard tested

Test plan

  1. Fresh install / upgrade with default config → GET /metrics returns 404
  2. Set metrics.enabled: true, require_auth: false → scrape returns text/plain with meshpoint_packets_session_total, meshpoint_noise_floor_dbm, etc.
  3. Confirm no PSK/token values appear in metric labels or sample values
  4. With require_auth: true, unauthenticated scrape returns 401
  5. Normal dashboard and packet pipeline unchanged

Relay / TX impact

None. Read-only exposition endpoint; no pipeline or relay changes.

Config

metrics:
  enabled: false
  require_auth: true

Documented in docs/CONFIGURATION.md with example prometheus.yml scrape job.

AI-assisted?

Implemented with AI assistance; unit tests run locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant