mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-23 20:36:21 +01:00
Add new node_cpu_frequency_hertz metric
Revert changes to node_cpu_info and add new node_cpu_frequency_hertz metric for measuring CPU frequency from /proc/cpuinfo Signed-off-by: John Kordich <jkordich@gmail.com>
This commit is contained in:
parent
e84c278107
commit
933b1c1797
@ -38,6 +38,7 @@ type cpuCollector struct {
|
|||||||
fs procfs.FS
|
fs procfs.FS
|
||||||
cpu *prometheus.Desc
|
cpu *prometheus.Desc
|
||||||
cpuInfo *prometheus.Desc
|
cpuInfo *prometheus.Desc
|
||||||
|
cpuFrequencyHz *prometheus.Desc
|
||||||
cpuFlagsInfo *prometheus.Desc
|
cpuFlagsInfo *prometheus.Desc
|
||||||
cpuBugsInfo *prometheus.Desc
|
cpuBugsInfo *prometheus.Desc
|
||||||
cpuGuest *prometheus.Desc
|
cpuGuest *prometheus.Desc
|
||||||
@ -96,6 +97,11 @@ func NewCPUCollector(logger log.Logger) (Collector, error) {
|
|||||||
"CPU information from /proc/cpuinfo.",
|
"CPU information from /proc/cpuinfo.",
|
||||||
[]string{"package", "core", "cpu", "vendor", "family", "model", "model_name", "microcode", "stepping", "cachesize"}, nil,
|
[]string{"package", "core", "cpu", "vendor", "family", "model", "model_name", "microcode", "stepping", "cachesize"}, nil,
|
||||||
),
|
),
|
||||||
|
cpuFrequencyHz: prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_hertz"),
|
||||||
|
"CPU frequency in hertz from /proc/cpuinfo.",
|
||||||
|
[]string{"package", "core", "cpu"}, nil,
|
||||||
|
),
|
||||||
cpuFlagsInfo: prometheus.NewDesc(
|
cpuFlagsInfo: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "flag_info"),
|
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "flag_info"),
|
||||||
"The `flags` field of CPU information from /proc/cpuinfo taken from the first core.",
|
"The `flags` field of CPU information from /proc/cpuinfo taken from the first core.",
|
||||||
@ -184,7 +190,7 @@ func (c *cpuCollector) updateInfo(ch chan<- prometheus.Metric) error {
|
|||||||
for _, cpu := range info {
|
for _, cpu := range info {
|
||||||
ch <- prometheus.MustNewConstMetric(c.cpuInfo,
|
ch <- prometheus.MustNewConstMetric(c.cpuInfo,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
cpu.CPUMHz,
|
1,
|
||||||
cpu.PhysicalID,
|
cpu.PhysicalID,
|
||||||
cpu.CoreID,
|
cpu.CoreID,
|
||||||
strconv.Itoa(int(cpu.Processor)),
|
strconv.Itoa(int(cpu.Processor)),
|
||||||
@ -197,6 +203,20 @@ func (c *cpuCollector) updateInfo(ch chan<- prometheus.Metric) error {
|
|||||||
cpu.CacheSize)
|
cpu.CacheSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cpuFreqEnabled, ok := collectorState["cpufreq"]
|
||||||
|
if !ok || cpuFreqEnabled == nil {
|
||||||
|
level.Warn(c.logger).Log("cpufreq key missing or nil value in collectorState map", err)
|
||||||
|
} else if !*cpuFreqEnabled {
|
||||||
|
for _, cpu := range info {
|
||||||
|
ch <- prometheus.MustNewConstMetric(c.cpuFrequencyHz,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
cpu.CPUMHz*1e6,
|
||||||
|
cpu.PhysicalID,
|
||||||
|
cpu.CoreID,
|
||||||
|
strconv.Itoa(int(cpu.Processor)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if len(info) != 0 {
|
if len(info) != 0 {
|
||||||
cpu := info[0]
|
cpu := info[0]
|
||||||
if err := updateFieldInfo(cpu.Flags, c.cpuFlagsIncludeRegexp, c.cpuFlagsInfo, ch); err != nil {
|
if err := updateFieldInfo(cpu.Flags, c.cpuFlagsIncludeRegexp, c.cpuFlagsInfo, ch); err != nil {
|
||||||
|
@ -311,14 +311,14 @@ node_cpu_guest_seconds_total{cpu="7",mode="nice"} 0.08
|
|||||||
node_cpu_guest_seconds_total{cpu="7",mode="user"} 0.09
|
node_cpu_guest_seconds_total{cpu="7",mode="user"} 0.09
|
||||||
# HELP node_cpu_info CPU information from /proc/cpuinfo.
|
# HELP node_cpu_info CPU information from /proc/cpuinfo.
|
||||||
# TYPE node_cpu_info gauge
|
# TYPE node_cpu_info gauge
|
||||||
node_cpu_info{cachesize="8192 KB",core="0",cpu="0",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 799.998
|
node_cpu_info{cachesize="8192 KB",core="0",cpu="0",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1
|
||||||
node_cpu_info{cachesize="8192 KB",core="0",cpu="4",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 799.989
|
node_cpu_info{cachesize="8192 KB",core="0",cpu="4",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1
|
||||||
node_cpu_info{cachesize="8192 KB",core="1",cpu="1",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.037
|
node_cpu_info{cachesize="8192 KB",core="1",cpu="1",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1
|
||||||
node_cpu_info{cachesize="8192 KB",core="1",cpu="5",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.083
|
node_cpu_info{cachesize="8192 KB",core="1",cpu="5",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1
|
||||||
node_cpu_info{cachesize="8192 KB",core="2",cpu="2",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.01
|
node_cpu_info{cachesize="8192 KB",core="2",cpu="2",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1
|
||||||
node_cpu_info{cachesize="8192 KB",core="2",cpu="6",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.017
|
node_cpu_info{cachesize="8192 KB",core="2",cpu="6",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1
|
||||||
node_cpu_info{cachesize="8192 KB",core="3",cpu="3",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.028
|
node_cpu_info{cachesize="8192 KB",core="3",cpu="3",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1
|
||||||
node_cpu_info{cachesize="8192 KB",core="3",cpu="7",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.03
|
node_cpu_info{cachesize="8192 KB",core="3",cpu="7",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1
|
||||||
# HELP node_cpu_isolated Whether each core is isolated, information from /sys/devices/system/cpu/isolated.
|
# HELP node_cpu_isolated Whether each core is isolated, information from /sys/devices/system/cpu/isolated.
|
||||||
# TYPE node_cpu_isolated gauge
|
# TYPE node_cpu_isolated gauge
|
||||||
node_cpu_isolated{cpu="1"} 1
|
node_cpu_isolated{cpu="1"} 1
|
||||||
|
Loading…
Reference in New Issue
Block a user