Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle NaN in Bosun?

Tags:

bosun

I have 2 metrics and try to find the difference of average value between them in percentage like 100*(m1+m2)/m1 but this obviously produces NaN if m1 turns to zero.

How should I handle this case if I don't want to alert when the metrics turn to zero?

like image 467
timurb Avatar asked Nov 21 '15 15:11

timurb


1 Answers

With bools bosun has a short-circuit like behavior. Since Bosun's expression language lacks if statements, you need to use a bool operation to see if the divisor is 0 first:

$foo = 0
$foo && 1/$foo

Since $foo is zero, the statement is "not true" so 1/$foo is not factored into the final calculation:

enter image description here

like image 117
Kyle Brandt Avatar answered Nov 01 '22 18:11

Kyle Brandt