From f4d9f661ac8e8fe06eae10130dca5c7211a6aa69 Mon Sep 17 00:00:00 2001 From: beegiik Date: Fri, 22 Nov 2024 11:30:51 +0000 Subject: [PATCH] fix(metric): Add VFP counter metric for uninitialized object --- pkg/metrics/metrics.go | 8 +++++++- pkg/metrics/types.go | 6 +++++- pkg/plugin/windows/hnsstats/hnsstats_windows.go | 7 ++++--- pkg/utils/attr_utils.go | 3 ++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index fde18e4ab6..b3239bb621 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -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, diff --git a/pkg/metrics/types.go b/pkg/metrics/types.go index cff5c28884..08130396ed 100644 --- a/pkg/metrics/types.go +++ b/pkg/metrics/types.go @@ -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" @@ -56,7 +58,9 @@ var ( ForwardPacketsGauge GaugeVec ForwardBytesGauge GaugeVec - WindowsGauge GaugeVec + // Windows + HNSStatsGauge GaugeVec + VFPStatsGauge GaugeVec // Common gauges across os distributions NodeConnectivityStatusGauge GaugeVec diff --git a/pkg/plugin/windows/hnsstats/hnsstats_windows.go b/pkg/plugin/windows/hnsstats/hnsstats_windows.go index e309bfc706..19604920b9 100644 --- a/pkg/plugin/windows/hnsstats/hnsstats_windows.go +++ b/pkg/plugin/windows/hnsstats/hnsstats_windows.go @@ -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 } diff --git a/pkg/utils/attr_utils.go b/pkg/utils/attr_utils.go index 9d102dc9d7..7bd667a473 100644 --- a/pkg/utils/attr_utils.go +++ b/pkg/utils/attr_utils.go @@ -7,7 +7,7 @@ import ( ) const ( - unknown = "__uknown__" + unknown = "__unknown__" ) var ( @@ -49,6 +49,7 @@ var ( AclRule = "aclrule" Active = "ACTIVE" Device = "device" + Uninitialized = "uninitialized" // TCP Connection Statistic Names ResetCount = "ResetCount"