@@ -22,11 +22,12 @@ type vmStateEntry struct {
2222}
2323
2424type guestData struct {
25- cpu float64
26- mem float64
27- disk float64
28- node string
29- class string
25+ cpu float64
26+ iowait float64
27+ mem float64
28+ disk float64
29+ node string
30+ class string
3031}
3132
3233// VMMetricsCollector holds per-VM metric state for the node agent.
@@ -85,6 +86,25 @@ func NewVMMetricsCollector(meter metric.Meter, gatherer prometheus.Gatherer) *VM
8586 }),
8687 )
8788
89+ _ , _ = meter .Float64ObservableGauge (
90+ "imp_vm_guest_cpu_iowait_ratio" ,
91+ metric .WithDescription ("Guest VM CPU iowait ratio (0.0–1.0)." ),
92+ metric .WithFloat64Callback (func (_ context.Context , o metric.Float64Observer ) error {
93+ c .mu .RLock ()
94+ defer c .mu .RUnlock ()
95+ for key , d := range c .guestMetrics {
96+ ns , name := splitKey (key )
97+ o .Observe (d .iowait , metric .WithAttributes (
98+ attribute .String ("impvm" , name ),
99+ attribute .String ("namespace" , ns ),
100+ attribute .String ("node" , d .node ),
101+ attribute .String ("impvmclass" , d .class ),
102+ ))
103+ }
104+ return nil
105+ }),
106+ )
107+
88108 _ , _ = meter .Float64ObservableGauge (
89109 "imp_vm_guest_memory_used_bytes" ,
90110 metric .WithDescription ("Guest VM memory used bytes." ),
@@ -134,15 +154,16 @@ func (c *VMMetricsCollector) SetVMState(key, state, node string) {
134154}
135155
136156// SetGuestMetrics updates guest agent metrics for a VM.
137- func (c * VMMetricsCollector ) SetGuestMetrics (key , node , impvmclass string , cpu float64 , mem , disk int64 ) {
157+ func (c * VMMetricsCollector ) SetGuestMetrics (key , node , impvmclass string , cpu , iowait float64 , mem , disk int64 ) {
138158 c .mu .Lock ()
139159 defer c .mu .Unlock ()
140160 c .guestMetrics [key ] = & guestData {
141- cpu : cpu ,
142- mem : float64 (mem ),
143- disk : float64 (disk ),
144- node : node ,
145- class : impvmclass ,
161+ cpu : cpu ,
162+ iowait : iowait ,
163+ mem : float64 (mem ),
164+ disk : float64 (disk ),
165+ node : node ,
166+ class : impvmclass ,
146167 }
147168}
148169
0 commit comments