From 28bce79e650e1cead42541ae4d530797a7a62088 Mon Sep 17 00:00:00 2001 From: Mohamed Mahmoud Date: Fri, 5 Apr 2024 17:14:14 -0400 Subject: [PATCH] create specific metics for flow filtering instead of using drop flows metric Signed-off-by: Mohamed Mahmoud --- pkg/ebpf/tracer.go | 6 +++++- pkg/metrics/metrics.go | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/ebpf/tracer.go b/pkg/ebpf/tracer.go index 14f5052f3..f21d144f4 100644 --- a/pkg/ebpf/tracer.go +++ b/pkg/ebpf/tracer.go @@ -491,7 +491,11 @@ func (m *FlowFetcher) ReadGlobalCounter(met *metrics.Metrics) { } // aggregate all the counters for _, counter := range allCPUValue { - met.DroppedFlowsCounter.WithSourceAndReason("flow-fetcher", reasons[key]).Add(float64(counter)) + if key == BpfGlobalCountersKeyTHASHMAP_FLOWS_DROPPED_KEY { + met.DroppedFlowsCounter.WithSourceAndReason("flow-fetcher", reasons[key]).Add(float64(counter)) + } else { + met.FilteredFlowsCounter.WithSourceAndReason("flow-fetcher", reasons[key]).Add(float64(counter)) + } } } } diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 1d49cf776..61cc72fc7 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -85,6 +85,13 @@ var ( "source", "reason", ) + filterFlows = defineMetric( + "filtered_flows_total", + "Number of filtered flows", + TypeCounter, + "source", + "reason", + ) bufferSize = defineMetric( "buffer_size", "Buffer size", @@ -136,6 +143,7 @@ type Metrics struct { EvictedFlowsCounter *EvictionCounter EvictedPacketsCounter *EvictionCounter DroppedFlowsCounter *EvictionCounter + FilteredFlowsCounter *EvictionCounter BufferSizeGauge *BufferSizeGauge Errors *ErrorCounter } @@ -148,6 +156,7 @@ func NewMetrics(settings *Settings) *Metrics { m.EvictedFlowsCounter = &EvictionCounter{vec: m.NewCounterVec(&evictedFlowsTotal)} m.EvictedPacketsCounter = &EvictionCounter{vec: m.NewCounterVec(&evictedPktTotal)} m.DroppedFlowsCounter = &EvictionCounter{vec: m.NewCounterVec(&droppedFlows)} + m.FilteredFlowsCounter = &EvictionCounter{vec: m.NewCounterVec(&filterFlows)} m.BufferSizeGauge = &BufferSizeGauge{vec: m.NewGaugeVec(&bufferSize)} m.Errors = &ErrorCounter{vec: m.NewCounterVec(&errorsCounter)} return m