diff --git a/linux/task.go b/linux/task.go index a4b46c9b6840..f18ec529adcd 100644 --- a/linux/task.go +++ b/linux/task.go @@ -19,7 +19,7 @@ type Task struct { pid int shim *client.Client namespace string - cg *cgroups.Cgroup + cg cgroups.Cgroup } func newTask(id, namespace string, pid int, shim *client.Client) (*Task, error) { @@ -210,5 +210,13 @@ func (t *Task) Process(ctx context.Context, id string) (runtime.Process, error) } func (t *Task) Metrics(ctx context.Context) (interface{}, error) { - return nil, nil + stats, err := t.cg.Stat(cgroups.IgnoreNotExist) + if err != nil { + return nil, err + } + return stats, nil +} + +func (t *Task) Cgroup() cgroups.Cgroup { + return t.cg } diff --git a/metrics/cgroups/blkio.go b/metrics/cgroups/blkio.go index 481ac354106b..f47be6c91ed3 100644 --- a/metrics/cgroups/blkio.go +++ b/metrics/cgroups/blkio.go @@ -15,7 +15,7 @@ var blkioMetrics = []*metric{ unit: metrics.Total, vt: prometheus.GaugeValue, labels: []string{"op", "device", "major", "minor"}, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Blkio == nil { return nil } @@ -28,7 +28,7 @@ var blkioMetrics = []*metric{ unit: metrics.Total, vt: prometheus.GaugeValue, labels: []string{"op", "device", "major", "minor"}, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Blkio == nil { return nil } @@ -41,7 +41,7 @@ var blkioMetrics = []*metric{ unit: metrics.Bytes, vt: prometheus.GaugeValue, labels: []string{"op", "device", "major", "minor"}, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Blkio == nil { return nil } @@ -54,7 +54,7 @@ var blkioMetrics = []*metric{ unit: metrics.Total, vt: prometheus.GaugeValue, labels: []string{"op", "device", "major", "minor"}, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Blkio == nil { return nil } @@ -67,7 +67,7 @@ var blkioMetrics = []*metric{ unit: metrics.Total, vt: prometheus.GaugeValue, labels: []string{"op", "device", "major", "minor"}, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Blkio == nil { return nil } @@ -80,7 +80,7 @@ var blkioMetrics = []*metric{ unit: metrics.Total, vt: prometheus.GaugeValue, labels: []string{"op", "device", "major", "minor"}, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Blkio == nil { return nil } @@ -93,7 +93,7 @@ var blkioMetrics = []*metric{ unit: metrics.Total, vt: prometheus.GaugeValue, labels: []string{"op", "device", "major", "minor"}, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Blkio == nil { return nil } diff --git a/metrics/cgroups/cgroups.go b/metrics/cgroups/cgroups.go index e2cfb9746d6b..cab67ebbfd5a 100644 --- a/metrics/cgroups/cgroups.go +++ b/metrics/cgroups/cgroups.go @@ -6,6 +6,7 @@ import ( "github.com/containerd/cgroups" eventsapi "github.com/containerd/containerd/api/services/events/v1" "github.com/containerd/containerd/events" + "github.com/containerd/containerd/linux" "github.com/containerd/containerd/log" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/plugin" @@ -49,10 +50,11 @@ type cgroupsMonitor struct { func (m *cgroupsMonitor) Monitor(c runtime.Task) error { info := c.Info() - if err := m.collector.Add(info.ID, info.Namespace, c); err != nil { + t := c.(*linux.Task) + if err := m.collector.Add(info.ID, info.Namespace, t.Cgroup()); err != nil { return err } - return m.oom.Add(info.ID, info.Namespace, cg, m.trigger) + return m.oom.Add(info.ID, info.Namespace, t.Cgroup(), m.trigger) } func (m *cgroupsMonitor) Stop(c runtime.Task) error { diff --git a/metrics/cgroups/cpu.go b/metrics/cgroups/cpu.go index d6ffee94a694..47b59395591f 100644 --- a/metrics/cgroups/cpu.go +++ b/metrics/cgroups/cpu.go @@ -16,7 +16,7 @@ var cpuMetrics = []*metric{ help: "The total cpu time", unit: metrics.Nanoseconds, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Cpu == nil { return nil } @@ -32,7 +32,7 @@ var cpuMetrics = []*metric{ help: "The total kernel cpu time", unit: metrics.Nanoseconds, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Cpu == nil { return nil } @@ -48,7 +48,7 @@ var cpuMetrics = []*metric{ help: "The total user cpu time", unit: metrics.Nanoseconds, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Cpu == nil { return nil } @@ -65,7 +65,7 @@ var cpuMetrics = []*metric{ unit: metrics.Nanoseconds, vt: prometheus.GaugeValue, labels: []string{"cpu"}, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Cpu == nil { return nil } @@ -84,7 +84,7 @@ var cpuMetrics = []*metric{ help: "The total cpu throttle periods", unit: metrics.Total, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Cpu == nil { return nil } @@ -100,7 +100,7 @@ var cpuMetrics = []*metric{ help: "The total cpu throttled periods", unit: metrics.Total, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Cpu == nil { return nil } @@ -116,7 +116,7 @@ var cpuMetrics = []*metric{ help: "The total cpu throttled time", unit: metrics.Nanoseconds, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Cpu == nil { return nil } diff --git a/metrics/cgroups/hugetlb.go b/metrics/cgroups/hugetlb.go index 01c406d23c7b..75cfb17d7644 100644 --- a/metrics/cgroups/hugetlb.go +++ b/metrics/cgroups/hugetlb.go @@ -15,7 +15,7 @@ var hugetlbMetrics = []*metric{ unit: metrics.Bytes, vt: prometheus.GaugeValue, labels: []string{"page"}, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Hugetlb == nil { return nil } @@ -35,7 +35,7 @@ var hugetlbMetrics = []*metric{ unit: metrics.Total, vt: prometheus.GaugeValue, labels: []string{"page"}, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Hugetlb == nil { return nil } @@ -55,7 +55,7 @@ var hugetlbMetrics = []*metric{ unit: metrics.Bytes, vt: prometheus.GaugeValue, labels: []string{"page"}, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Hugetlb == nil { return nil } diff --git a/metrics/cgroups/memory.go b/metrics/cgroups/memory.go index e942efbdf78e..27b574b648ee 100644 --- a/metrics/cgroups/memory.go +++ b/metrics/cgroups/memory.go @@ -14,7 +14,7 @@ var memoryMetrics = []*metric{ help: "The cache amount used", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -30,13 +30,13 @@ var memoryMetrics = []*metric{ help: "The rss amount used", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } return []value{ { - v: float64(stats.Memory.RSS), + v: float64(stats.Memory.Rss), }, } }, @@ -46,13 +46,13 @@ var memoryMetrics = []*metric{ help: "The rss_huge amount used", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } return []value{ { - v: float64(stats.Memory.RSSHuge), + v: float64(stats.Memory.RssHuge), }, } }, @@ -62,7 +62,7 @@ var memoryMetrics = []*metric{ help: "The mapped_file amount used", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -78,7 +78,7 @@ var memoryMetrics = []*metric{ help: "The dirty amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -94,7 +94,7 @@ var memoryMetrics = []*metric{ help: "The writeback amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -110,7 +110,7 @@ var memoryMetrics = []*metric{ help: "The pgpgin amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -126,7 +126,7 @@ var memoryMetrics = []*metric{ help: "The pgpgout amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -142,7 +142,7 @@ var memoryMetrics = []*metric{ help: "The pgfault amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -158,7 +158,7 @@ var memoryMetrics = []*metric{ help: "The pgmajfault amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -174,7 +174,7 @@ var memoryMetrics = []*metric{ help: "The inactive_anon amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -190,7 +190,7 @@ var memoryMetrics = []*metric{ help: "The active_anon amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -206,7 +206,7 @@ var memoryMetrics = []*metric{ help: "The inactive_file amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -222,7 +222,7 @@ var memoryMetrics = []*metric{ help: "The active_file amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -238,7 +238,7 @@ var memoryMetrics = []*metric{ help: "The unevictable amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -254,7 +254,7 @@ var memoryMetrics = []*metric{ help: "The hierarchical_memory_limit amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -270,7 +270,7 @@ var memoryMetrics = []*metric{ help: "The hierarchical_memsw_limit amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -286,7 +286,7 @@ var memoryMetrics = []*metric{ help: "The total_cache amount used", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -302,13 +302,13 @@ var memoryMetrics = []*metric{ help: "The total_rss amount used", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } return []value{ { - v: float64(stats.Memory.TotalRSS), + v: float64(stats.Memory.TotalRss), }, } }, @@ -318,13 +318,13 @@ var memoryMetrics = []*metric{ help: "The total_rss_huge amount used", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } return []value{ { - v: float64(stats.Memory.TotalRSSHuge), + v: float64(stats.Memory.TotalRssHuge), }, } }, @@ -334,7 +334,7 @@ var memoryMetrics = []*metric{ help: "The total_mapped_file amount used", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -350,7 +350,7 @@ var memoryMetrics = []*metric{ help: "The total_dirty amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -366,7 +366,7 @@ var memoryMetrics = []*metric{ help: "The total_writeback amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -382,7 +382,7 @@ var memoryMetrics = []*metric{ help: "The total_pgpgin amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -398,7 +398,7 @@ var memoryMetrics = []*metric{ help: "The total_pgpgout amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -414,7 +414,7 @@ var memoryMetrics = []*metric{ help: "The total_pgfault amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -430,7 +430,7 @@ var memoryMetrics = []*metric{ help: "The total_pgmajfault amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -446,7 +446,7 @@ var memoryMetrics = []*metric{ help: "The total_inactive_anon amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -462,7 +462,7 @@ var memoryMetrics = []*metric{ help: "The total_active_anon amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -478,7 +478,7 @@ var memoryMetrics = []*metric{ help: "The total_inactive_file amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -494,7 +494,7 @@ var memoryMetrics = []*metric{ help: "The total_active_file amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -510,7 +510,7 @@ var memoryMetrics = []*metric{ help: "The total_unevictable amount", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -526,7 +526,7 @@ var memoryMetrics = []*metric{ help: "The usage failcnt", unit: metrics.Total, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -542,7 +542,7 @@ var memoryMetrics = []*metric{ help: "The memory limit", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -558,7 +558,7 @@ var memoryMetrics = []*metric{ help: "The memory maximum usage", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -574,7 +574,7 @@ var memoryMetrics = []*metric{ help: "The memory usage", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -590,7 +590,7 @@ var memoryMetrics = []*metric{ help: "The swap failcnt", unit: metrics.Total, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -606,7 +606,7 @@ var memoryMetrics = []*metric{ help: "The swap limit", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -622,7 +622,7 @@ var memoryMetrics = []*metric{ help: "The swap maximum usage", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -638,7 +638,7 @@ var memoryMetrics = []*metric{ help: "The swap usage", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -654,7 +654,7 @@ var memoryMetrics = []*metric{ help: "The kernel failcnt", unit: metrics.Total, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -670,7 +670,7 @@ var memoryMetrics = []*metric{ help: "The kernel limit", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -686,7 +686,7 @@ var memoryMetrics = []*metric{ help: "The kernel maximum usage", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -702,7 +702,7 @@ var memoryMetrics = []*metric{ help: "The kernel usage", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } @@ -718,13 +718,13 @@ var memoryMetrics = []*metric{ help: "The kerneltcp failcnt", unit: metrics.Total, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } return []value{ { - v: float64(stats.Memory.KernelTCP.Failcnt), + v: float64(stats.Memory.KernelTcp.Failcnt), }, } }, @@ -734,13 +734,13 @@ var memoryMetrics = []*metric{ help: "The kerneltcp limit", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } return []value{ { - v: float64(stats.Memory.KernelTCP.Limit), + v: float64(stats.Memory.KernelTcp.Limit), }, } }, @@ -750,13 +750,13 @@ var memoryMetrics = []*metric{ help: "The kerneltcp maximum usage", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } return []value{ { - v: float64(stats.Memory.KernelTCP.Max), + v: float64(stats.Memory.KernelTcp.Max), }, } }, @@ -766,13 +766,13 @@ var memoryMetrics = []*metric{ help: "The kerneltcp usage", unit: metrics.Bytes, vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Memory == nil { return nil } return []value{ { - v: float64(stats.Memory.KernelTCP.Usage), + v: float64(stats.Memory.KernelTcp.Usage), }, } }, diff --git a/metrics/cgroups/metric.go b/metrics/cgroups/metric.go index d1a0056e0d85..da532dd00f33 100644 --- a/metrics/cgroups/metric.go +++ b/metrics/cgroups/metric.go @@ -20,7 +20,7 @@ type metric struct { vt prometheus.ValueType labels []string // getValues returns the value and labels for the data - getValues func(stats *cgroups.Stats) []value + getValues func(stats *cgroups.Metrics) []value } func (m *metric) desc(ns *metrics.Namespace) *prometheus.Desc { @@ -28,7 +28,7 @@ func (m *metric) desc(ns *metrics.Namespace) *prometheus.Desc { return ns.NewDesc(m.name, m.help, m.unit, append([]string{"container_id", "namespace"}, m.labels...)...) } -func (m *metric) collect(id, namespace string, stats *cgroups.Stats, ns *metrics.Namespace, ch chan<- prometheus.Metric) { +func (m *metric) collect(id, namespace string, stats *cgroups.Metrics, ns *metrics.Namespace, ch chan<- prometheus.Metric) { values := m.getValues(stats) for _, v := range values { ch <- prometheus.MustNewConstMetric(m.desc(ns), m.vt, v.v, append([]string{id, namespace}, v.l...)...) diff --git a/metrics/cgroups/metrics.go b/metrics/cgroups/metrics.go index e4769646714a..6e8b8257c5b3 100644 --- a/metrics/cgroups/metrics.go +++ b/metrics/cgroups/metrics.go @@ -123,7 +123,7 @@ func (c *Collector) Remove(id, namespace string) { delete(c.cgroups, taskID(id, namespace)) } -func blkioValues(l []cgroups.BlkioEntry) []value { +func blkioValues(l []*cgroups.BlkioEntry) []value { var out []value for _, e := range l { out = append(out, value{ diff --git a/metrics/cgroups/pids.go b/metrics/cgroups/pids.go index 35e7d4fd8910..d95a682c7aa8 100644 --- a/metrics/cgroups/pids.go +++ b/metrics/cgroups/pids.go @@ -14,7 +14,7 @@ var pidMetrics = []*metric{ help: "The limit to the number of pids allowed", unit: metrics.Unit("limit"), vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Pids == nil { return nil } @@ -30,7 +30,7 @@ var pidMetrics = []*metric{ help: "The current number of pids", unit: metrics.Unit("current"), vt: prometheus.GaugeValue, - getValues: func(stats *cgroups.Stats) []value { + getValues: func(stats *cgroups.Metrics) []value { if stats.Pids == nil { return nil }