mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-23 12:30:46 +01:00
Cleanup cgroups collector (#2414)
* Correctly name collector file. * Fix cgroup summary type as gauge. * Use a boolean metric rather than a label for enabled. Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
parent
45c75f1dbc
commit
a516d4de4a
@ -193,6 +193,7 @@ from debugfs. And example usage of this would be
|
||||
Name | Description | OS
|
||||
---------|-------------|----
|
||||
buddyinfo | Exposes statistics of memory fragments as reported by /proc/buddyinfo. | Linux
|
||||
cgroups | A summary of the number of active and enabled cgroups | Linux
|
||||
devstat | Exposes device statistics | Dragonfly, FreeBSD
|
||||
drbd | Exposes Distributed Replicated Block Device statistics (to version 8.4) | Linux
|
||||
ethtool | Exposes network interface information and network driver statistics equivalent to `ethtool`, `ethtool -S`, and `ethtool -i`. | Linux
|
||||
|
@ -18,21 +18,23 @@ package collector
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-kit/log"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/procfs"
|
||||
)
|
||||
|
||||
const cgroupsCollectorSubsystem = "cgroups"
|
||||
|
||||
type cgroupSummaryCollector struct {
|
||||
fs procfs.FS
|
||||
cgroups *prometheus.Desc
|
||||
enabled *prometheus.Desc
|
||||
logger log.Logger
|
||||
}
|
||||
|
||||
func init() {
|
||||
registerCollector("cgroupSummary", defaultEnabled, NewCgroupSummaryCollector)
|
||||
registerCollector(cgroupsCollectorSubsystem, defaultDisabled, NewCgroupSummaryCollector)
|
||||
}
|
||||
|
||||
// NewCgroupSummaryCollector returns a new Collector exposing a summary of cgroups.
|
||||
@ -44,9 +46,14 @@ func NewCgroupSummaryCollector(logger log.Logger) (Collector, error) {
|
||||
return &cgroupSummaryCollector{
|
||||
fs: fs,
|
||||
cgroups: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, "", "cgroups_total"),
|
||||
prometheus.BuildFQName(namespace, cgroupsCollectorSubsystem, "cgroups"),
|
||||
"Current cgroup number of the subsystem.",
|
||||
[]string{"subsys_name", "enabled"}, nil,
|
||||
[]string{"subsys_name"}, nil,
|
||||
),
|
||||
enabled: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, cgroupsCollectorSubsystem, "enabled"),
|
||||
"Current cgroup number of the subsystem.",
|
||||
[]string{"subsys_name"}, nil,
|
||||
),
|
||||
logger: logger,
|
||||
}, nil
|
||||
@ -59,7 +66,8 @@ func (c *cgroupSummaryCollector) Update(ch chan<- prometheus.Metric) error {
|
||||
return err
|
||||
}
|
||||
for _, cs := range cgroupSummarys {
|
||||
ch <- prometheus.MustNewConstMetric(c.cgroups, prometheus.CounterValue, float64(cs.Cgroups), cs.SubsysName, strconv.Itoa(cs.Enabled))
|
||||
ch <- prometheus.MustNewConstMetric(c.cgroups, prometheus.GaugeValue, float64(cs.Cgroups), cs.SubsysName)
|
||||
ch <- prometheus.MustNewConstMetric(c.enabled, prometheus.GaugeValue, float64(cs.Enabled), cs.SubsysName)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -296,20 +296,34 @@ node_buddyinfo_blocks{node="0",size="8",zone="Normal"} 0
|
||||
node_buddyinfo_blocks{node="0",size="9",zone="DMA"} 1
|
||||
node_buddyinfo_blocks{node="0",size="9",zone="DMA32"} 0
|
||||
node_buddyinfo_blocks{node="0",size="9",zone="Normal"} 0
|
||||
# HELP node_cgroups_total Current cgroup number of the subsystem.
|
||||
# TYPE node_cgroups_total counter
|
||||
node_cgroups_total{enabled="1",subsys_name="blkio"} 170
|
||||
node_cgroups_total{enabled="1",subsys_name="cpu"} 172
|
||||
node_cgroups_total{enabled="1",subsys_name="cpuacct"} 172
|
||||
node_cgroups_total{enabled="1",subsys_name="cpuset"} 47
|
||||
node_cgroups_total{enabled="1",subsys_name="devices"} 170
|
||||
node_cgroups_total{enabled="1",subsys_name="freezer"} 47
|
||||
node_cgroups_total{enabled="1",subsys_name="hugetlb"} 47
|
||||
node_cgroups_total{enabled="1",subsys_name="memory"} 234
|
||||
node_cgroups_total{enabled="1",subsys_name="net_cls"} 47
|
||||
node_cgroups_total{enabled="1",subsys_name="perf_event"} 47
|
||||
node_cgroups_total{enabled="1",subsys_name="pids"} 170
|
||||
node_cgroups_total{enabled="1",subsys_name="rdma"} 1
|
||||
# HELP node_cgroups_cgroups Current cgroup number of the subsystem.
|
||||
# TYPE node_cgroups_cgroups gauge
|
||||
node_cgroups_cgroups{subsys_name="blkio"} 170
|
||||
node_cgroups_cgroups{subsys_name="cpu"} 172
|
||||
node_cgroups_cgroups{subsys_name="cpuacct"} 172
|
||||
node_cgroups_cgroups{subsys_name="cpuset"} 47
|
||||
node_cgroups_cgroups{subsys_name="devices"} 170
|
||||
node_cgroups_cgroups{subsys_name="freezer"} 47
|
||||
node_cgroups_cgroups{subsys_name="hugetlb"} 47
|
||||
node_cgroups_cgroups{subsys_name="memory"} 234
|
||||
node_cgroups_cgroups{subsys_name="net_cls"} 47
|
||||
node_cgroups_cgroups{subsys_name="perf_event"} 47
|
||||
node_cgroups_cgroups{subsys_name="pids"} 170
|
||||
node_cgroups_cgroups{subsys_name="rdma"} 1
|
||||
# HELP node_cgroups_enabled Current cgroup number of the subsystem.
|
||||
# TYPE node_cgroups_enabled gauge
|
||||
node_cgroups_enabled{subsys_name="blkio"} 1
|
||||
node_cgroups_enabled{subsys_name="cpu"} 1
|
||||
node_cgroups_enabled{subsys_name="cpuacct"} 1
|
||||
node_cgroups_enabled{subsys_name="cpuset"} 1
|
||||
node_cgroups_enabled{subsys_name="devices"} 1
|
||||
node_cgroups_enabled{subsys_name="freezer"} 1
|
||||
node_cgroups_enabled{subsys_name="hugetlb"} 1
|
||||
node_cgroups_enabled{subsys_name="memory"} 1
|
||||
node_cgroups_enabled{subsys_name="net_cls"} 1
|
||||
node_cgroups_enabled{subsys_name="perf_event"} 1
|
||||
node_cgroups_enabled{subsys_name="pids"} 1
|
||||
node_cgroups_enabled{subsys_name="rdma"} 1
|
||||
# HELP node_context_switches_total Total number of context switches.
|
||||
# TYPE node_context_switches_total counter
|
||||
node_context_switches_total 3.8014093e+07
|
||||
@ -3045,7 +3059,7 @@ node_scrape_collector_success{collector="bcache"} 1
|
||||
node_scrape_collector_success{collector="bonding"} 1
|
||||
node_scrape_collector_success{collector="btrfs"} 1
|
||||
node_scrape_collector_success{collector="buddyinfo"} 1
|
||||
node_scrape_collector_success{collector="cgroupSummary"} 1
|
||||
node_scrape_collector_success{collector="cgroups"} 1
|
||||
node_scrape_collector_success{collector="conntrack"} 1
|
||||
node_scrape_collector_success{collector="cpu"} 1
|
||||
node_scrape_collector_success{collector="cpufreq"} 1
|
||||
|
@ -8,6 +8,7 @@ enabled_collectors=$(cat << COLLECTORS
|
||||
btrfs
|
||||
buddyinfo
|
||||
conntrack
|
||||
cgroups
|
||||
cpu
|
||||
cpufreq
|
||||
diskstats
|
||||
|
Loading…
Reference in New Issue
Block a user