@@ -33,6 +33,11 @@ import (
33
33
// asFloat64 converts a uint64 into a float64.
34
34
func asFloat64 (v uint64 ) float64 { return float64 (v ) }
35
35
36
+ // asMicrosecondsToSeconds converts nanoseconds into a float64 representing seconds.
37
+ func asMicrosecondsToSeconds (v uint64 ) float64 {
38
+ return float64 (v ) / float64 (time .Millisecond )
39
+ }
40
+
36
41
// asNanosecondsToSeconds converts nanoseconds into a float64 representing seconds.
37
42
func asNanosecondsToSeconds (v uint64 ) float64 {
38
43
return float64 (v ) / float64 (time .Second )
@@ -1749,46 +1754,39 @@ func NewPrometheusCollector(i infoProvider, f ContainerLabelsFunc, includedMetri
1749
1754
if includedMetrics .Has (container .PressureMetrics ) {
1750
1755
c .containerMetrics = append (c .containerMetrics , []containerMetric {
1751
1756
{
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
- }, {
1759
1757
name : "container_pressure_cpu_waiting_seconds_total" ,
1760
1758
help : "Total time duration tasks in the container have waited due to CPU congestion." ,
1761
1759
valueType : prometheus .CounterValue ,
1762
1760
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 }}
1764
1762
},
1765
1763
}, {
1766
1764
name : "container_pressure_memory_stalled_seconds_total" ,
1767
1765
help : "Total time duration no tasks in the container could make progress due to memory congestion." ,
1768
1766
valueType : prometheus .CounterValue ,
1769
1767
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 }}
1771
1769
},
1772
1770
}, {
1773
1771
name : "container_pressure_memory_waiting_seconds_total" ,
1774
1772
help : "Total time duration tasks in the container have waited due to memory congestion." ,
1775
1773
valueType : prometheus .CounterValue ,
1776
1774
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 }}
1778
1776
},
1779
1777
}, {
1780
1778
name : "container_pressure_io_stalled_seconds_total" ,
1781
1779
help : "Total time duration no tasks in the container could make progress due to IO congestion." ,
1782
1780
valueType : prometheus .CounterValue ,
1783
1781
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 }}
1785
1783
},
1786
1784
}, {
1787
1785
name : "container_pressure_io_waiting_seconds_total" ,
1788
1786
help : "Total time duration tasks in the container have waited due to IO congestion." ,
1789
1787
valueType : prometheus .CounterValue ,
1790
1788
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 }}
1792
1790
},
1793
1791
},
1794
1792
}... )
0 commit comments