Skip to content

feat(metrics): one endpoint for the whole container (#135) - #136

Merged
sylvesterdamgaard merged 1 commit into
mainfrom
feat/unified-metrics-endpoint
Sep 7, 2026
Merged

sylvesterdamgaard merged 1 commit into
mainfrom
feat/unified-metrics-endpoint

Conversation

@sylvesterdamgaard

Copy link
Copy Markdown
Contributor

Implements #135 in full - see the commit message for design and verification details.

One scrape, one story:

cbox_init_process_up{name="php-fpm"} 1        # supervision
fpm_tune_pool_workers_configured{pool="www"} 5 # vertical capacity (merged natively)
# Federated from fpm-exporter (http://127.0.0.1:9114/metrics)
phpfpm_listen_queue{pool="www"} 0              # horizontal saturation
cbox_init_federate_up{name="fpm-exporter"} 1
  • Native merge: the embedded fpm-tune registry rides on the main endpoint (no second listener needed; metrics_addr stays optional)
  • global.metrics_federate: loopback-only local exporters appended per scrape, TTL-cached, degrading to cbox_init_federate_up 0 when down
  • Full gate green locally (Go 1.26.7): tests incl. new federation/validation coverage, lint v2.12.2, govulncheck clean, SBOM regenerated, all 16 example configs valid (one new: metrics-federate.yaml)
  • End-to-end verified with the built binary against a live source, including the down-degradation path

php-baseimages will collapse its documented three-port layout to this single endpoint once released.

… merge + local-exporter federation (#135)

A php-baseimages container had grown three Prometheus endpoints: 9090
(cbox_init_*), 9110 (fpm_tune_*, embedded engine with its own listener)
and 9114 (fpm-exporter). The scale-out signal was literally split across
ports. The main /metrics response can now carry the whole story:

- Embedded engines merge natively: the runtime autotuner's registry is
  added to the main endpoint's gatherers when the tuner starts (it starts
  after the metrics server, so gatherers are snapshotted per scrape under
  a lock). fpm_tune.metrics_addr stays optional for standalone parity.
- global.metrics_federate declares local exporters whose exposition is
  appended to every scrape: per-source timeout (2s) and TTL cache (5s),
  8 MiB body cap, OpenMetrics EOF terminators stripped. Each source
  contributes cbox_init_federate_up{name}; a down source degrades to 0
  and drops its stale body rather than failing the scrape or serving old
  data as current.
- URLs are validated to loopback only (127/8, ::1, localhost) - the
  metrics port must not become a proxy for whatever a config points at.
- With federation enabled the endpoint serves the plain-text exposition
  unconditionally, since federated bodies are appended verbatim and must
  not disagree with a negotiated encoding.

Verified: unit tests for federation (up/down/TTL/EOF/size-cap) and the
merged handler; config validation tests (loopback enforcement, duplicate
names); full gate green (coverage 81% over the 78% floor, govulncheck
clean, SBOM regenerated for the two now-direct prometheus deps); and an
end-to-end run of the built binary - one scrape returned own series +
federated body + federate_up 1, and killing the source degraded to 0
with the scrape still 200.
@sylvesterdamgaard
sylvesterdamgaard merged commit 9bc2e1c into main Sep 7, 2026
5 checks passed
@sylvesterdamgaard
sylvesterdamgaard deleted the feat/unified-metrics-endpoint branch September 7, 2026 10:19
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