@@ -33,9 +33,14 @@ 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 ) / 1e6
39+ }
40+
3641// asNanosecondsToSeconds converts nanoseconds into a float64 representing seconds.
3742func asNanosecondsToSeconds (v uint64 ) float64 {
38- return float64 (v ) / float64 ( time . Second )
43+ return float64 (v ) / 1e9
3944}
4045
4146// fsValues is a helper method for assembling per-filesystem stats.
@@ -1746,6 +1751,54 @@ func NewPrometheusCollector(i infoProvider, f ContainerLabelsFunc, includedMetri
17461751 })
17471752 }
17481753
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+
17491802 return c
17501803}
17511804
0 commit comments