Skip to content

Commit

Permalink
fix(bug): Update logging for uninitialized VFP stats from warn to deb…
Browse files Browse the repository at this point in the history
…ug (#958)

# Description

Add node level metric for no VFPCounters. Tested the new metric works by
calling the metrics endpoint inside the node of the windows retina pod:

```
curl.exe http://10.224.0.9:10093/metrics  

...
# HELP networkobservability_windows_hns_stats Include many different metrics from packets sent/received to closed connections
# TYPE networkobservability_windows_hns_stats gauge
networkobservability_windows_hns_stats{direction="win_packets_recv_count"} 12
networkobservability_windows_hns_stats{direction="win_packets_sent_count"} 84
# HELP networkobservability_windows_vfp_stats Include many different metrics from packets sent/received to closed connections
# TYPE networkobservability_windows_vfp_stats gauge
networkobservability_windows_vfp_stats{state="uninitialized"} 36
```

## Related Issue

#933

## Checklist

- [x] I have read the [contributing
documentation](https://retina.sh/docs/contributing).
- [x] I signed and signed-off the commits (`git commit -S -s ...`). See
[this
documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification)
on signing commits.
- [x] I have correctly attributed the author(s) of the code.
- [x] I have tested the changes locally.
- [x] I have followed the project's style guidelines.
- [x] I have updated the documentation, if necessary.
- [x] I have added tests, if applicable.

## Screenshots (if applicable) or Testing Completed

Please add any relevant screenshots or GIFs to showcase the changes
made.

## Additional Notes
The metric was generated as it brought outside the conditional statement
for testing purposes only, i.e. metric can be compiled and incremented.

---

Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more
information on how to contribute to this project.
  • Loading branch information
BeegiiK authored Feb 14, 2025
1 parent 8d91704 commit 1437cf8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func InitializeMetrics() {
utils.ForwardBytesGaugeName,
forwardBytesGaugeDescription,
utils.Direction)
WindowsGauge = exporter.CreatePrometheusGaugeVecForMetric(
HNSStatsGauge = exporter.CreatePrometheusGaugeVecForMetric(
exporter.DefaultRegistry,
hnsStats,
hnsStatsDescription,
Expand Down
3 changes: 2 additions & 1 deletion pkg/metrics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ var (
ForwardPacketsGauge GaugeVec
ForwardBytesGauge GaugeVec

WindowsGauge GaugeVec
// Windows
HNSStatsGauge GaugeVec

// Common gauges across os distributions
NodeConnectivityStatusGauge GaugeVec
Expand Down
6 changes: 3 additions & 3 deletions pkg/plugin/hnsstats/hnsstats_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ 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")
h.l.Debug("will not record some metrics since VFP port counters failed to be set")
return
}

Expand Down
4 changes: 0 additions & 4 deletions pkg/utils/attr_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import (
"go.opentelemetry.io/otel/attribute"
)

const (
unknown = "__uknown__"
)

var (
pluginKey = attribute.Key("plugin")
eventTypeKey = attribute.Key("event_type")
Expand Down

0 comments on commit 1437cf8

Please sign in to comment.