Add Prometheus metrics exporter and API docs#1697
Conversation
|
Can you add a screenshot of the dashboard? |
|
will look over in the next week or so |
0xf0xx0
left a comment
There was a problem hiding this comment.
playin with the dashboard, we'll have to be sure the uid keys are removed so importing works as its using the uid of your prometheus
- remove duplicate mining_enabled metric (keep mining_paused) - emit fan2/chip_temp2 metrics only on supported hardware - broaden label sanitization for wifi/rejected-reason labels - remove hardcoded Grafana datasource uid for portable dashboard imports - update OpenAPI/README docs to match metric behavior
- export espminer_fan_rpm as fan=1|2 series based on detected hardware - export espminer_chip_temp_celsius as chip=1|2 series based on detected sensors - update dashboard queries to new labeled metric model - keep OpenAPI and README metric docs in sync
|
somethin in latest commits seems to have broken metrics for me |
- prometheus_format_label() is an internal helper that intentionally omits
the surrounding {} braces; it must not be called by metric emitters directly.
- The fan/chip labeled metric code introduced in 63b48c0 incorrectly used
prometheus_format_label() instead of prometheus_format_labels(), producing
malformed output: espminer_fan_rpmfan="1" 4032
- Switch all 4 call sites to prometheus_format_labels() (count=1) so output
is valid Prometheus text exposition: espminer_fan_rpm{fan="1"} 4032
- Extract the four prometheus formatting helpers into a standalone
components/prometheus_format/ component so they can be unit-tested
without bringing in the full HTTP-server context.
- Add Unity test suite covering: no-label, single-label, multi-label,
board-601 fan RPM, board-601 chip-temp, and a regression guard that
asserts the label string always starts with '{' and ends with '}'.
- Include prometheus_format in test/CMakeLists.txt TEST_COMPONENTS.
Voltage/current unit note (not fixed here): Power_get_input_voltage() returns
TPS546_get_vin()*1000 (mV), and Power_get_output() returns iout*1000 (mA),
but both are emitted as espminer_voltage_volts / espminer_current_amps.
This is a pre-existing inconsistency that warrants a separate investigation.
Fixes test project build by registering components/prometheus_format/test as an IDF test component. Required for compiling the new label-format regression tests in test/.
Drop Grafana UID fields from dashboard.json so imports are portable across instances. Limit build_info sanitization in /api/system/metrics to hostname only, per review guidance.
|
functionality wise, acked, this is a good feat :3 |
|
Can I propose to have the dashboards in a separate repository? |
|
would a separate repo be necessary? its not like theyll be updated very often, theyre just examples |
I'm open to suggestions. It seems people are interested in different bits of the metrics. |
|
ok, final nit from me is i think the _online metric should be removed as it'd always be |
|
also, give this dashboard a whirl: Bitaxe Quick Overview-1780267367205.json |



Add Prometheus metrics exporter (
/api/system/metrics)Summary
Adds a new HTTP endpoint
GET /api/system/metricsthat exposes ESP-Miner telemetry in Prometheus text exposition format, enabling direct scraping by Prometheus or compatible monitoring tools (Grafana, VictoriaMetrics, etc.).A Grafana dashboard JSON (
dashboard.json) is included for quick visualization.Changes
main/http_server/http_server.c— Implements the/api/system/metricshandler with:",\, newlines, non-printable chars)esp_reset_reason_tmain/http_server/openapi.yaml— Adds theGET /api/system/metricspath andPrometheusMetricsschema componentmain/http_server/axe-os/README.md— Documents the endpoint, examplecurlusage, example output, and the full list of metric familiesdashboard.json— Grafana dashboard for visualizing all exported metricsExposed metrics
espminer_build_infoespminer_uptime_secondsespminer_heap_free_bytesespminer_heap_min_free_bytesespminer_wifi_rssi_dbmespminer_wifi_connectedespminer_hashrate_hashes_per_secondespminer_shares_accepted_totalespminer_shares_rejected_totalespminer_jobs_received_totalespminer_best_shareespminer_pool_connectedespminer_mining_enabledespminer_fan_rpm/espminer_fan2_rpmespminer_chip_temp_celsius/espminer_vr_temp_celsiusespminer_voltage_voltsespminer_frequency_hzespminer_power_wattsespminer_current_ampsExample usage
Testing
Scrape the endpoint with
curlor point Prometheus athttp://<device_ip>/api/system/metrics. Importdashboard.jsoninto Grafana for a ready-made dashboard.