collect flag_info and bug_info only for one core (#2156)

Signed-off-by: binjip978 <binjip978@gmail.com>
This commit is contained in:
Sergei Semenchuk 2021-09-28 08:44:03 +03:00 committed by GitHub
parent 2b490d645e
commit 5de46c6bac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -77,12 +77,12 @@ func NewCPUCollector(logger log.Logger) (Collector, error) {
),
cpuFlagsInfo: prometheus.NewDesc(
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "flag_info"),
"The `flags` field of CPU information from /proc/cpuinfo.",
"The `flags` field of CPU information from /proc/cpuinfo taken from the first core.",
[]string{"flag"}, nil,
),
cpuBugsInfo: prometheus.NewDesc(
prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "bug_info"),
"The `bugs` field of CPU information from /proc/cpuinfo.",
"The `bugs` field of CPU information from /proc/cpuinfo taken from the first core.",
[]string{"bug"}, nil,
),
cpuGuest: prometheus.NewDesc(
@ -167,7 +167,10 @@ func (c *cpuCollector) updateInfo(ch chan<- prometheus.Metric) error {
cpu.Microcode,
cpu.Stepping,
cpu.CacheSize)
}
if len(info) != 0 {
cpu := info[0]
if err := updateFieldInfo(cpu.Flags, c.cpuFlagsIncludeRegexp, c.cpuFlagsInfo, ch); err != nil {
return err
}
@ -175,6 +178,7 @@ func (c *cpuCollector) updateInfo(ch chan<- prometheus.Metric) error {
return err
}
}
return nil
}

View File

@ -247,7 +247,7 @@ node_cooling_device_cur_state{name="0",type="Processor"} 0
# HELP node_cooling_device_max_state Maximum throttle state of the cooling device
# TYPE node_cooling_device_max_state gauge
node_cooling_device_max_state{name="0",type="Processor"} 3
# HELP node_cpu_bug_info The `bugs` field of CPU information from /proc/cpuinfo.
# HELP node_cpu_bug_info The `bugs` field of CPU information from /proc/cpuinfo taken from the first core.
# TYPE node_cpu_bug_info gauge
node_cpu_bug_info{bug="cpu_meltdown"} 1
node_cpu_bug_info{bug="mds"} 1
@ -259,7 +259,7 @@ node_cpu_core_throttles_total{core="0",package="0"} 5
node_cpu_core_throttles_total{core="0",package="1"} 0
node_cpu_core_throttles_total{core="1",package="0"} 0
node_cpu_core_throttles_total{core="1",package="1"} 9
# HELP node_cpu_flag_info The `flags` field of CPU information from /proc/cpuinfo.
# HELP node_cpu_flag_info The `flags` field of CPU information from /proc/cpuinfo taken from the first core.
# TYPE node_cpu_flag_info gauge
node_cpu_flag_info{flag="aes"} 1
node_cpu_flag_info{flag="avx"} 1