Bosun Using Merge to Combine Series


If you want to graph two series on one graph, you can use the Merge function. This can also be combined with the Series function to manipulate the Y axis (like forcing it to start at zero).

template graph.template {
    subject = ...

    body = `{{template "header" .}}

    <strong>Graph With Merge+Series so Y Axis Starts At Zero</strong>
    <div>{{.Graph .Alert.Vars.graph_merged .Alert.Vars.graph_unit}}</div>

alert os.low.memory {
    template = graph.template
    $graph_time = "1d"
    $graph_host = q("avg:300s-avg:os.mem.percent_free{host=myhost}", $graph_time, "")
    $graph_unit = Notice the Y axis always starts at zero now
    $graph_series = series("value=zero", epoch()-d($graph_time), 0, epoch(),0)
    $graph_merged = merge($graph_host,$graph_series)