Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the port from the peer metrics label #206

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions e2etests/tests/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,20 +384,19 @@ func labelsForPeers(peers []*frrcontainer.FRR, ipFamily ipfamily.Family) []peerP
if ipFamily == ipfamily.IPv6 {
address = c.Ipv6
}
peerAddr := address + fmt.Sprintf(":%d", c.RouterConfig.BGPPort)

// Note: we deliberately don't add the vrf label in case of the default vrf to validate that
// it is still possible to list the metrics using only the peer label, which is what most users
// who don't care about vrfs should do.
labelsBGP := map[string]string{"peer": peerAddr}
labelsForQueryBGP := fmt.Sprintf(`peer="%s"`, peerAddr)
labelsBGP := map[string]string{"peer": address}
labelsForQueryBGP := fmt.Sprintf(`peer="%s"`, address)
labelsBFD := map[string]string{"peer": address}
labelsForQueryBFD := fmt.Sprintf(`peer="%s"`, address)
noEcho := c.NeighborConfig.MultiHop

if c.RouterConfig.VRF != "" {
labelsBGP["vrf"] = c.RouterConfig.VRF
labelsForQueryBGP = fmt.Sprintf(`peer="%s",vrf="%s"`, peerAddr, c.RouterConfig.VRF)
labelsForQueryBGP = fmt.Sprintf(`peer="%s",vrf="%s"`, address, c.RouterConfig.VRF)
labelsBFD["vrf"] = c.RouterConfig.VRF
labelsForQueryBFD = fmt.Sprintf(`peer="%s",vrf="%s"`, address, c.RouterConfig.VRF)
}
Expand Down
2 changes: 1 addition & 1 deletion frr-tools/metrics/collector/bgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func updateNeighborsMetrics(ch chan<- prometheus.Metric, neighbors map[string][]
if !n.Connected {
sessionUp = 0
}
peerLabel := fmt.Sprintf("%s:%d", n.IP.String(), n.Port)
peerLabel := n.IP.String()

ch <- prometheus.MustNewConstMetric(sessionUpDesc, prometheus.GaugeValue, float64(sessionUp), peerLabel, vrf)
ch <- prometheus.MustNewConstMetric(prefixesDesc, prometheus.GaugeValue, float64(n.PrefixSent), peerLabel, vrf)
Expand Down
4 changes: 2 additions & 2 deletions frr-tools/metrics/collector/bgp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var (
{
desc: "Output contains only IPv4 advertisements",
vtyshOutput: neighborsIPv4Only,
neighborIP: "172.18.0.4:179",
neighborIP: "172.18.0.4",
neighborVRF: "default",
announcedPrefixes: 3,
receivedPrefixes: 3,
Expand All @@ -95,7 +95,7 @@ var (
{
desc: "Output contains mixed IPv4 and IPv6 advertisements",
vtyshOutput: neighborsDual,
neighborIP: "172.18.0.4:180",
neighborIP: "172.18.0.4",
neighborVRF: "default",
announcedPrefixes: 6,
receivedPrefixes: 6,
Expand Down
Loading