【问题标题】:How to disable the annotaion description from the alerts in Prometheus如何从 Prometheus 的警报中禁用注释描述
【发布时间】:2018-10-16 12:30:20
【问题描述】:

我有一个正在运行的 Prometheus,并通过 alertmanager 为我的 slack 配置了警报。我可以通过它的描述获得触发的警报。为此,我在配置文件中添加了以下内容。

      Summary: '{{ range .Alerts }}{{ .Annotations.summary }} {{ end }}'

      Description: '{{ range .Alerts }}{{ .Annotations.description }} {{ end }}'

但现在我的问题是,当警报得到解决时,正在生成相同的描述。有什么方法可以禁用已解决消息的警报描述?

【问题讨论】:

    标签: kubernetes prometheus prometheus-alertmanager


    【解决方案1】:

    您将需要使用模板检查警报的状态(无论是触发还是解决),然后根据它有条件地设置消息的内容。

    例如,我的警报的标题字段设置如下:

    {{ define "templatenamehere.title" }}
      {{- .Status | title }}
      {{- if eq .Status "firing" }} {{ .Alerts.Firing | len }}{{ else }} {{ .Alerts.Resolved | len }}{{ end }}
      {{- printf " - " }}
      {{- if gt (len .Alerts.Firing) 1 }}
      {{- .CommonLabels.alertname }}
      {{- else }}
      {{- .CommonAnnotations.summary }}
      {{- end }}
    {{- end }}
    

    【讨论】:

      猜你喜欢
      • 2019-11-01
      • 1970-01-01
      • 2015-04-30
      • 1970-01-01
      • 1970-01-01
      • 2020-12-31
      • 2019-03-01
      • 2011-08-24
      • 2018-01-12
      相关资源
      最近更新 更多