douyuben9434 2017-04-18 13:22
浏览 273
已采纳

Prometheus电子邮件警报以显示指标值

I have a label cs_job_time in Prometheus/Alert Manager and would like to send an email alert when a condition is met for another job. The email sends fine but is it possible to include the value of cs_job_time within the email? I can use {{$value}} for the metric in question but I would also like to print the value of cs_job_time.

I came across this but when I try

time = "{{  `cs_job_time{instance='%s', job='/'}` $labels.instance | query | first }}

or similar variants, I get the error message "Error expanding alert template CSJobAlert with data '{map[] 2123}': runtime error: invalid memory address or nil pointer dereference" source="alerting.go:199"

Is it possible to email metric values?

  • 写回答

1条回答 默认 最新

  • dounong5373 2017-04-18 13:36
    关注

    You're missing the printf there from the example:

    "{{ printf `cs_job_time{instance='%s', job='/'}` $labels.instance | query | first }}"
    

    Be careful though, if there's no results then the first will fail. It's generally best to use a range statement as that'll be resilient to that.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料