Skip to content

Commit

Permalink
Fix for issue caused by reusing labels
Browse files Browse the repository at this point in the history
Added new labels for BridgeRemote, InterfaceHW and Redundancy

Also minor fix to update error logging
  • Loading branch information
dwray authored and GreenRover committed Sep 12, 2024
1 parent ff62430 commit fb11e36
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 40 deletions.
4 changes: 2 additions & 2 deletions exporter/exporter.collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ func (e *Exporter) CollectPrometheusMetric(ch chan<- semp.PrometheusMetric) {
} else {
up = 0
err = errors.New("Software only scrape target: \"" + dataSource.Name + "\". Please check documentation for valid targets.")
_ = level.Error(e.logger).Log("Hardware only scrape target: \"" + dataSource.Name + "\". Please check documentation for valid targets.")
_ = level.Error(e.logger).Log("Software only scrape target: \"" + dataSource.Name + "\". Please check documentation for valid targets.")
}
case "StorageElement", "StorageElementV1":
if !e.config.IsHWBroker {
up, err = e.semp.GetStorageElementSemp1(ch, dataSource.ItemFilter)
} else {
up = 0
err = errors.New("Software only scrape target: \"" + dataSource.Name + "\". Please check documentation for valid targets.")
_ = level.Error(e.logger).Log("Hardware only scrape target: \"" + dataSource.Name + "\". Please check documentation for valid targets.")
_ = level.Error(e.logger).Log("Software only scrape target: \"" + dataSource.Name + "\". Please check documentation for valid targets.")
}
case "Disk", "DiskV1":
if e.config.IsHWBroker {
Expand Down
16 changes: 8 additions & 8 deletions semp/getBridgeRemoteSemp1.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ func (e *Semp) GetBridgeRemoteSemp1(ch chan<- PrometheusMetric, vpnFilter string
vpnName := bridge.LocalVpnName
remoteVpnName := bridge.ConnectedRemoteVpnName
remoteRouter := bridge.ConnectedRemoteRouterName
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_admin_state"], prometheus.GaugeValue, encodeMetricMulti(bridge.AdminState, []string{"Enabled", "Disabled", "-", "N/A"}), vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_connection_establisher"], prometheus.GaugeValue, encodeMetricMulti(bridge.ConnectionEstablisher, []string{"NotApplicable", "Local", "Remote", "Invalid"}), vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_inbound_operational_state"], prometheus.GaugeValue, encodeMetricMulti(bridge.InboundOperationalState, opStates), vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_inbound_operational_failure_reason"], prometheus.GaugeValue, encodeMetricMulti(bridge.InboundOperationalFailureReason, failReasons), vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_outbound_operational_state"], prometheus.GaugeValue, encodeMetricMulti(bridge.OutboundOperationalState, opStates), vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_queue_operational_state"], prometheus.GaugeValue, encodeMetricMulti(bridge.QueueOperationalState, []string{"NotApplicable", "Bound", "Unbound"}), vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_redundancy"], prometheus.GaugeValue, encodeMetricMulti(bridge.Redundancy, []string{"NotApplicable", "auto", "primary", "backup", "static", "none"}), vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_connection_uptime_in_seconds"], prometheus.GaugeValue, bridge.ConnectionUptimeInSeconds, vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_r_admin_state"], prometheus.GaugeValue, encodeMetricMulti(bridge.AdminState, []string{"Enabled", "Disabled", "-", "N/A"}), vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_r_connection_establisher"], prometheus.GaugeValue, encodeMetricMulti(bridge.ConnectionEstablisher, []string{"NotApplicable", "Local", "Remote", "Invalid"}), vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_r_inbound_operational_state"], prometheus.GaugeValue, encodeMetricMulti(bridge.InboundOperationalState, opStates), vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_r_inbound_operational_failure_reason"], prometheus.GaugeValue, encodeMetricMulti(bridge.InboundOperationalFailureReason, failReasons), vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_r_outbound_operational_state"], prometheus.GaugeValue, encodeMetricMulti(bridge.OutboundOperationalState, opStates), vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_r_queue_operational_state"], prometheus.GaugeValue, encodeMetricMulti(bridge.QueueOperationalState, []string{"NotApplicable", "Bound", "Unbound"}), vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_r_redundancy"], prometheus.GaugeValue, encodeMetricMulti(bridge.Redundancy, []string{"NotApplicable", "auto", "primary", "backup", "static", "none"}), vpnName, bridgeName, remoteVpnName, remoteRouter)
ch <- e.NewMetric(MetricDesc["BridgeRemote"]["bridge_r_connection_uptime_in_seconds"], prometheus.GaugeValue, bridge.ConnectionUptimeInSeconds, vpnName, bridgeName, remoteVpnName, remoteRouter)
}
return 1, nil
}
14 changes: 7 additions & 7 deletions semp/getInterfaceHWSemp1.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ func (e *Semp) GetInterfaceHWSemp1(ch chan<- PrometheusMetric, interfaceFilter s
}

for _, intf := range target.RPC.Show.Interface.Interfaces.Interface {
ch <- e.NewMetric(MetricDesc["Interface"]["network_if_rx_bytes"], prometheus.CounterValue, intf.Stats.RxBytes, intf.Name)
ch <- e.NewMetric(MetricDesc["Interface"]["network_if_tx_bytes"], prometheus.CounterValue, intf.Stats.TxBytes, intf.Name)
ch <- e.NewMetric(MetricDesc["InterfaceHW"]["network_if_rx_packets"], prometheus.CounterValue, intf.Stats.RxPackets, intf.Name)
ch <- e.NewMetric(MetricDesc["InterfaceHW"]["network_if_tx_packets"], prometheus.CounterValue, intf.Stats.TxPackets, intf.Name)
ch <- e.NewMetric(MetricDesc["Interface"]["network_if_state"], prometheus.GaugeValue, encodeMetricMulti(intf.State, []string{"Down", "Up"}), intf.Name)
ch <- e.NewMetric(MetricDesc["InterfaceHW"]["network_if_enabled"], prometheus.GaugeValue, encodeMetricMulti(intf.Enabled, []string{"No", "Yes"}), intf.Name)
ch <- e.NewMetric(MetricDesc["InterfaceHW"]["network_ifhw_rx_bytes"], prometheus.CounterValue, intf.Stats.RxBytes, intf.Name)
ch <- e.NewMetric(MetricDesc["InterfaceHW"]["network_ifhw_tx_bytes"], prometheus.CounterValue, intf.Stats.TxBytes, intf.Name)
ch <- e.NewMetric(MetricDesc["InterfaceHW"]["network_ifhw_rx_packets"], prometheus.CounterValue, intf.Stats.RxPackets, intf.Name)
ch <- e.NewMetric(MetricDesc["InterfaceHW"]["network_ifhw_tx_packets"], prometheus.CounterValue, intf.Stats.TxPackets, intf.Name)
ch <- e.NewMetric(MetricDesc["InterfaceHW"]["network_ifhw_state"], prometheus.GaugeValue, encodeMetricMulti(intf.State, []string{"Down", "Up"}), intf.Name)
ch <- e.NewMetric(MetricDesc["InterfaceHW"]["network_ifhw_enabled"], prometheus.GaugeValue, encodeMetricMulti(intf.Enabled, []string{"No", "Yes"}), intf.Name)
if intf.LAG.ConfiguredMembers.Member != nil {
ch <- e.NewMetric(MetricDesc["InterfaceHW"]["network_lag_configured_members"], prometheus.GaugeValue, float64(len(intf.LAG.ConfiguredMembers.Member)), intf.Name)
ch <- e.NewMetric(MetricDesc["InterfaceHW"]["network_lag_available_members"], prometheus.GaugeValue, float64(len(intf.LAG.AvailableMembers.Member)), intf.Name)
ch <- e.NewMetric(MetricDesc["InterfaceHW"]["network_lag_operational_members"], prometheus.GaugeValue, float64(len(intf.LAG.OperationalMembers.Member)), intf.Name)
} else if len(intf.ETH.LinkDetected) > 0 {
ch <- e.NewMetric(MetricDesc["InterfaceHW"]["network_if_link_detected"], prometheus.GaugeValue, encodeMetricMulti(intf.ETH.LinkDetected, []string{"No", "Yes"}), intf.Name)
ch <- e.NewMetric(MetricDesc["InterfaceHW"]["network_ifhw_link_detected"], prometheus.GaugeValue, encodeMetricMulti(intf.ETH.LinkDetected, []string{"No", "Yes"}), intf.Name)
}
}

Expand Down
8 changes: 4 additions & 4 deletions semp/getRedundancySemp1.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func (e *Semp) GetRedundancySemp1(ch chan<- PrometheusMetric) (ok float64, err e
if !e.isHWBroker {
ch <- e.NewMetric(MetricDesc["Redundancy"]["system_redundancy_role"], prometheus.GaugeValue, encodeMetricMulti(target.RPC.Show.Red.ActiveStandbyRole, []string{"Backup", "Primary", "Monitor", "Undefined"}), mateRouterName)
} else {
ch <- e.NewMetric(MetricDesc["RedundancyHW"]["system_redundancy_role"], prometheus.GaugeValue, encodeMetricMulti(target.RPC.Show.Red.ActiveStandbyRole, []string{"Backup", "Primary", "Undefined"}), mateRouterName)
ch <- e.NewMetric(MetricDesc["RedundancyHW"]["system_redundancy_mode"], prometheus.GaugeValue, encodeMetricMulti(target.RPC.Show.Red.RedundancyMode, []string{"Active/Active", "Active/Standby"}), mateRouterName)
ch <- e.NewMetric(MetricDesc["RedundancyHW"]["system_redundancy_adb_link"], prometheus.GaugeValue, encodeMetricBool(target.RPC.Show.Red.OperationalStatus.ADBLink), mateRouterName)
ch <- e.NewMetric(MetricDesc["RedundancyHW"]["system_redundancy_adb_hello"], prometheus.GaugeValue, encodeMetricBool(target.RPC.Show.Red.OperationalStatus.ADBHello), mateRouterName)
ch <- e.NewMetric(MetricDesc["RedundancyHW"]["system_redundancy_hw_role"], prometheus.GaugeValue, encodeMetricMulti(target.RPC.Show.Red.ActiveStandbyRole, []string{"Backup", "Primary", "Undefined"}), mateRouterName)
ch <- e.NewMetric(MetricDesc["RedundancyHW"]["system_redundancy_hw_mode"], prometheus.GaugeValue, encodeMetricMulti(target.RPC.Show.Red.RedundancyMode, []string{"Active/Active", "Active/Standby"}), mateRouterName)
ch <- e.NewMetric(MetricDesc["RedundancyHW"]["system_redundancy_hw_adb_link"], prometheus.GaugeValue, encodeMetricBool(target.RPC.Show.Red.OperationalStatus.ADBLink), mateRouterName)
ch <- e.NewMetric(MetricDesc["RedundancyHW"]["system_redundancy_hw_adb_hello"], prometheus.GaugeValue, encodeMetricBool(target.RPC.Show.Red.OperationalStatus.ADBHello), mateRouterName)
}

if target.RPC.Show.Red.ActiveStandbyRole == "Primary" && target.RPC.Show.Red.VirtualRouters.Primary.Status.Activity == "Local Active" ||
Expand Down
Loading

0 comments on commit fb11e36

Please sign in to comment.