gnore unused cpus in Prometheus metrics
Only include cpu's in the Prometheus metrics endpoint that were used. In recent kernels the cpuacct.statcpus behavior has changed to include all possible cpu's. This can results in a high number of stale metrics in the Prometheus endpoint.
This commit is contained in:
parent
8a87edd987
commit
a3e8c73865
@ -130,10 +130,12 @@ func NewPrometheusCollector(i infoProvider, f ContainerLabelsFunc) *PrometheusCo
|
||||
getValues: func(s *info.ContainerStats) metricValues {
|
||||
values := make(metricValues, 0, len(s.Cpu.Usage.PerCpu))
|
||||
for i, value := range s.Cpu.Usage.PerCpu {
|
||||
values = append(values, metricValue{
|
||||
value: float64(value) / float64(time.Second),
|
||||
labels: []string{fmt.Sprintf("cpu%02d", i)},
|
||||
})
|
||||
if value > 0 {
|
||||
values = append(values, metricValue{
|
||||
value: float64(value) / float64(time.Second),
|
||||
labels: []string{fmt.Sprintf("cpu%02d", i)},
|
||||
})
|
||||
}
|
||||
}
|
||||
return values
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user