@@ -33,6 +33,11 @@ import (
3333// asFloat64 converts a uint64 into a float64.
3434func asFloat64 (v uint64 ) float64 { return float64 (v ) }
3535
36+ // asMicrosecondsToSeconds converts nanoseconds into a float64 representing seconds.
37+ func asMicrosecondsToSeconds (v uint64 ) float64 {
38+ return float64 (v ) / float64 (time .Millisecond )
39+ }
40+
3641// asNanosecondsToSeconds converts nanoseconds into a float64 representing seconds.
3742func asNanosecondsToSeconds (v uint64 ) float64 {
3843 return float64 (v ) / float64 (time .Second )
@@ -1749,46 +1754,39 @@ func NewPrometheusCollector(i infoProvider, f ContainerLabelsFunc, includedMetri
17491754 if includedMetrics .Has (container .PressureMetrics ) {
17501755 c .containerMetrics = append (c .containerMetrics , []containerMetric {
17511756 {
1752- name : "container_pressure_cpu_stalled_seconds_total" ,
1753- help : "Total time duration no tasks in the container could make progress due to CPU congestion." ,
1754- valueType : prometheus .CounterValue ,
1755- getValues : func (s * info.ContainerStats ) metricValues {
1756- return metricValues {{value : float64 (s .Cpu .PSI .Full .Total ) / 1000.0 / 1000.0 , timestamp : s .Timestamp }}
1757- },
1758- }, {
17591757 name : "container_pressure_cpu_waiting_seconds_total" ,
17601758 help : "Total time duration tasks in the container have waited due to CPU congestion." ,
17611759 valueType : prometheus .CounterValue ,
17621760 getValues : func (s * info.ContainerStats ) metricValues {
1763- return metricValues {{value : float64 (s .Cpu .PSI .Some .Total ) / 1000.0 / 1000.0 , timestamp : s .Timestamp }}
1761+ return metricValues {{value : asMicrosecondsToSeconds (s .Cpu .PSI .Some .Total ), timestamp : s .Timestamp }}
17641762 },
17651763 }, {
17661764 name : "container_pressure_memory_stalled_seconds_total" ,
17671765 help : "Total time duration no tasks in the container could make progress due to memory congestion." ,
17681766 valueType : prometheus .CounterValue ,
17691767 getValues : func (s * info.ContainerStats ) metricValues {
1770- return metricValues {{value : float64 (s .Memory .PSI .Full .Total ) / 1000.0 / 1000.0 , timestamp : s .Timestamp }}
1768+ return metricValues {{value : asMicrosecondsToSeconds (s .Memory .PSI .Full .Total ), timestamp : s .Timestamp }}
17711769 },
17721770 }, {
17731771 name : "container_pressure_memory_waiting_seconds_total" ,
17741772 help : "Total time duration tasks in the container have waited due to memory congestion." ,
17751773 valueType : prometheus .CounterValue ,
17761774 getValues : func (s * info.ContainerStats ) metricValues {
1777- return metricValues {{value : float64 (s .Memory .PSI .Some .Total ) / 1000.0 / 1000.0 , timestamp : s .Timestamp }}
1775+ return metricValues {{value : asMicrosecondsToSeconds (s .Memory .PSI .Some .Total ), timestamp : s .Timestamp }}
17781776 },
17791777 }, {
17801778 name : "container_pressure_io_stalled_seconds_total" ,
17811779 help : "Total time duration no tasks in the container could make progress due to IO congestion." ,
17821780 valueType : prometheus .CounterValue ,
17831781 getValues : func (s * info.ContainerStats ) metricValues {
1784- return metricValues {{value : float64 (s .DiskIo .PSI .Full .Total ) / 1000.0 / 1000.0 , timestamp : s .Timestamp }}
1782+ return metricValues {{value : asMicrosecondsToSeconds (s .DiskIo .PSI .Full .Total ), timestamp : s .Timestamp }}
17851783 },
17861784 }, {
17871785 name : "container_pressure_io_waiting_seconds_total" ,
17881786 help : "Total time duration tasks in the container have waited due to IO congestion." ,
17891787 valueType : prometheus .CounterValue ,
17901788 getValues : func (s * info.ContainerStats ) metricValues {
1791- return metricValues {{value : float64 (s .DiskIo .PSI .Some .Total ) / 1000.0 / 1000.0 , timestamp : s .Timestamp }}
1789+ return metricValues {{value : asMicrosecondsToSeconds (s .DiskIo .PSI .Some .Total ), timestamp : s .Timestamp }}
17921790 },
17931791 },
17941792 }... )
0 commit comments