Skip to content

fix(bgp): eliminate per-peer route-table dumps that cause scrape time…#163

Open
jklaiber wants to merge 1 commit into
tynany:masterfrom
jklaiber:perf/bgp-fix-prefix-scrape-timeout
Open

fix(bgp): eliminate per-peer route-table dumps that cause scrape time…#163
jklaiber wants to merge 1 commit into
tynany:masterfrom
jklaiber:perf/bgp-fix-prefix-scrape-timeout

Conversation

@jklaiber

Copy link
Copy Markdown
Contributor

Problem

On hosts with large BGP tables (100k+ prefixes), --collector.bgp.accepted-filtered-prefixes triggered one show bgp <afi> neighbors <peer> routes json command per established peer. FRR serializes the entire Adj-RIB-In to produce this output — taking 30+ seconds for a single peer — which reliably exceeded Prometheus scrape timeouts and returned empty metric sets.

Solution

  • acceptedPrefixCounter and sentPrefixCounter are already maintained by FRR per neighbor per address-family and exposed in show bgp vrf all neighbors json (the single O(peers) call already issued for peer-descriptions/peer-groups). This field has been present since FRR 7.0.
  • getPeerAcceptedFilteredRoutes (the per-peer route-table dump) is removed entirely. processPeerAcceptedFilteredPrefixes now reads the counter directly from the neighbors JSON, reducing the accepted/filtered scrape from O(peers × prefixes) to O(1) additional work.
  • The AFI/SAFI key lookup normalises spaces and case so older FRR versions that emit "IPv4 Unicast" instead of "ipv4Unicast" are handled transparently.

…outs

On hosts with large BGP tables (100k+ prefixes), `--collector.bgp.accepted-filtered-prefixes`
triggered one `show bgp <afi> neighbors <peer> routes json` command per established
peer. FRR serializes the entire Adj-RIB-In to produce this output — taking 30+ seconds
for a single peer — which reliably exceeded Prometheus scrape timeouts and returned
empty metric sets.

- `acceptedPrefixCounter` and `sentPrefixCounter` are already maintained by FRR per
  neighbor per address-family and exposed in `show bgp vrf all neighbors json` (the
  single O(peers) call already issued for peer-descriptions/peer-groups). This field
  has been present since FRR 7.0.
- `getPeerAcceptedFilteredRoutes` (the per-peer route-table dump) is removed entirely.
  `processPeerAcceptedFilteredPrefixes` now reads the counter directly from the
  neighbors JSON, reducing the accepted/filtered scrape from O(peers × prefixes)
  to O(1) additional work.
- The AFI/SAFI key lookup normalises spaces and case so older FRR versions that
  emit `"IPv4 Unicast"` instead of `"ipv4Unicast"` are handled transparently.
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