feat(metrics): one endpoint for the whole container (#135) - #136
Merged
Merged
Conversation
… 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.
Closed
4 tasks
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 #135 in full - see the commit message for design and verification details.
One scrape, one story:
metrics_addrstays optional)global.metrics_federate: loopback-only local exporters appended per scrape, TTL-cached, degrading tocbox_init_federate_up 0when downmetrics-federate.yaml)php-baseimages will collapse its documented three-port layout to this single endpoint once released.