Skip to content

feat: add Prometheus metrics exporter endpoint (GET /metrics) - #34

Closed
bolausson wants to merge 2 commits into
21cncstudio:mainfrom
bolausson:main
Closed

bolausson wants to merge 2 commits into
21cncstudio:mainfrom
bolausson:main

Conversation

@bolausson

Copy link
Copy Markdown

Summary

  • This is implemented with the help of an LLM!
  • Since I don't have the necessary hardware yet, I haven't been able to test the metrics for plausibility
  • Add GET /metrics endpoint exporting ~60 metrics in Prometheus text exposition format
  • Covers all sensor readings, derived values (dew point, absolute humidity, mold risk), DAC/fan control state, network status, and ESP32 system diagnostics (heap, PSRAM, chip temperature, flash sizes, FreeRTOS task count)
  • Invalid/unavailable sensors are omitted rather than zeroed, which is the correct Prometheus semantic for absent data
  • Uses chunked HTTP transfer to keep peak memory usage at ~1.5 KB
  • Flash/sketch size metrics are cached at init to avoid repeated SPI flash reads on every scrape

Files Changed

  • New: src/web/PrometheusExporter.h, src/web/PrometheusExporter.cpp — exporter implementation
  • New: test/test_prometheus_exporter/test_prometheus_exporter.cpp — 10 native unit tests
  • New: docs/prometheus/README.md — full metric reference, scrape config examples, PromQL queries
  • Modified: src/modules/NetworkManager.cpp — route registration and init
  • Modified: platformio.ini — added exporter to native test build filter
  • Modified: README.md — added Prometheus section with quick-start config

Testing

  • Firmware compiles cleanly with zero warnings (pio run -e project_aura)
  • All 35 native unit tests pass (pio test -e native_test), including 10 new tests covering sensor metric serialization, invalid sensor omission, derived metric computation, pressure trend output, and Prometheus format correctness (HELP/TYPE/value ordering)
  • On-device testing was not performed as hardware is not yet available. The endpoint follows the exact same data access patterns as the existing /api/state handler and should be validated with curl http://aura.local/metrics and promtool check metrics once hardware is available

Checklist

  • I have read CONTRIBUTING.md and agree to the CLA.
  • I tested my changes or explained why tests are not applicable.
  • I updated documentation if needed.

Export ~60 metrics in Prometheus text exposition format including all
sensor readings, derived values, DAC/fan state, network status, and
ESP32 system diagnostics (heap, PSRAM, chip temperature, flash sizes,
FreeRTOS task count). Invalid sensors are omitted rather than zeroed.
Flash metrics are cached at init to avoid repeated SPI reads.
@21cncstudio

Copy link
Copy Markdown
Owner

Thanks a lot for the contribution and for the detailed implementation.
The Prometheus /metrics work looks solid and is very much appreciated.

For now, I’m focusing on core firmware stability and release scope, so this is a bit early for the current roadmap. I’d like to revisit this in a future phase when we expand observability features.

I reviewed the changes locally and the idea is great. It’s just a timing/prioritization decision for this release cycle.

Thanks again for the effort and for putting this together.

@bolausson

Copy link
Copy Markdown
Author

That is fine.

@21cncstudio 21cncstudio added the enhancement New feature or request label Mar 3, 2026

Copy link
Copy Markdown
Owner

Project Aura now requires an explicit, recorded CLA signature before external contributions can be merged. I am going to close and immediately reopen this PR once so GitHub attaches the new CLA agreement check. Please follow the automated prompt and post the exact signature comment it requests. The old checklist checkbox alone is not used as the new signature record.

@21cncstudio 21cncstudio reopened this Jul 16, 2026
@github-actions

github-actions Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Thank you for contributing to Project Aura. Before this pull request can be merged,
every contributor must read the
Project Aura CLA
and post the exact signature statement shown below.


I have read and agree to the Project Aura Individual Contributor License Agreement v2.0, and I hereby sign it.


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Copy link
Copy Markdown
Owner

The first automated prompt rendered its document variable literally. The workflow is fixed now. Please read the actual Project Aura CLA, then post this exact comment in a new reply:

I have read the CLA Document and I hereby sign the CLA

Copy link
Copy Markdown
Owner

Project Aura has adopted Individual CLA v2.0. The earlier checklist acceptance and v1 prompt do not count as a v2 signature. After the automated CLA comment appears, please read the current CLA and post its exact v2 signature statement. This administrative refresh does not change the technical review of this PR.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants