From 99f611e997a3b785b2d048136d56f341907eb139 Mon Sep 17 00:00:00 2001 From: Anna Kapuscinska Date: Wed, 14 Aug 2024 00:19:10 +0100 Subject: [PATCH] kprobemetrics: Fix collecting missed metrics When collecting metrics from kernel, Tetragon needs to aggregate them in userspace maps to avoid duplicate labelsets, which cause metrics server errors. This was done incorrectly, using a pointer to missedKey struct as the aggregation key. Use missedKey struct directly. Signed-off-by: Anna Kapuscinska --- pkg/metrics/kprobemetrics/collector.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/metrics/kprobemetrics/collector.go b/pkg/metrics/kprobemetrics/collector.go index de514773c7f..0ce815460f1 100644 --- a/pkg/metrics/kprobemetrics/collector.go +++ b/pkg/metrics/kprobemetrics/collector.go @@ -73,8 +73,8 @@ type missedKey struct { func collect(ch chan<- prometheus.Metric) { allPrograms := sensors.AllPrograms() - mapProg := make(map[*missedKey]uint64) - mapLink := make(map[*missedKey]uint64) + mapProg := make(map[missedKey]uint64) + mapLink := make(map[missedKey]uint64) // Group all the metrics together so we avoid of duplicate // metric values due to missing policy name. @@ -88,7 +88,7 @@ func collect(ch chan<- prometheus.Metric) { continue } - key := &missedKey{load.Policy, load.Attach} + key := missedKey{load.Policy, load.Attach} if okLink { mapLink[key] = mapLink[key] + valLink