@@ -19,16 +19,23 @@ package collector
19
19
import (
20
20
"fmt"
21
21
22
+ "github.com/alecthomas/kingpin/v2"
22
23
"github.com/go-kit/log"
23
24
"github.com/prometheus/client_golang/prometheus"
24
25
"github.com/prometheus/procfs"
25
26
)
26
27
28
+ var (
29
+ slabNameInclude = kingpin .Flag ("collector.slabinfo.slabs-include" , "Regexp of slabs to include in slabinfo collector." ).Default (".*" ).String ()
30
+ slabNameExclude = kingpin .Flag ("collector.slabinfo.slabs-exclude" , "Regexp of slabs to exclude in slabinfo collector." ).Default ("" ).String ()
31
+ )
32
+
27
33
type slabinfoCollector struct {
28
- fs procfs.FS
29
- logger log.Logger
30
- subsystem string
31
- labels []string
34
+ fs procfs.FS
35
+ logger log.Logger
36
+ subsystem string
37
+ labels []string
38
+ slabNameFilter deviceFilter
32
39
}
33
40
34
41
func init () {
@@ -42,9 +49,10 @@ func NewSlabinfoCollector(logger log.Logger) (Collector, error) {
42
49
}
43
50
44
51
return & slabinfoCollector {logger : logger ,
45
- fs : fs ,
46
- subsystem : "slabinfo" ,
47
- labels : []string {"slab" },
52
+ fs : fs ,
53
+ subsystem : "slabinfo" ,
54
+ labels : []string {"slab" },
55
+ slabNameFilter : newDeviceFilter (* slabNameExclude , * slabNameInclude ),
48
56
}, nil
49
57
}
50
58
@@ -55,6 +63,9 @@ func (c *slabinfoCollector) Update(ch chan<- prometheus.Metric) error {
55
63
}
56
64
57
65
for _ , slab := range slabinfo .Slabs {
66
+ if c .slabNameFilter .ignored (slab .Name ) {
67
+ continue
68
+ }
58
69
ch <- c .activeObjects (slab .Name , slab .ObjActive )
59
70
ch <- c .objects (slab .Name , slab .ObjNum )
60
71
ch <- c .objectSizeBytes (slab .Name , slab .ObjSize )
0 commit comments