Skip to content
Snippets Groups Projects
Unverified Commit 3e78d9c1 authored by Mohamed S. Mahmoud's avatar Mohamed S. Mahmoud Committed by GitHub
Browse files

reset ebpf global counters after reading them (#316)

parent 0b0d95aa
Branches
Tags
No related merge requests found
...@@ -483,7 +483,7 @@ func (m *FlowFetcher) ReadGlobalCounter(met *metrics.Metrics) { ...@@ -483,7 +483,7 @@ func (m *FlowFetcher) ReadGlobalCounter(met *metrics.Metrics) {
"FlowFilterAcceptCounter", "FlowFilterAcceptCounter",
"FlowFilterNoMatchCounter", "FlowFilterNoMatchCounter",
} }
zeroCounters := make([]uint32, ebpf.MustPossibleCPU())
for key := BpfGlobalCountersKeyTHASHMAP_FLOWS_DROPPED_KEY; key < BpfGlobalCountersKeyTMAX_DROPPED_FLOWS_KEY; key++ { for key := BpfGlobalCountersKeyTHASHMAP_FLOWS_DROPPED_KEY; key < BpfGlobalCountersKeyTMAX_DROPPED_FLOWS_KEY; key++ {
if err := m.objects.GlobalCounters.Lookup(key, &allCPUValue); err != nil { if err := m.objects.GlobalCounters.Lookup(key, &allCPUValue); err != nil {
log.WithError(err).Warnf("couldn't read global counter") log.WithError(err).Warnf("couldn't read global counter")
...@@ -497,6 +497,11 @@ func (m *FlowFetcher) ReadGlobalCounter(met *metrics.Metrics) { ...@@ -497,6 +497,11 @@ func (m *FlowFetcher) ReadGlobalCounter(met *metrics.Metrics) {
met.FilteredFlowsCounter.WithSourceAndReason("flow-fetcher", reasons[key]).Add(float64(counter)) met.FilteredFlowsCounter.WithSourceAndReason("flow-fetcher", reasons[key]).Add(float64(counter))
} }
} }
// reset the global counter map entry
if err := m.objects.GlobalCounters.Put(key, zeroCounters); err != nil {
log.WithError(err).Warnf("coudn't reset global counter")
return
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment