monitor-exporter: native Prometheus /metrics for SMC and GPU (#58) - #59
Merged
Merged
Conversation
This was referenced Sep 14, 2026
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.
Implements #58: a
monitor-exporterbinary that serves this Mac's SMC and GPUsensors as Prometheus metrics on
GET /metrics, for a Prometheus server toscrape.
Why it lives here
The sensor readers already exist in
MonitorSources, native and tested. So thisis the native-Swift answer to evanwtf/local-llm#361, which debated wrapping
macmonor reimplementing IOReport in Go — neither is needed. No new packagedependency: the exposition format is rendered in-house (a golden-file test pins
it), and the endpoint is one
NWListenerroute.What it does
/metrics, read at scrape time — the scrape interval is thesampling rate, nothing to configure. A dead exporter fails the scrape
(
up == 0) rather than serving a stale reading.darwin; this exports what it cannot — the SMC (temperature, fans, power) and
the GPU — so nothing is scraped twice. (
--allfor the rest is deferred, YAGNI.)on the dev machine, a fanless MacBook Air:
macos_smc_fan_rpmis correctlyabsent, while temperatures, power and GPU are present.
--bind-portdefault9650(verified free in the Prometheusdefault-port-allocations registry),
--bind-addressdefault loopback.Metric names:
macos_smc_temperature_celsius{sensor},macos_smc_fan_rpm{fan},macos_smc_power_watts{rail},macos_gpu_utilization_ratio,macos_gpu_vram_used_bytes, plusmonitor_exporter_build_info{version,commit}.Celsius only (no °F twin); no
hostnamelabel (instancecovers it).Structure
MonitorPrometheus(new library, pureMonitorCore): exposition renderer +MetricID→metric mapping.MonitorExporter(new executablemonitor-exporter): readsSourceRegistry.make(ids: ["sensors", "gpu"])at scrape time, serves the body.Never links
MonitorLog/MonitorStore— it writes no files.Tests
+22 tests (257 → 279), all green: golden-file exposition format, the mapping
against the real
SMCSource/GPUSourceMetricIDconstants (a rename breaksthe test, not production), the handler with a fake source (maps known, drops
unmapped, always emits
build_info), pure HTTP routing, and one realbound-port scrape. CI adds a
--help/--versionsmoke and boots the endpointto scrape it once. The release zip now ships
monitor-exporterbesidemonitord.Design captured in #58; plan in
docs/superpowers/plans/2026-09-13-monitor-exporter.md.Docs:
docs/exporter.md(launchd plist + scrape config), README and AGENTS updated.Closes #58.