您是否尝试过设置帖子通知的正文?在测试上面列出的 curl 命令时,我相信它仍在使用 content-type application/x-www-form-urlencoded,这是通知的默认设置。我认为这会起作用:
notification influx{
post = http://localhost:8086/write?db=mydb
body = cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000
}
如果您需要自定义值,则必须让主题呈现正确的文本并使用 {{.}} 将其注入到发布通知中。
template influx.testing {
subject = `
{{ if .IsEmail }}
normal email template details here
{{else}}
{{.Group.host}} value={{.Eval .Alert.Vars.value_variable | printf "%.2f"}} {{.State.Touched.UnixNano}}
{{end}}`
body = `email body details here`
}
notification influx{
post = http://localhost:8086/write?db=mydb
body = cpu_load_short,region=us-west,host={{.}}
}
帖子主题将server01 value=0.64 1434055562000000000
假设 $value_variable 是一个返回 0.64 值的表达式。
另请注意,在最后一次触摸的规则页面中进行测试时始终为 0,因此时间戳将为 -6795364578871345152,但对于实际警报,它应该可以正常工作。