stateDuration and sigma


Hi I have the following tick:
dbrp “statsd”.“shortterm”

        .message('{{ .Level}}: {{ .Name }}/{{ index .Tags "host" }} has high cpu load: {{ index .Fields "mean" }}')
        .warn(lambda: sigma("mean") > 2.0)
        .crit(lambda: sigma("mean") > 3.0)

How would i go about using state duration with this tick i.e. i want alert when sigma("mean) > 2.0 for 5 minutes.

thanks !


I think you need to evaluate sigma independently, then track its duration duration over the limit and then alert when that duration is over 5 minutes:

|eval(lambda: sigma(“mean”))
|stateDuration(lambda: “sig” > 2.0)
|stateDuration(lambda: “sig” > 3.0)
.warn(lambda: “sig_gt_2_min” > 5)
.crit(lambda: “sig_gt_3_min” > 5)


awesome thanks, I will give it a try.