Skip to content

Commit

Permalink
fix: map_drops_total replaced with ProcessCacheEvicted and drop event…
Browse files Browse the repository at this point in the history
…cache usuage in mapmetrics

map_drops_total replaced with ProcessCacheEvicted and drop eventcache usuage in mapmetrics

Signed-off-by: sadath-12 <sadathsadu2002@gmail.com>
  • Loading branch information
sadath-12 committed Feb 22, 2024
1 parent 9f641c0 commit 36d7177
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 53 deletions.
4 changes: 0 additions & 4 deletions pkg/eventcache/eventcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,3 @@ func New(s *server.Server) *Cache {
func Get() *Cache {
return cache
}

func (ec *Cache) len() int {
return len(ec.cache)
}
30 changes: 0 additions & 30 deletions pkg/eventcache/metrics.go

This file was deleted.

13 changes: 1 addition & 12 deletions pkg/metrics/mapmetrics/mapmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import (
)

var (
MapDrops = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: consts.MetricsNamespace,
Name: "map_drops_total",
Help: "The total number of entries dropped per LRU map.",
ConstLabels: nil,
}, []string{"map"})
MapSize = metrics.NewBPFGauge(prometheus.NewDesc(
prometheus.BuildFQName(consts.MetricsNamespace, "", "map_in_use"),
"The total number of in-use entries per map.",
Expand All @@ -28,15 +22,10 @@ var (
))
)

func InitMetrics(registry *prometheus.Registry) {
registry.MustRegister(MapDrops)
func InitMetrics(_ *prometheus.Registry) {
// custom collectors are registered independently
}

func MapDropInc(mapName string) {
MapDrops.WithLabelValues(mapName).Inc()
}

// bpfCollector implements prometheus.Collector. It collects metrics directly from BPF maps.
// NB: We can't register individual BPF collectors collecting map metrics, because they share the
// metrics descriptors. Sending duplicate descriptors from different collectors results in
Expand Down
2 changes: 0 additions & 2 deletions pkg/metrics/metricsconfig/initmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package metricsconfig

import (
"github.com/cilium/tetragon/pkg/eventcache"
"github.com/cilium/tetragon/pkg/grpc/tracing"
"github.com/cilium/tetragon/pkg/metrics/errormetrics"
"github.com/cilium/tetragon/pkg/metrics/eventcachemetrics"
Expand Down Expand Up @@ -46,7 +45,6 @@ func InitAllMetrics(registry *prometheus.Registry) {

// register BPF collectors
registry.MustRegister(mapmetrics.NewBPFCollector(
eventcache.NewBPFCollector(),
observer.NewBPFCollector(),
process.NewBPFCollector(),
))
Expand Down
6 changes: 1 addition & 5 deletions pkg/process/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/cilium/tetragon/api/v1/tetragon"
"github.com/cilium/tetragon/pkg/logger"
"github.com/cilium/tetragon/pkg/metrics/errormetrics"
"github.com/cilium/tetragon/pkg/metrics/mapmetrics"
lru "github.com/hashicorp/golang-lru/v2"
)

Expand Down Expand Up @@ -132,7 +131,7 @@ func NewCache(
lruCache, err := lru.NewWithEvict(
processCacheSize,
func(_ string, _ *ProcessInternal) {
mapmetrics.MapDropInc("processLru")
errormetrics.ErrorTotalInc(errormetrics.ProcessCacheEvicted)
},
)
if err != nil {
Expand Down Expand Up @@ -160,9 +159,6 @@ func (pc *Cache) get(processID string) (*ProcessInternal, error) {
// clone or execve events
func (pc *Cache) add(process *ProcessInternal) bool {
evicted := pc.cache.Add(process.process.ExecId, process)
if evicted {
errormetrics.ErrorTotalInc(errormetrics.ProcessCacheEvicted)
}
return evicted
}

Expand Down

0 comments on commit 36d7177

Please sign in to comment.