diff --git a/e2etests/tests/metrics.go b/e2etests/tests/metrics.go index fae6b9ae..3039b985 100644 --- a/e2etests/tests/metrics.go +++ b/e2etests/tests/metrics.go @@ -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) } diff --git a/frr-tools/metrics/collector/bgp.go b/frr-tools/metrics/collector/bgp.go index ee13e472..73bd5dc4 100644 --- a/frr-tools/metrics/collector/bgp.go +++ b/frr-tools/metrics/collector/bgp.go @@ -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) diff --git a/frr-tools/metrics/collector/bgp_test.go b/frr-tools/metrics/collector/bgp_test.go index 05469579..7f6ca359 100644 --- a/frr-tools/metrics/collector/bgp_test.go +++ b/frr-tools/metrics/collector/bgp_test.go @@ -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, @@ -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,