@@ -19,16 +19,23 @@ package collector
1919import (
2020 "fmt"
2121
22+ "github.com/alecthomas/kingpin/v2"
2223 "github.com/go-kit/log"
2324 "github.com/prometheus/client_golang/prometheus"
2425 "github.com/prometheus/procfs"
2526)
2627
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+
2733type 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
3239}
3340
3441func init () {
@@ -42,9 +49,10 @@ func NewSlabinfoCollector(logger log.Logger) (Collector, error) {
4249 }
4350
4451 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 ),
4856 }, nil
4957}
5058
@@ -55,6 +63,9 @@ func (c *slabinfoCollector) Update(ch chan<- prometheus.Metric) error {
5563 }
5664
5765 for _ , slab := range slabinfo .Slabs {
66+ if c .slabNameFilter .ignored (slab .Name ) {
67+ continue
68+ }
5869 ch <- c .activeObjects (slab .Name , slab .ObjActive )
5970 ch <- c .objects (slab .Name , slab .ObjNum )
6071 ch <- c .objectSizeBytes (slab .Name , slab .ObjSize )
0 commit comments