Unify CPU collector conventions (#806)
* Unify CPU collector conventions Add a common CPU metric description. * All collectors use the same `nodeCpuSecondsDesc`. * All collectors drop the `cpu` prefix for `cpu` label values. * Fix subsystem string in cpu_freebsd. * Fix Linux CPU freq label names.
This commit is contained in:
parent
e3c76b1f0c
commit
14d60958d6
6 changed files with 129 additions and 117 deletions
|
|
@ -94,11 +94,7 @@ func init() {
|
|||
// NewStatCollector returns a new Collector exposing CPU stats.
|
||||
func NewStatCollector() (Collector, error) {
|
||||
return &statCollector{
|
||||
cpu: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, "", "cpu"),
|
||||
"Seconds the cpus spent in each mode.",
|
||||
[]string{"cpu", "mode"}, nil,
|
||||
),
|
||||
cpu: nodeCpuSecondsDesc,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +139,7 @@ func (c *statCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
// Export order: user nice sys intr idle
|
||||
cpuFields := []string{"user", "nice", "sys", "interrupt", "idle"}
|
||||
for i, value := range cpuTimes {
|
||||
cpux := fmt.Sprintf("cpu%d", i/fieldsCount)
|
||||
cpux := fmt.Sprintf("%d", i/fieldsCount)
|
||||
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, value, cpux, cpuFields[i%fieldsCount])
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue