Skip to content

Commit 78d25e3

Browse files
committed
CA-411679: Runstate metrics return data over 100%
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. Signed-off-by: Bengang Yuan <[email protected]>
1 parent 3f21dea commit 78d25e3

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
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

0 commit comments

Comments
 (0)