Skip to content
Snippets Groups Projects
Commit 859a825b authored by Calle Pettersson's avatar Calle Pettersson Committed by Johannes 'fish' Ziemke
Browse files

Replace --collectors.enabled with per-collector flags (#640)

* Move NodeCollector into package collector

* Refactor collector enabling

* Update README with new collector enabled flags

* Fix out-of-date inline flag reference syntax

* Use new flags in end-to-end tests

* Add flag to disable all default collectors

* Track if a flag has been set explicitly

* Add --collectors.disable-defaults to README

* Revert disable-defaults flag

* Shorten flags

* Fixup timex collector registration

* Fix end-to-end tests

* Change procfs and sysfs path flags

* Fix review comments
parent 3762191e
No related branches found
No related tags found
No related merge requests found
Showing
with 183 additions and 81 deletions
Loading
Loading
@@ -16,7 +16,8 @@ The [WMI exporter](https://github.com/martinlindhe/wmi_exporter) is recommended
There is varying support for collectors on each operating system. The tables
below list all existing collectors and the supported systems.
 
Which collectors are used is controlled by the `--collectors.enabled` flag.
Collectors are enabled by providing a `--collector.<name>` flag.
Collectors that are enabled by default can be disabled by providing a `--no-collector.<name>` flag.
 
### Enabled by default
 
Loading
Loading
@@ -137,8 +138,8 @@ docker run -d -p 9100:9100 \
-v "/:/rootfs:ro" \
--net="host" \
quay.io/prometheus/node-exporter \
--collector.procfs /host/proc \
--collector.sysfs /host/sys \
--path.procfs /host/proc \
--path.sysfs /host/sys \
--collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"
```
 
Loading
Loading
Loading
Loading
@@ -30,14 +30,14 @@ type arpCollector struct {
}
 
func init() {
Factories["arp"] = NewARPCollector
registerCollector("arp", defaultEnabled, NewARPCollector)
}
 
// NewARPCollector returns a new Collector exposing ARP stats.
func NewARPCollector() (Collector, error) {
return &arpCollector{
entries: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "arp", "entries"),
prometheus.BuildFQName(namespace, "arp", "entries"),
"ARP entries by device",
[]string{"device"}, nil,
),
Loading
Loading
Loading
Loading
@@ -25,7 +25,7 @@ import (
)
 
func init() {
Factories["bcache"] = NewBcacheCollector
registerCollector("bcache", defaultEnabled, NewBcacheCollector)
}
 
// A bcacheCollector is a Collector which gathers metrics from Linux bcache.
Loading
Loading
@@ -283,7 +283,7 @@ func (c *bcacheCollector) updateBcacheStats(ch chan<- prometheus.Metric, s *bcac
labels := append(devLabel, m.extraLabel...)
 
desc := prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, m.name),
prometheus.BuildFQName(namespace, subsystem, m.name),
m.desc,
labels,
nil,
Loading
Loading
Loading
Loading
@@ -31,7 +31,7 @@ type bondingCollector struct {
}
 
func init() {
Factories["bonding"] = NewBondingCollector
registerCollector("bonding", defaultDisabled, NewBondingCollector)
}
 
// NewBondingCollector returns a newly allocated bondingCollector.
Loading
Loading
@@ -39,12 +39,12 @@ func init() {
func NewBondingCollector() (Collector, error) {
return &bondingCollector{
slaves: typedDesc{prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "bonding", "slaves"),
prometheus.BuildFQName(namespace, "bonding", "slaves"),
"Number of configured slaves per bonding interface.",
[]string{"master"}, nil,
), prometheus.GaugeValue},
active: typedDesc{prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "bonding", "active"),
prometheus.BuildFQName(namespace, "bonding", "active"),
"Number of active slaves per bonding interface.",
[]string{"master"}, nil,
), prometheus.GaugeValue},
Loading
Loading
Loading
Loading
@@ -34,13 +34,13 @@ type buddyinfoCollector struct {
}
 
func init() {
Factories["buddyinfo"] = NewBuddyinfoCollector
registerCollector("buddyinfo", defaultDisabled, NewBuddyinfoCollector)
}
 
// NewBuddyinfoCollector returns a new Collector exposing buddyinfo stats.
func NewBuddyinfoCollector() (Collector, error) {
desc := prometheus.NewDesc(
prometheus.BuildFQName(Namespace, buddyInfoSubsystem, "count"),
prometheus.BuildFQName(namespace, buddyInfoSubsystem, "count"),
"Count of free blocks according to size.",
[]string{"node", "zone", "size"}, nil,
)
Loading
Loading
Loading
Loading
@@ -15,20 +15,121 @@
package collector
 
import (
"fmt"
"sync"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
"gopkg.in/alecthomas/kingpin.v2"
)
 
// Namespace defines the common namespace to be used by all metrics.
const Namespace = "node"
const namespace = "node"
 
// Factories contains the list of all available collectors.
var Factories = make(map[string]func() (Collector, error))
var (
scrapeDurationDesc = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "scrape", "collector_duration_seconds"),
"node_exporter: Duration of a collector scrape.",
[]string{"collector"},
nil,
)
scrapeSuccessDesc = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "scrape", "collector_success"),
"node_exporter: Whether a collector succeeded.",
[]string{"collector"},
nil,
)
)
 
func warnDeprecated(collector string) {
log.Warnf("The %s collector is deprecated and will be removed in the future!", collector)
}
 
const (
defaultEnabled = true
defaultDisabled = false
)
var (
factories = make(map[string]func() (Collector, error))
collectorState = make(map[string]*bool)
)
func registerCollector(collector string, isDefaultEnabled bool, factory func() (Collector, error)) {
var helpDefaultState string
if isDefaultEnabled {
helpDefaultState = "enabled"
} else {
helpDefaultState = "disabled"
}
flagName := fmt.Sprintf("collector.%s", collector)
flagHelp := fmt.Sprintf("Enable the %s collector (default: %s).", collector, helpDefaultState)
defaultValue := fmt.Sprintf("%v", isDefaultEnabled)
flag := kingpin.Flag(flagName, flagHelp).Default(defaultValue).Bool()
collectorState[collector] = flag
factories[collector] = factory
}
// NodeCollector implements the prometheus.Collector interface.
type nodeCollector struct {
Collectors map[string]Collector
}
// NewNodeCollector creates a new NodeCollector
func NewNodeCollector() (*nodeCollector, error) {
collectors := make(map[string]Collector)
for key, enabled := range collectorState {
if *enabled {
collector, err := factories[key]()
if err != nil {
return nil, err
}
collectors[key] = collector
}
}
return &nodeCollector{Collectors: collectors}, nil
}
// Describe implements the prometheus.Collector interface.
func (n nodeCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- scrapeDurationDesc
ch <- scrapeSuccessDesc
}
// Collect implements the prometheus.Collector interface.
func (n nodeCollector) Collect(ch chan<- prometheus.Metric) {
wg := sync.WaitGroup{}
wg.Add(len(n.Collectors))
for name, c := range n.Collectors {
go func(name string, c Collector) {
execute(name, c, ch)
wg.Done()
}(name, c)
}
wg.Wait()
}
func execute(name string, c Collector, ch chan<- prometheus.Metric) {
begin := time.Now()
err := c.Update(ch)
duration := time.Since(begin)
var success float64
if err != nil {
log.Errorf("ERROR: %s collector failed after %fs: %s", name, duration.Seconds(), err)
success = 0
} else {
log.Debugf("OK: %s collector succeeded after %fs.", name, duration.Seconds())
success = 1
}
ch <- prometheus.MustNewConstMetric(scrapeDurationDesc, prometheus.GaugeValue, duration.Seconds(), name)
ch <- prometheus.MustNewConstMetric(scrapeSuccessDesc, prometheus.GaugeValue, success, name)
}
// Collector is the interface a collector has to implement.
type Collector interface {
// Get new metrics and expose them via prometheus registry.
Loading
Loading
Loading
Loading
@@ -25,19 +25,19 @@ type conntrackCollector struct {
}
 
func init() {
Factories["conntrack"] = NewConntrackCollector
registerCollector("conntrack", defaultEnabled, NewConntrackCollector)
}
 
// NewConntrackCollector returns a new Collector exposing conntrack stats.
func NewConntrackCollector() (Collector, error) {
return &conntrackCollector{
current: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", "nf_conntrack_entries"),
prometheus.BuildFQName(namespace, "", "nf_conntrack_entries"),
"Number of currently allocated flow entries for connection tracking.",
nil, nil,
),
limit: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", "nf_conntrack_entries_limit"),
prometheus.BuildFQName(namespace, "", "nf_conntrack_entries_limit"),
"Maximum size of connection tracking table.",
nil, nil,
),
Loading
Loading
Loading
Loading
@@ -52,14 +52,14 @@ type statCollector struct {
}
 
func init() {
Factories["cpu"] = NewCPUCollector
registerCollector("cpu", defaultEnabled, NewCPUCollector)
}
 
// NewCPUCollector returns a new Collector exposing CPU stats.
func NewCPUCollector() (Collector, error) {
return &statCollector{
cpu: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", "cpu"),
prometheus.BuildFQName(namespace, "", "cpu"),
"Seconds the cpus spent in each mode.",
[]string{"cpu", "mode"}, nil,
),
Loading
Loading
Loading
Loading
@@ -88,14 +88,14 @@ type statCollector struct {
}
 
func init() {
Factories["cpu"] = NewStatCollector
registerCollector("cpu", defaultEnabled, NewStatCollector)
}
 
// NewStatCollector returns a new Collector exposing CPU stats.
func NewStatCollector() (Collector, error) {
return &statCollector{
cpu: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", "cpu"),
prometheus.BuildFQName(namespace, "", "cpu"),
"Seconds the cpus spent in each mode.",
[]string{"cpu", "mode"}, nil,
),
Loading
Loading
Loading
Loading
@@ -86,19 +86,19 @@ type statCollector struct {
}
 
func init() {
Factories["cpu"] = NewStatCollector
registerCollector("cpu", defaultEnabled, NewStatCollector)
}
 
// NewStatCollector returns a new Collector exposing CPU stats.
func NewStatCollector() (Collector, error) {
return &statCollector{
cpu: typedDesc{prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "cpu", "seconds_total"),
prometheus.BuildFQName(namespace, "cpu", "seconds_total"),
"Seconds the CPU spent in each mode.",
[]string{"cpu", "mode"}, nil,
), prometheus.CounterValue},
temp: typedDesc{prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "cpu", "temperature_celsius"),
prometheus.BuildFQName(namespace, "cpu", "temperature_celsius"),
"CPU temperature",
[]string{"cpu"}, nil,
), prometheus.GaugeValue},
Loading
Loading
Loading
Loading
@@ -29,7 +29,7 @@ import (
)
 
const (
cpuCollectorNamespace = "cpu"
cpuCollectorSubsystem = "cpu"
)
 
var (
Loading
Loading
@@ -46,40 +46,40 @@ type cpuCollector struct {
}
 
func init() {
Factories["cpu"] = NewCPUCollector
registerCollector("cpu", defaultEnabled, NewCPUCollector)
}
 
// NewCPUCollector returns a new Collector exposing kernel/system statistics.
func NewCPUCollector() (Collector, error) {
return &cpuCollector{
cpu: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", cpuCollectorNamespace),
prometheus.BuildFQName(namespace, "", cpuCollectorSubsystem),
"Seconds the cpus spent in each mode.",
[]string{"cpu", "mode"}, nil,
),
cpuFreq: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, cpuCollectorNamespace, "frequency_hertz"),
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_hertz"),
"Current cpu thread frequency in hertz.",
[]string{"cpu"}, nil,
),
cpuFreqMin: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, cpuCollectorNamespace, "frequency_min_hertz"),
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_min_hertz"),
"Minimum cpu thread frequency in hertz.",
[]string{"cpu"}, nil,
),
cpuFreqMax: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, cpuCollectorNamespace, "frequency_max_hertz"),
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_max_hertz"),
"Maximum cpu thread frequency in hertz.",
[]string{"cpu"}, nil,
),
// FIXME: This should be a per core metric, not per cpu!
cpuCoreThrottle: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, cpuCollectorNamespace, "core_throttles_total"),
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "core_throttles_total"),
"Number of times this cpu core has been throttled.",
[]string{"cpu"}, nil,
),
cpuPackageThrottle: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, cpuCollectorNamespace, "package_throttles_total"),
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "package_throttles_total"),
"Number of times this cpu package has been throttled.",
[]string{"node"}, nil,
),
Loading
Loading
Loading
Loading
@@ -99,24 +99,24 @@ type devstatCollector struct {
}
 
func init() {
Factories["devstat"] = NewDevstatCollector
registerCollector("devstat", defaultDisabled, NewDevstatCollector)
}
 
// NewDevstatCollector returns a new Collector exposing Device stats.
func NewDevstatCollector() (Collector, error) {
return &devstatCollector{
bytesDesc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, devstatSubsystem, "bytes_total"),
prometheus.BuildFQName(namespace, devstatSubsystem, "bytes_total"),
"The total number of bytes transferred for reads and writes on the device.",
[]string{"device"}, nil,
),
transfersDesc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, devstatSubsystem, "transfers_total"),
prometheus.BuildFQName(namespace, devstatSubsystem, "transfers_total"),
"The total number of transactions completed.",
[]string{"device"}, nil,
),
blocksDesc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, devstatSubsystem, "blocks_total"),
prometheus.BuildFQName(namespace, devstatSubsystem, "blocks_total"),
"The total number of bytes given in terms of the devices blocksize.",
[]string{"device"}, nil,
),
Loading
Loading
Loading
Loading
@@ -44,7 +44,7 @@ type devstatCollector struct {
}
 
func init() {
Factories["devstat"] = NewDevstatCollector
registerCollector("devstat", defaultDisabled, NewDevstatCollector)
}
 
// NewDevstatCollector returns a new Collector exposing Device stats.
Loading
Loading
@@ -52,27 +52,27 @@ func NewDevstatCollector() (Collector, error) {
return &devstatCollector{
devinfo: &C.struct_devinfo{},
bytes: typedDesc{prometheus.NewDesc(
prometheus.BuildFQName(Namespace, devstatSubsystem, "bytes_total"),
prometheus.BuildFQName(namespace, devstatSubsystem, "bytes_total"),
"The total number of bytes in transactions.",
[]string{"device", "type"}, nil,
), prometheus.CounterValue},
transfers: typedDesc{prometheus.NewDesc(
prometheus.BuildFQName(Namespace, devstatSubsystem, "transfers_total"),
prometheus.BuildFQName(namespace, devstatSubsystem, "transfers_total"),
"The total number of transactions.",
[]string{"device", "type"}, nil,
), prometheus.CounterValue},
duration: typedDesc{prometheus.NewDesc(
prometheus.BuildFQName(Namespace, devstatSubsystem, "duration_seconds_total"),
prometheus.BuildFQName(namespace, devstatSubsystem, "duration_seconds_total"),
"The total duration of transactions in seconds.",
[]string{"device", "type"}, nil,
), prometheus.CounterValue},
busyTime: typedDesc{prometheus.NewDesc(
prometheus.BuildFQName(Namespace, devstatSubsystem, "busy_time_seconds_total"),
prometheus.BuildFQName(namespace, devstatSubsystem, "busy_time_seconds_total"),
"Total time the device had one or more transactions outstanding in seconds.",
[]string{"device"}, nil,
), prometheus.CounterValue},
blocks: typedDesc{prometheus.NewDesc(
prometheus.BuildFQName(Namespace, devstatSubsystem, "blocks_transferred_total"),
prometheus.BuildFQName(namespace, devstatSubsystem, "blocks_transferred_total"),
"The total number of blocks transferred.",
[]string{"device"}, nil,
), prometheus.CounterValue},
Loading
Loading
Loading
Loading
@@ -36,7 +36,7 @@ type diskstatsCollector struct {
}
 
func init() {
Factories["diskstats"] = NewDiskstatsCollector
registerCollector("diskstats", defaultEnabled, NewDiskstatsCollector)
}
 
// NewDiskstatsCollector returns a new Collector exposing disk device stats.
Loading
Loading
@@ -48,7 +48,7 @@ func NewDiskstatsCollector() (Collector, error) {
{
typedDesc: typedDesc{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "reads_completed_total"),
prometheus.BuildFQName(namespace, diskSubsystem, "reads_completed_total"),
"The total number of reads completed successfully.",
diskLabelNames,
nil,
Loading
Loading
@@ -62,7 +62,7 @@ func NewDiskstatsCollector() (Collector, error) {
{
typedDesc: typedDesc{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "read_sectors_total"),
prometheus.BuildFQName(namespace, diskSubsystem, "read_sectors_total"),
"The total number of sectors read successfully.",
diskLabelNames,
nil,
Loading
Loading
@@ -76,7 +76,7 @@ func NewDiskstatsCollector() (Collector, error) {
{
typedDesc: typedDesc{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "read_seconds_total"),
prometheus.BuildFQName(namespace, diskSubsystem, "read_seconds_total"),
"The total number of seconds spent by all reads.",
diskLabelNames,
nil,
Loading
Loading
@@ -90,7 +90,7 @@ func NewDiskstatsCollector() (Collector, error) {
{
typedDesc: typedDesc{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "writes_completed_total"),
prometheus.BuildFQName(namespace, diskSubsystem, "writes_completed_total"),
"The total number of writes completed successfully.",
diskLabelNames,
nil,
Loading
Loading
@@ -104,7 +104,7 @@ func NewDiskstatsCollector() (Collector, error) {
{
typedDesc: typedDesc{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "written_sectors_total"),
prometheus.BuildFQName(namespace, diskSubsystem, "written_sectors_total"),
"The total number of sectors written successfully.",
diskLabelNames,
nil,
Loading
Loading
@@ -118,7 +118,7 @@ func NewDiskstatsCollector() (Collector, error) {
{
typedDesc: typedDesc{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "write_seconds_total"),
prometheus.BuildFQName(namespace, diskSubsystem, "write_seconds_total"),
"This is the total number of seconds spent by all writes.",
diskLabelNames,
nil,
Loading
Loading
@@ -132,7 +132,7 @@ func NewDiskstatsCollector() (Collector, error) {
{
typedDesc: typedDesc{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "read_bytes_total"),
prometheus.BuildFQName(namespace, diskSubsystem, "read_bytes_total"),
"The total number of bytes read successfully.",
diskLabelNames,
nil,
Loading
Loading
@@ -146,7 +146,7 @@ func NewDiskstatsCollector() (Collector, error) {
{
typedDesc: typedDesc{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "written_bytes_total"),
prometheus.BuildFQName(namespace, diskSubsystem, "written_bytes_total"),
"The total number of bytes written successfully.",
diskLabelNames,
nil,
Loading
Loading
Loading
Loading
@@ -44,7 +44,7 @@ type diskstatsCollector struct {
}
 
func init() {
Factories["diskstats"] = NewDiskstatsCollector
registerCollector("diskstats", defaultEnabled, NewDiskstatsCollector)
}
 
// NewDiskstatsCollector returns a new Collector exposing disk device stats.
Loading
Loading
@@ -57,7 +57,7 @@ func NewDiskstatsCollector() (Collector, error) {
descs: []typedDesc{
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "reads_completed"),
prometheus.BuildFQName(namespace, diskSubsystem, "reads_completed"),
"The total number of reads completed successfully.",
diskLabelNames,
nil,
Loading
Loading
@@ -65,7 +65,7 @@ func NewDiskstatsCollector() (Collector, error) {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "reads_merged"),
prometheus.BuildFQName(namespace, diskSubsystem, "reads_merged"),
"The total number of reads merged. See https://www.kernel.org/doc/Documentation/iostats.txt.",
diskLabelNames,
nil,
Loading
Loading
@@ -73,7 +73,7 @@ func NewDiskstatsCollector() (Collector, error) {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "sectors_read"),
prometheus.BuildFQName(namespace, diskSubsystem, "sectors_read"),
"The total number of sectors read successfully.",
diskLabelNames,
nil,
Loading
Loading
@@ -81,7 +81,7 @@ func NewDiskstatsCollector() (Collector, error) {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "read_time_ms"),
prometheus.BuildFQName(namespace, diskSubsystem, "read_time_ms"),
"The total number of milliseconds spent by all reads.",
diskLabelNames,
nil,
Loading
Loading
@@ -89,7 +89,7 @@ func NewDiskstatsCollector() (Collector, error) {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "writes_completed"),
prometheus.BuildFQName(namespace, diskSubsystem, "writes_completed"),
"The total number of writes completed successfully.",
diskLabelNames,
nil,
Loading
Loading
@@ -97,7 +97,7 @@ func NewDiskstatsCollector() (Collector, error) {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "writes_merged"),
prometheus.BuildFQName(namespace, diskSubsystem, "writes_merged"),
"The number of writes merged. See https://www.kernel.org/doc/Documentation/iostats.txt.",
diskLabelNames,
nil,
Loading
Loading
@@ -105,7 +105,7 @@ func NewDiskstatsCollector() (Collector, error) {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "sectors_written"),
prometheus.BuildFQName(namespace, diskSubsystem, "sectors_written"),
"The total number of sectors written successfully.",
diskLabelNames,
nil,
Loading
Loading
@@ -113,7 +113,7 @@ func NewDiskstatsCollector() (Collector, error) {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "write_time_ms"),
prometheus.BuildFQName(namespace, diskSubsystem, "write_time_ms"),
"This is the total number of milliseconds spent by all writes.",
diskLabelNames,
nil,
Loading
Loading
@@ -121,7 +121,7 @@ func NewDiskstatsCollector() (Collector, error) {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "io_now"),
prometheus.BuildFQName(namespace, diskSubsystem, "io_now"),
"The number of I/Os currently in progress.",
diskLabelNames,
nil,
Loading
Loading
@@ -129,7 +129,7 @@ func NewDiskstatsCollector() (Collector, error) {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "io_time_ms"),
prometheus.BuildFQName(namespace, diskSubsystem, "io_time_ms"),
"Total Milliseconds spent doing I/Os.",
diskLabelNames,
nil,
Loading
Loading
@@ -137,7 +137,7 @@ func NewDiskstatsCollector() (Collector, error) {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "io_time_weighted"),
prometheus.BuildFQName(namespace, diskSubsystem, "io_time_weighted"),
"The weighted # of milliseconds spent doing I/Os. See https://www.kernel.org/doc/Documentation/iostats.txt.",
diskLabelNames,
nil,
Loading
Loading
@@ -145,7 +145,7 @@ func NewDiskstatsCollector() (Collector, error) {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "bytes_read"),
prometheus.BuildFQName(namespace, diskSubsystem, "bytes_read"),
"The total number of bytes read successfully.",
diskLabelNames,
nil,
Loading
Loading
@@ -153,7 +153,7 @@ func NewDiskstatsCollector() (Collector, error) {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, diskSubsystem, "bytes_written"),
prometheus.BuildFQName(namespace, diskSubsystem, "bytes_written"),
"The total number of bytes written successfully.",
diskLabelNames,
nil,
Loading
Loading
Loading
Loading
@@ -34,7 +34,7 @@ type drbdNumericalMetric struct {
func newDRBDNumericalMetric(name string, desc string, valueType prometheus.ValueType, multiplier float64) drbdNumericalMetric {
return drbdNumericalMetric{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "drbd", name),
prometheus.BuildFQName(namespace, "drbd", name),
desc,
[]string{"device"}, nil),
valueType: valueType,
Loading
Loading
@@ -58,7 +58,7 @@ func (metric *drbdStringPairMetric) isOkay(value string) float64 {
func newDRBDStringPairMetric(name string, desc string, valueOkay string) drbdStringPairMetric {
return drbdStringPairMetric{
desc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "drbd", name),
prometheus.BuildFQName(namespace, "drbd", name),
desc,
[]string{"device", "node"}, nil),
valueOkay: valueOkay,
Loading
Loading
@@ -140,7 +140,7 @@ var (
}
 
drbdConnected = prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "drbd", "connected"),
prometheus.BuildFQName(namespace, "drbd", "connected"),
"Whether DRBD is connected to the peer.",
[]string{"device"}, nil)
)
Loading
Loading
@@ -148,7 +148,7 @@ var (
type drbdCollector struct{}
 
func init() {
Factories["drbd"] = newDRBDCollector
registerCollector("drbd", defaultDisabled, newDRBDCollector)
}
 
func newDRBDCollector() (Collector, error) {
Loading
Loading
Loading
Loading
@@ -41,29 +41,29 @@ type edacCollector struct {
}
 
func init() {
Factories["edac"] = NewEdacCollector
registerCollector("edac", defaultEnabled, NewEdacCollector)
}
 
// NewEdacCollector returns a new Collector exposing edac stats.
func NewEdacCollector() (Collector, error) {
return &edacCollector{
ceCount: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, edacSubsystem, "correctable_errors_total"),
prometheus.BuildFQName(namespace, edacSubsystem, "correctable_errors_total"),
"Total correctable memory errors.",
[]string{"controller"}, nil,
),
ueCount: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, edacSubsystem, "uncorrectable_errors_total"),
prometheus.BuildFQName(namespace, edacSubsystem, "uncorrectable_errors_total"),
"Total uncorrectable memory errors.",
[]string{"controller"}, nil,
),
csRowCECount: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, edacSubsystem, "csrow_correctable_errors_total"),
prometheus.BuildFQName(namespace, edacSubsystem, "csrow_correctable_errors_total"),
"Total correctable memory errors for this csrow.",
[]string{"controller", "csrow"}, nil,
),
csRowUECount: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, edacSubsystem, "csrow_uncorrectable_errors_total"),
prometheus.BuildFQName(namespace, edacSubsystem, "csrow_uncorrectable_errors_total"),
"Total uncorrectable memory errors for this csrow.",
[]string{"controller", "csrow"}, nil,
),
Loading
Loading
Loading
Loading
@@ -26,14 +26,14 @@ type entropyCollector struct {
}
 
func init() {
Factories["entropy"] = NewEntropyCollector
registerCollector("entropy", defaultEnabled, NewEntropyCollector)
}
 
// NewEntropyCollector returns a new Collector exposing entropy stats.
func NewEntropyCollector() (Collector, error) {
return &entropyCollector{
entropyAvail: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", "entropy_available_bits"),
prometheus.BuildFQName(namespace, "", "entropy_available_bits"),
"Bits of available entropy.",
nil, nil,
),
Loading
Loading
Loading
Loading
@@ -25,7 +25,7 @@ type execCollector struct {
}
 
func init() {
Factories["exec"] = NewExecCollector
registerCollector("exec", defaultEnabled, NewExecCollector)
}
 
// NewExecCollector returns a new Collector exposing system execution statistics.
Loading
Loading
@@ -95,7 +95,7 @@ func (c *execCollector) Update(ch chan<- prometheus.Metric) error {
 
ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "exec", m.name),
prometheus.BuildFQName(namespace, "exec", m.name),
m.description,
nil, nil,
), prometheus.CounterValue, v)
Loading
Loading
Loading
Loading
@@ -32,7 +32,7 @@ const (
type fileFDStatCollector struct{}
 
func init() {
Factories[fileFDStatSubsystem] = NewFileFDStatCollector
registerCollector(fileFDStatSubsystem, defaultEnabled, NewFileFDStatCollector)
}
 
// NewFileFDStatCollector returns a new Collector exposing file-nr stats.
Loading
Loading
@@ -52,7 +52,7 @@ func (c *fileFDStatCollector) Update(ch chan<- prometheus.Metric) error {
}
ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName(Namespace, fileFDStatSubsystem, name),
prometheus.BuildFQName(namespace, fileFDStatSubsystem, name),
fmt.Sprintf("File descriptor statistics: %s.", name),
nil, nil,
),
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment