Skip to content

Commit 7ad7f88

Browse files
authored
CA-411679: Runstate metrics return data over 100% (#6493)
To handle deviations in CPU rates, Derive values exceeding the maximum by up to 5% are capped at the maximum; others are marked as unknown. This logic is specific to Derive data sources because they represent rates derived from differences over time, which can occasionally exceed expected bounds due to measurement inaccuracies.
2 parents 4bfdf7e + 78d25e3 commit 7ad7f88

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

ocaml/libs/xapi-rrd/lib/rrd.ml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,23 @@ let ds_update rrd timestamp valuesandtransforms new_rrd =
468468
in
469469
(* Apply the transform after the raw value has been calculated *)
470470
let raw = apply_transform_function transform raw in
471+
471472
(* Make sure the values are not out of bounds after all the processing *)
472-
if raw < ds.ds_min || raw > ds.ds_max then
473-
(i, nan)
474-
else
475-
(i, raw)
473+
match (ds.ds_ty, raw) with
474+
| Derive, _ when raw > ds.ds_max && raw < ds.ds_max *. (1. +. 0.05)
475+
->
476+
(* CA-411679: To handle deviations in CPU rates, Derive values
477+
exceeding the maximum by up to 5% are capped at the maximum;
478+
others are marked as unknown. This logic is specific to
479+
Derive data sources because they represent rates derived
480+
from differences over time, which can occasionally exceed
481+
expected bounds due to measurement inaccuracies. *)
482+
(i, ds.ds_max)
483+
| (Derive | Gauge | Absolute), _
484+
when raw < ds.ds_min || raw > ds.ds_max ->
485+
(i, nan)
486+
| (Derive | Gauge | Absolute), _ ->
487+
(i, raw)
476488
)
477489
valuesandtransforms
478490
in

ocaml/xcp-rrdd/bin/rrdp-cpu/rrdp_cpu.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ let dss_vcpus xc doms =
6363
, Ds.ds_make ~name:"runstate_fullrun" ~units:"(fraction)"
6464
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time0 /. 1.0e9))
6565
~description:"Fraction of time that all VCPUs are running"
66-
~ty:Rrd.Derive ~default:false ~min:0.0 ()
66+
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
6767
)
6868
:: ( Rrd.VM uuid
6969
, Ds.ds_make ~name:"runstate_full_contention" ~units:"(fraction)"
7070
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time1 /. 1.0e9))
7171
~description:
7272
"Fraction of time that all VCPUs are runnable (i.e., \
7373
waiting for CPU)"
74-
~ty:Rrd.Derive ~default:false ~min:0.0 ()
74+
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
7575
)
7676
:: ( Rrd.VM uuid
7777
, Ds.ds_make ~name:"runstate_concurrency_hazard"
@@ -80,22 +80,22 @@ let dss_vcpus xc doms =
8080
~description:
8181
"Fraction of time that some VCPUs are running and some are \
8282
runnable"
83-
~ty:Rrd.Derive ~default:false ~min:0.0 ()
83+
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
8484
)
8585
:: ( Rrd.VM uuid
8686
, Ds.ds_make ~name:"runstate_blocked" ~units:"(fraction)"
8787
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time3 /. 1.0e9))
8888
~description:
8989
"Fraction of time that all VCPUs are blocked or offline"
90-
~ty:Rrd.Derive ~default:false ~min:0.0 ()
90+
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
9191
)
9292
:: ( Rrd.VM uuid
9393
, Ds.ds_make ~name:"runstate_partial_run" ~units:"(fraction)"
9494
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time4 /. 1.0e9))
9595
~description:
9696
"Fraction of time that some VCPUs are running, and some are \
9797
blocked"
98-
~ty:Rrd.Derive ~default:false ~min:0.0 ()
98+
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
9999
)
100100
:: ( Rrd.VM uuid
101101
, Ds.ds_make ~name:"runstate_partial_contention"
@@ -104,7 +104,7 @@ let dss_vcpus xc doms =
104104
~description:
105105
"Fraction of time that some VCPUs are runnable and some are \
106106
blocked"
107-
~ty:Rrd.Derive ~default:false ~min:0.0 ()
107+
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
108108
)
109109
:: ( Rrd.VM uuid
110110
, Ds.ds_make

0 commit comments

Comments
 (0)