@@ -26,12 +26,13 @@ import (
2626)
2727
2828const (
29- nodeEnergyStatMetric = "node_energy_stat"
30- podEnergyStatMetric = "pod_energy_stat"
31- nodeEnergyMetric = "node_hwmon_energy_joule_total"
32- freqMetric = "node_cpu_scaling_frequency_hertz"
33- pkgEnergyMetric = "node_package_energy_millijoule"
34- perCPUStatMetric = "pod_cpu_cpu_time_us"
29+ nodeEnergyStatMetric = "node_energy_stat"
30+ podEnergyStatMetric = "pod_energy_stat"
31+ nodeEnergyMetric = "node_hwmon_energy_joule_total"
32+ freqMetric = "node_cpu_scaling_frequency_hertz"
33+ pkgEnergyMetric = "node_package_energy_millijoule"
34+ perCPUStatMetric = "pod_cpu_cpu_time_us"
35+ podCPUInstructionMetric = "pod_cpu_instructions"
3536
3637 podLabelPrefix = "pod_"
3738 nodeLabelPrefix = "node_"
@@ -265,6 +266,18 @@ func (c *Collector) getPodDetailedCPUTimeDescription() *prometheus.Desc {
265266 )
266267}
267268
269+ func (c * Collector ) getPodInstructionDescription () * prometheus.Desc {
270+ return prometheus .NewDesc (
271+ podCPUInstructionMetric ,
272+ "Recorded CPU instructions during the period." ,
273+ []string {
274+ "pod_name" ,
275+ "pod_namespace" ,
276+ },
277+ nil ,
278+ )
279+ }
280+
268281func (c * Collector ) Describe (ch chan <- * prometheus.Desc ) {
269282 lock .Lock ()
270283 defer lock .Unlock ()
@@ -284,6 +297,9 @@ func (c *Collector) Describe(ch chan<- *prometheus.Desc) {
284297 ch <- c .getFreqDescription ()
285298 ch <- c .getPackageEnergyDescription ()
286299 ch <- c .getPodDetailedCPUTimeDescription ()
300+ if cpuInstrCounterEnabled {
301+ ch <- c .getPodInstructionDescription ()
302+ }
287303}
288304
289305func (c * Collector ) Collect (ch chan <- prometheus.Metric ) {
@@ -390,6 +406,16 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) {
390406 )
391407 ch <- metric
392408 }
409+ if cpuInstrCounterEnabled &&
410+ v .CounterStats [attacher .CPUInstructionLabel ] != nil {
411+ // all curr pod cpu instructions
412+ edesc = prometheus .MustNewConstMetric (
413+ c .getPodInstructionDescription (),
414+ prometheus .GaugeValue ,
415+ float64 (v .CounterStats [attacher .CPUInstructionLabel ].Curr ),
416+ v .PodName , v .Namespace )
417+ ch <- edesc
418+ }
393419 }
394420
395421 // de_node_energy and desc_node_energy give indexable values for total energy consumptions of a node
0 commit comments