diff --git a/pkg/observer/observer_stats.go b/pkg/observer/observer_stats.go index bdf51c772ed..c933009a8a3 100644 --- a/pkg/observer/observer_stats.go +++ b/pkg/observer/observer_stats.go @@ -6,6 +6,7 @@ package observer import ( "fmt" "path/filepath" + "strings" "github.com/cilium/ebpf" "github.com/cilium/tetragon/pkg/metrics/mapmetrics" @@ -27,19 +28,29 @@ func (c *bpfCollector) Describe(ch chan<- *prometheus.Desc) { } func (c *bpfCollector) Collect(ch chan<- prometheus.Metric) { + statsSuffix := "_stats" for _, m := range sensors.AllMaps { name := m.Name pin := filepath.Join(option.Config.MapDir, name) - pinStats := pin + "_stats" + // Skip map names that end up with _stats. + // This will result in _stats_stats suffixes that we don't care about + if strings.HasSuffix(pin, statsSuffix) { + continue + } + pinStats := pin + statsSuffix mapLinkStats, err := ebpf.LoadPinnedMap(pinStats, nil) if err != nil { - return + // If we fail to open the map with _stats suffix + // continue to the next map. + continue } defer mapLinkStats.Close() mapLink, err := ebpf.LoadPinnedMap(pin, nil) if err != nil { - return + // We have already opened the map with _stats suffix + // so we don't expect that to fail. + continue } defer mapLink.Close()