2
votes

I'm trying to setup Bosun and Graphite to alert on error ratio, compiled from two different sources: API traffic and web app traffic. Here's what I have now:

$web_rate = avg(graphite("sumSeries(collectd.*.statsd.web.*.rate)", "5m", "", ""))
$api_rate = avg(graphite("sumSeries(collectd.*.statsd.api.*.rate)", "5m", "", ""))
$web_error_rate = avg(graphite("sumSeries(collectd.*.statsd.web.*.errorRate)", "5m", "", ""))
$api_error_rate = avg(graphite("sumSeries(collectd.*.statsd.api.*.errorRate)", "5m", "", "")) 

$total_rate = ungroup($web_rate) + ungroup($api_rate)
$total_error_rate = ungroup($web_error_rate) + ungroup(api_error_rate)

$error_ratio = $total_error_rate / $total_rate

Our counters don't exist in graphite until they are non-zero, so for our pre-production environment, the above fails with the following:

ungroup: requires exactly one group

When I look in the expression browser, the graphite(...) call is returning, as expected, an empty set but the result of avg(graphite(...)) displays nothing.

Does anyone know how to handle this?

1

1 Answers

2
votes

In case there is no data in Graphite for the metric and the specified timeframe, it will return NaN, which is nothing.

If you try to ungroup NaN, you will get the following error:

ungroup: requires exactly one group

Use nv function to protect yourself from this error. Nv function will replace possible NaN with a specified value:

nv($result, 0)

Now you can safely ungroup:

ungroup(nv($result, 0))