使用警报变量的图表
使用 .Graph 会将结果过滤为仅包含与警报标记集匹配的结果。例如,os.low.memory {host = ny-web01}的警报只包含 host = ny-web01 标签的系列。如果多个系列匹配,则仅使用第一个匹配结果。
template graph.template {
subject = ...
body = `{{template "header" .}}
<strong>Graph</strong>
<div>{{.Graph .Alert.Vars.graph}}</div>
<strong>Graph With Y Axis Label Literal</strong>
<div>{{.Graph .Alert.Vars.graph "Free Memory in GB"}}</div>
<strong>Graph With Y Axis Label From Variable</strong>
<div>{{.Graph .Alert.Vars.graph .Alert.Vars.graph_unit}}</div>
`
}
alert os.low.memory {
template = graph.template
...
$graph = q("avg:300s-avg:os.mem.percent_free{host=$host}", "1d", "")
$graph_unit = Percent Free Memory (Including Buffers and Cache)
...
}