Add Prometheus HTTP Service Discovery for switches - #110
Draft
peanball wants to merge 7 commits into
Draft
Conversation
peanball
force-pushed
the
enh/sonic-metrics
branch
from
May 4, 2026 10:27
70db77d to
056d982
Compare
Register a /switch-sd endpoint on the controller-runtime metrics server using AddMetricsServerExtraHandler. This serves Prometheus HTTP SD target groups for all switches in Ready state, enabling dynamic scrape target discovery without coupling to the provisioning HTTP server.
- Agent gRPC server: listen on "tcp" (dual-stack) instead of "tcp4" - Agent metrics server: bind to ":port" instead of "0.0.0.0:port" - Operator switch_util: use net.JoinHostPort for correct IPv6 address formatting (e.g. [2001:db8::1]:50051)
peanball
force-pushed
the
enh/sonic-metrics
branch
from
May 4, 2026 12:58
056d982 to
332ea97
Compare
peanball
force-pushed
the
enh/prometheus-http-sd-switches
branch
from
May 4, 2026 12:58
69f0b4b to
f4d9218
Compare
Remove sonic_scrape_duration_seconds from docs since the metric was removed.
Skip empty-string subexp names in regex_capture to avoid producing empty label values for non-participating capture groups.
… operator Remove println debug statement and commented-out legacy dial code.
…tches Add 10s response cache and context timeout (10s) to bound API load from concurrent Prometheus scrapers and protect against slow List calls.
…tches Add the new docs for HTTP SD
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.
Summary
GET /switch-sdendpoint to the provisioning HTTP server that implements the Prometheus HTTP SD protocolReadyswitches with non-empty management hosts as scrape targets on port 9100name,mac,sku,firmware) as__meta_sonic_switch_*labels for Prometheus relabeling