通过 AlertManager 进行 Slack 通知 - Slack 桌面应用程序中缺少一些按钮

问题描述 投票:0回答:1

我为 AlertManager 配置了 Slack 通知:

receivers:
  - name: "team:slack"
    slack_configs:
      - channel: "alerts" 
        icon_emoji: !unsafe '{{ template "slack.my.icon" . }}'
        color: !unsafe '{{ template "slack.my.color" . }}'
        title: !unsafe '{{ template "slack.my.title" . }}'
        title_link: !unsafe '{{ template "slack.my.link" . }}'
        text: !unsafe '{{ template "slack.my.text" . }} (notify <!subteam^S04*****>)'
        send_resolved: true
        api_url: "https://hooks.slack.com/services/***/***/*****"
        actions:
          - type: button
            text: "Runbook :green_book:"
            url: !unsafe '{{ template "slack.my.runbook_url" . }}'
          - type: button
            text: "View :mag:"
            url: !unsafe '{{ template "slack.my.alert_source_url" . }}'
          - type: button
            text: "Dashboard :chart_with_upwards_trend:"
            url: !unsafe '{{ template "slack.my.dashboard_url" . }}'
          - type: button
            text: "Mute :no_bell:"
            url: !unsafe '{{ template "__alert_silence_link" . }}'
          - type: button
            text: "Docs :books:"
            url: !unsafe '{{ template "slack.my.doc_url" . }}'

奇怪的是,当在 Slack 移动应用程序中收到通知时 - 我看到所有 5 个按钮,但在 Slack 桌面应用程序中时 - 我只看到前 3 个按钮,没有静音和文档按钮。

这是我的越野车按钮自定义模板的一部分:

{{ define "__alert_silence_link" -}}
    {{ .ExternalURL }}/#/silences/new?filter=%7B
    {{- range .CommonLabels.SortedPairs -}}
        {{- if ne .Name "alertname" -}}
            {{- .Name }}%3D%22{{- .Value | urlquery -}}%22%2C%20
        {{- end -}}
    {{- end -}}
    alertname%3D%22{{- .CommonLabels.alertname -}}%22%7D
{{- end }}

{{ define "slack.my.doc_url" }}
    {{- if ne (index .Alerts 0).Annotations.doc_url "" -}}
        {{- (index .Alerts 0).Annotations.doc_url -}}
    {{- end -}}
{{- end }}

有什么办法可以解决吗?

slack prometheus-alertmanager
1个回答
0
投票

您可以尝试为每个按钮添加名称属性

© www.soinside.com 2019 - 2024. All rights reserved.