Skip to content

Commit 39c276a

Browse files
authored
Remove redundant bio_bgp_up metric (#373)
The metrics »bio_bgp_up« is exposing the exact same value as the metric »bio_bgp_state« having the value 6 so it adds redundant data to Prometheus which becomes a concern at scale. Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
1 parent 568af71 commit 39c276a

File tree

4 files changed

+3
-18
lines changed

4 files changed

+3
-18
lines changed

metrics/bgp/adapter/prom/bgp_prom_adapter.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,12 @@ var (
3939

4040
func init() {
4141
labels := []string{"peer_ip", "local_asn", "peer_asn", "vrf"}
42-
upDesc = prometheus.NewDesc(prefix+"up", "Returns if the session is up", labels, nil)
4342
stateDesc = prometheus.NewDesc(prefix+"state", "State of the BGP session (Down = 0, Idle = 1, Connect = 2, Active = 3, OpenSent = 4, OpenConfirm = 5, Established = 6)", labels, nil)
4443
uptimeDesc = prometheus.NewDesc(prefix+"uptime_second", "Time since the session was established in seconds", labels, nil)
4544
updatesReceivedDesc = prometheus.NewDesc(prefix+"update_received_count", "Number of updates received", labels, nil)
4645
updatesSentDesc = prometheus.NewDesc(prefix+"update_sent_count", "Number of updates sent", labels, nil)
4746

4847
labelsRouter := append(labels, "sys_name", "agent_address")
49-
upDescRouter = prometheus.NewDesc(prefix+"up", "Returns if the session is up", labelsRouter, nil)
5048
stateDescRouter = prometheus.NewDesc(prefix+"state", "State of the BGP session (Down = 0, Idle = 1, Connect = 2, Active = 3, OpenSent = 4, OpenConfirm = 5, Established = 6)", labelsRouter, nil)
5149
uptimeDescRouter = prometheus.NewDesc(prefix+"uptime_second", "Time since the session was established in seconds", labelsRouter, nil)
5250
updatesReceivedDescRouter = prometheus.NewDesc(prefix+"update_received_count", "Number of updates received", labelsRouter, nil)
@@ -79,7 +77,6 @@ type bgpCollector struct {
7977

8078
// Describe conforms to the prometheus collector interface
8179
func (c *bgpCollector) Describe(ch chan<- *prometheus.Desc) {
82-
ch <- upDesc
8380
ch <- stateDesc
8481
ch <- uptimeDesc
8582
ch <- updatesReceivedDesc
@@ -92,7 +89,6 @@ func (c *bgpCollector) Describe(ch chan<- *prometheus.Desc) {
9289
}
9390

9491
func DescribeRouter(ch chan<- *prometheus.Desc) {
95-
ch <- upDescRouter
9692
ch <- stateDescRouter
9793
ch <- uptimeDescRouter
9894
ch <- updatesReceivedDescRouter
@@ -125,13 +121,10 @@ func collectForPeer(ch chan<- prometheus.Metric, peer *metrics.BGPPeerMetrics) {
125121
peer.VRF,
126122
}
127123

128-
var up float64
129124
var uptime float64
130-
if peer.Up {
131-
up = 1
125+
if peer.State == metrics.StateEstablished {
132126
uptime = float64(time.Since(peer.Since) * time.Second)
133127
}
134-
ch <- prometheus.MustNewConstMetric(upDesc, prometheus.GaugeValue, up, l...)
135128
ch <- prometheus.MustNewConstMetric(uptimeDesc, prometheus.GaugeValue, uptime, l...)
136129
ch <- prometheus.MustNewConstMetric(stateDesc, prometheus.GaugeValue, float64(peer.State), l...)
137130

@@ -153,13 +146,10 @@ func CollectForPeerRouter(ch chan<- prometheus.Metric, sysName string, agentAddr
153146
agentAddress,
154147
}
155148

156-
var up float64
157149
var uptime float64
158-
if peer.Up {
159-
up = 1
150+
if peer.State == metrics.StateEstablished {
160151
uptime = float64(time.Since(peer.Since) * time.Second)
161152
}
162-
ch <- prometheus.MustNewConstMetric(upDescRouter, prometheus.GaugeValue, up, l...)
163153
ch <- prometheus.MustNewConstMetric(uptimeDescRouter, prometheus.GaugeValue, uptime, l...)
164154
ch <- prometheus.MustNewConstMetric(stateDescRouter, prometheus.GaugeValue, float64(peer.State), l...)
165155

protocols/bgp/metrics/bgp_peer_metrics.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ type BGPPeerMetrics struct {
3636
// State of the BGP session (Down = 0, Idle = 1, Connect = 2, Active = 3, OpenSent = 4, OpenConfirm = 5, Established = 6)
3737
State uint8
3838

39-
// Up returns if the session is established
40-
Up bool
41-
4239
// UpdatesReceived is the number of update messages received on this session
4340
UpdatesReceived uint64
4441

protocols/bgp/server/metrics_service.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ func metricsForPeer(peer *peer) *metrics.BGPPeerMetrics {
4141

4242
fsm := fsms[0]
4343
m.State = statusFromFSM(fsm)
44-
m.Up = m.State == metrics.StateEstablished
4544

46-
if m.Up {
45+
if m.State == metrics.StateEstablished {
4746
m.Since = fsm.establishedTime
4847
}
4948

protocols/bgp/server/metrics_service_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ func TestMetrics(t *testing.T) {
5858
UpdatesReceived: 3,
5959
UpdatesSent: 4,
6060
VRF: "inet.0",
61-
Up: true,
6261
State: metrics.StateEstablished,
6362
Since: establishedTime,
6463
AddressFamilies: []*metrics.BGPAddressFamilyMetrics{

0 commit comments

Comments
 (0)