Skip to content

Commit

Permalink
create specific metics for flow filtering instead of using drop flows…
Browse files Browse the repository at this point in the history
… metric

Signed-off-by: Mohamed Mahmoud <[email protected]>
  • Loading branch information
msherif1234 committed Apr 8, 2024
1 parent b29636c commit 28bce79
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/ebpf/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -136,6 +143,7 @@ type Metrics struct {
EvictedFlowsCounter *EvictionCounter
EvictedPacketsCounter *EvictionCounter
DroppedFlowsCounter *EvictionCounter
FilteredFlowsCounter *EvictionCounter
BufferSizeGauge *BufferSizeGauge
Errors *ErrorCounter
}
Expand All @@ -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
Expand Down

0 comments on commit 28bce79

Please sign in to comment.