@@ -33,9 +33,14 @@ 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 ) / 1e6
39
+ }
40
+
36
41
// asNanosecondsToSeconds converts nanoseconds into a float64 representing seconds.
37
42
func asNanosecondsToSeconds (v uint64 ) float64 {
38
- return float64 (v ) / float64 ( time . Second )
43
+ return float64 (v ) / 1e9
39
44
}
40
45
41
46
// fsValues is a helper method for assembling per-filesystem stats.
@@ -1746,6 +1751,54 @@ func NewPrometheusCollector(i infoProvider, f ContainerLabelsFunc, includedMetri
1746
1751
})
1747
1752
}
1748
1753
1754
+ if includedMetrics .Has (container .PressureMetrics ) {
1755
+ c .containerMetrics = append (c .containerMetrics , []containerMetric {
1756
+ {
1757
+ name : "container_pressure_cpu_stalled_seconds_total" ,
1758
+ help : "Total time duration no tasks in the container could make progress due to CPU congestion." ,
1759
+ valueType : prometheus .CounterValue ,
1760
+ getValues : func (s * info.ContainerStats ) metricValues {
1761
+ return metricValues {{value : asMicrosecondsToSeconds (s .Cpu .PSI .Full .Total ), timestamp : s .Timestamp }}
1762
+ },
1763
+ }, {
1764
+ name : "container_pressure_cpu_waiting_seconds_total" ,
1765
+ help : "Total time duration tasks in the container have waited due to CPU congestion." ,
1766
+ valueType : prometheus .CounterValue ,
1767
+ getValues : func (s * info.ContainerStats ) metricValues {
1768
+ return metricValues {{value : asMicrosecondsToSeconds (s .Cpu .PSI .Some .Total ), timestamp : s .Timestamp }}
1769
+ },
1770
+ }, {
1771
+ name : "container_pressure_memory_stalled_seconds_total" ,
1772
+ help : "Total time duration no tasks in the container could make progress due to memory congestion." ,
1773
+ valueType : prometheus .CounterValue ,
1774
+ getValues : func (s * info.ContainerStats ) metricValues {
1775
+ return metricValues {{value : asMicrosecondsToSeconds (s .Memory .PSI .Full .Total ), timestamp : s .Timestamp }}
1776
+ },
1777
+ }, {
1778
+ name : "container_pressure_memory_waiting_seconds_total" ,
1779
+ help : "Total time duration tasks in the container have waited due to memory congestion." ,
1780
+ valueType : prometheus .CounterValue ,
1781
+ getValues : func (s * info.ContainerStats ) metricValues {
1782
+ return metricValues {{value : asMicrosecondsToSeconds (s .Memory .PSI .Some .Total ), timestamp : s .Timestamp }}
1783
+ },
1784
+ }, {
1785
+ name : "container_pressure_io_stalled_seconds_total" ,
1786
+ help : "Total time duration no tasks in the container could make progress due to IO congestion." ,
1787
+ valueType : prometheus .CounterValue ,
1788
+ getValues : func (s * info.ContainerStats ) metricValues {
1789
+ return metricValues {{value : asMicrosecondsToSeconds (s .DiskIo .PSI .Full .Total ), timestamp : s .Timestamp }}
1790
+ },
1791
+ }, {
1792
+ name : "container_pressure_io_waiting_seconds_total" ,
1793
+ help : "Total time duration tasks in the container have waited due to IO congestion." ,
1794
+ valueType : prometheus .CounterValue ,
1795
+ getValues : func (s * info.ContainerStats ) metricValues {
1796
+ return metricValues {{value : asMicrosecondsToSeconds (s .DiskIo .PSI .Some .Total ), timestamp : s .Timestamp }}
1797
+ },
1798
+ },
1799
+ }... )
1800
+ }
1801
+
1749
1802
return c
1750
1803
}
1751
1804
0 commit comments