Skip to content

Commit

Permalink
fix(metric): Add VFP counter metric for uninitialized object
Browse files Browse the repository at this point in the history
  • Loading branch information
BeegiiK committed Nov 22, 2024
1 parent 5e11f6f commit 0c4e16e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
8 changes: 7 additions & 1 deletion pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ func InitializeMetrics() {
utils.ForwardBytesGaugeName,
forwardBytesGaugeDescription,
utils.Direction)
WindowsGauge = exporter.CreatePrometheusGaugeVecForMetric(
HNSStatsGauge = exporter.CreatePrometheusGaugeVecForMetric(
exporter.DefaultRegistry,
hnsStats,
hnsStatsDescription,
utils.Direction,
)
VFPStatsGauge = exporter.CreatePrometheusGaugeVecForMetric(
exporter.DefaultRegistry,
vfpStats,
vfpStatsDescription,
utils.State,
)
NodeConnectivityStatusGauge = exporter.CreatePrometheusGaugeVecForMetric(
exporter.DefaultRegistry,
utils.NodeConnectivityStatusName,
Expand Down
6 changes: 5 additions & 1 deletion pkg/metrics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const (
// Windows
hnsStats = "windows_hns_stats"
hnsStatsDescription = "Include many different metrics from packets sent/received to closed connections"
vfpStats = "windows_vfp_stats"
vfpStatsDescription = "Include many different metrics from packets sent/received to closed connections"

// Linux only metrics (for now).
nodeApiServerHandshakeLatencyHistName = "node_apiserver_handshake_latency_ms"
Expand Down Expand Up @@ -56,7 +58,9 @@ var (
ForwardPacketsGauge GaugeVec
ForwardBytesGauge GaugeVec

WindowsGauge GaugeVec
// Windows
HNSStatsGauge GaugeVec
VFPStatsGauge GaugeVec

// Common gauges across os distributions
NodeConnectivityStatusGauge GaugeVec
Expand Down
7 changes: 4 additions & 3 deletions pkg/plugin/windows/hnsstats/hnsstats_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,15 @@ func notifyHnsStats(h *hnsstats, stats *HnsStatsData) {
metrics.ForwardBytesGauge.WithLabelValues(ingressLabel).Set(float64(stats.hnscounters.BytesReceived))
h.l.Debug("emitting bytes received count metric", zap.Uint64(BytesReceived, stats.hnscounters.BytesReceived))

metrics.WindowsGauge.WithLabelValues(PacketsReceived).Set(float64(stats.hnscounters.PacketsReceived))
metrics.WindowsGauge.WithLabelValues(PacketsSent).Set(float64(stats.hnscounters.PacketsSent))
metrics.HNSStatsGauge.WithLabelValues(PacketsReceived).Set(float64(stats.hnscounters.PacketsReceived))
metrics.HNSStatsGauge.WithLabelValues(PacketsSent).Set(float64(stats.hnscounters.PacketsSent))

metrics.DropPacketsGauge.WithLabelValues(utils.Endpoint, egressLabel).Set(float64(stats.hnscounters.DroppedPacketsOutgoing))
metrics.DropPacketsGauge.WithLabelValues(utils.Endpoint, ingressLabel).Set(float64(stats.hnscounters.DroppedPacketsIncoming))

if stats.vfpCounters == nil {
h.l.Warn("will not record some metrics since VFP port counters failed to be set")
metrics.VFPStatsGauge.WithLabelValues(utils.Uninitialized).Inc()
h.l.Debug("will not record some metrics since VFP port counters failed to be set")
return
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/utils/attr_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

const (
unknown = "__uknown__"
unknown = "__unknown__"
)

var (
Expand Down Expand Up @@ -49,6 +49,7 @@ var (
AclRule = "aclrule"
Active = "ACTIVE"
Device = "device"
Uninitialized = "uninitialized"

// TCP Connection Statistic Names
ResetCount = "ResetCount"
Expand Down

0 comments on commit 0c4e16e

Please sign in to comment.