Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(metric): Add VFP counter metric for uninitialized object #958

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
BeegiiK marked this conversation as resolved.
Show resolved Hide resolved
exporter.DefaultRegistry,
hnsStats,
hnsStatsDescription,
utils.Direction,
)
VfpStatsGauge = exporter.CreatePrometheusCounterVecForMetric(
BeegiiK marked this conversation as resolved.
Show resolved Hide resolved
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 CounterVec

// 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 @@ -159,14 +159,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
Loading