Skip to content

Add Prometheus HTTP Service Discovery for switches - #110

Draft
peanball wants to merge 7 commits into
enh/sonic-metricsfrom
enh/prometheus-http-sd-switches
Draft

Add Prometheus HTTP Service Discovery for switches#110
peanball wants to merge 7 commits into
enh/sonic-metricsfrom
enh/prometheus-http-sd-switches

Conversation

@peanball

Copy link
Copy Markdown
Member

Summary

  • Adds a GET /switch-sd endpoint to the provisioning HTTP server that implements the Prometheus HTTP SD protocol
  • Returns only Ready switches with non-empty management hosts as scrape targets on port 9100
  • Exposes switch metadata (name, mac, sku, firmware) as __meta_sonic_switch_* labels for Prometheus relabeling

@github-actions github-actions Bot added documentation Improvements or additions to documentation enhancement New feature or request size/L labels Apr 23, 2026
@hardikdr hardikdr added the area/switch-automation Automation processes for network switch management and operations. label Apr 24, 2026
@hardikdr hardikdr added this to Roadmap Apr 24, 2026
@peanball
peanball force-pushed the enh/sonic-metrics branch from 70db77d to 056d982 Compare May 4, 2026 10:27
peanball added 2 commits May 4, 2026 13:13
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
peanball force-pushed the enh/sonic-metrics branch from 056d982 to 332ea97 Compare May 4, 2026 12:58
@peanball
peanball force-pushed the enh/prometheus-http-sd-switches branch from 69f0b4b to f4d9218 Compare May 4, 2026 12:58
peanball added 5 commits May 7, 2026 11:25
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/switch-automation Automation processes for network switch management and operations. documentation Improvements or additions to documentation enhancement New feature or request size/L

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants