Add Prometheus metrics exporter and API docs#1697
Open
trcjr wants to merge 5 commits into
Open
Conversation
Collaborator
|
Can you add a screenshot of the dashboard? |
Author
Collaborator
|
will look over in the next week or so |
0xf0xx0
requested changes
May 24, 2026
Collaborator
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
Collaborator
|
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/.
Collaborator
|
functionality wise, acked, this is a good feat :3 |
Collaborator
|
Can I propose to have the dashboards in a separate repository? |
Collaborator
|
would a separate repo be necessary? its not like theyll be updated very often, theyre just examples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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.