From f4d9f661ac8e8fe06eae10130dca5c7211a6aa69 Mon Sep 17 00:00:00 2001 From: beegiik Date: Fri, 22 Nov 2024 11:30:51 +0000 Subject: [PATCH 1/3] 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" From 460b6fb244384ccc62c4df63968617bdaf8e50f7 Mon Sep 17 00:00:00 2001 From: beegiik Date: Mon, 23 Dec 2024 10:09:29 +0000 Subject: [PATCH 2/3] Polishing --- pkg/utils/attr_utils.go | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/pkg/utils/attr_utils.go b/pkg/utils/attr_utils.go index c867ba40fa..ad83ef5327 100644 --- a/pkg/utils/attr_utils.go +++ b/pkg/utils/attr_utils.go @@ -34,24 +34,6 @@ var ( remoteNodeKey = attribute.Key("remote_node") // todo move to attributes pkg? -<<<<<<< HEAD - Type = "type" - Reason = "reason" - Direction = "direction" - SourceNodeName = "source_node_name" - TargetNodeName = "target_node_name" - State = "state" - Address = "address" - Port = "port" - StatName = "statistic_name" - InterfaceName = "interface_name" - Flag = "flag" - Endpoint = "endpoint" - AclRule = "aclrule" - Active = "ACTIVE" - Device = "device" - Uninitialized = "uninitialized" -======= Type = "type" Reason = "reason" Direction = "direction" @@ -68,7 +50,7 @@ var ( AclRule = "aclrule" Active = "ACTIVE" Device = "device" ->>>>>>> main + Uninitialized = "uninitialized" // TCP Connection Statistic Names ResetCount = "ResetCount" From d491bc7407ac506247fde10a7bca08782559a166 Mon Sep 17 00:00:00 2001 From: beegiik Date: Mon, 23 Dec 2024 10:20:26 +0000 Subject: [PATCH 3/3] Remove unused variable to fix lint --- pkg/utils/attr_utils.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkg/utils/attr_utils.go b/pkg/utils/attr_utils.go index ad83ef5327..83153f0012 100644 --- a/pkg/utils/attr_utils.go +++ b/pkg/utils/attr_utils.go @@ -6,10 +6,6 @@ import ( "go.opentelemetry.io/otel/attribute" ) -const ( - unknown = "__unknown__" -) - var ( pluginKey = attribute.Key("plugin") eventTypeKey = attribute.Key("event_type")