小编Jon*_*Jon的帖子

如何格式化Bosun模板中的数字?

在Bosun模板中,是否可以将评估变量的输出格式化为较小的精度小数位?

简单示例:

template test_template{
    subject = test
    body = {{.Eval .Alert.Vars.average_runtime}} seconds
}
alert test_alert{
    template test_template
    $average_runtime = avg(q("avg:metric_name", "24h",""))
    crit = $average_runtime > 150.0
}
Run Code Online (Sandbox Code Playgroud)

结果是

190.71165892385326秒

在模板体中,这是不必要的精确.理想情况下,我希望看到:

190.71秒

bosun

7
推荐指数
1
解决办法
269
查看次数

标签 统计

bosun ×1