Add flag to disable guest CPU metrics
In high scale virtualized / cloud environments there are typically no guest VMs. Add a boolean flag to allow disabling the Linux guest CPU metrics. Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
parent
832909dd25
commit
84b36c4fd8
|
@ -5,6 +5,8 @@
|
||||||
* [ENHANCEMENT]
|
* [ENHANCEMENT]
|
||||||
* [BUGFIX]
|
* [BUGFIX]
|
||||||
|
|
||||||
|
* [ENHANCEMENT] Add flag to disable guest CPU metrics #2123
|
||||||
|
|
||||||
## 1.2.2 / 2021-08-06
|
## 1.2.2 / 2021-08-06
|
||||||
|
|
||||||
* [BUGFIX] Fix processes collector long int parsing #2112
|
* [BUGFIX] Fix processes collector long int parsing #2112
|
||||||
|
|
|
@ -50,6 +50,7 @@ type cpuCollector struct {
|
||||||
const jumpBackSeconds = 3.0
|
const jumpBackSeconds = 3.0
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
enableCPUGuest = kingpin.Flag("collector.cpu.guest", "Enables metric node_cpu_guest_seconds_total").Default("true").Bool()
|
||||||
enableCPUInfo = kingpin.Flag("collector.cpu.info", "Enables metric cpu_info").Bool()
|
enableCPUInfo = kingpin.Flag("collector.cpu.info", "Enables metric cpu_info").Bool()
|
||||||
flagsInclude = kingpin.Flag("collector.cpu.info.flags-include", "Filter the `flags` field in cpuInfo with a value that must be a regular expression").String()
|
flagsInclude = kingpin.Flag("collector.cpu.info.flags-include", "Filter the `flags` field in cpuInfo with a value that must be a regular expression").String()
|
||||||
bugsInclude = kingpin.Flag("collector.cpu.info.bugs-include", "Filter the `bugs` field in cpuInfo with a value that must be a regular expression").String()
|
bugsInclude = kingpin.Flag("collector.cpu.info.bugs-include", "Filter the `bugs` field in cpuInfo with a value that must be a regular expression").String()
|
||||||
|
@ -296,9 +297,11 @@ func (c *cpuCollector) updateStat(ch chan<- prometheus.Metric) error {
|
||||||
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.SoftIRQ, cpuNum, "softirq")
|
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.SoftIRQ, cpuNum, "softirq")
|
||||||
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.Steal, cpuNum, "steal")
|
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.Steal, cpuNum, "steal")
|
||||||
|
|
||||||
// Guest CPU is also accounted for in cpuStat.User and cpuStat.Nice, expose these as separate metrics.
|
if *enableCPUGuest {
|
||||||
ch <- prometheus.MustNewConstMetric(c.cpuGuest, prometheus.CounterValue, cpuStat.Guest, cpuNum, "user")
|
// Guest CPU is also accounted for in cpuStat.User and cpuStat.Nice, expose these as separate metrics.
|
||||||
ch <- prometheus.MustNewConstMetric(c.cpuGuest, prometheus.CounterValue, cpuStat.GuestNice, cpuNum, "nice")
|
ch <- prometheus.MustNewConstMetric(c.cpuGuest, prometheus.CounterValue, cpuStat.Guest, cpuNum, "user")
|
||||||
|
ch <- prometheus.MustNewConstMetric(c.cpuGuest, prometheus.CounterValue, cpuStat.GuestNice, cpuNum, "nice")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue