0

I'm trying to migrate Prometheus Alertmanager alerting from using slack_configs (ref1) into the webex_configs (ref2). Is there any possibility to adjust the message sent to Webex with structure used in "old" slack_configs? Following structure is needed:

<Title composed of .Status + text eg 'Event Notification'>
Alert - < Annotations.Summary + Labes.severity >
Message - < Annotations.message >
Graph - < GeneralURL >, Dashboard < Annotations.dashboardurl >
Details ( composed of Labels.SortedPairs (Name + Value))

I know this is possible via webhook_configs + proxy, however If there's possibility to create this without the need of proxy, that would be ideal.
- ref1

- name: alerts
        slack_configs:
          - api_url: https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
            channel: '#XXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
            http_config:
              proxy_url: XXXXXXXXXXX
            text: |-
              {{ `{{ range .Alerts }}
                *Alert:* {{ .Annotations.summary }} - {{ .Labels.severity }}
                *Message:* {{ .Annotations.message }}
                *Graph:* <{{ .GeneratorURL }}|:chart_with_upwards_trend:> *Dashboard:* <{{ .Annotations.dashboardurl }}|:bar_chart:>
                *Details:*
                {{ range .Labels.SortedPairs }} • *{{ .Name }}:* {{ .Value }}
                {{ end }}
              {{ end }}` }}
            title: |-
              {{ `[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] Notification` }}

- ref2

- name: alerts_webex
        webex_configs:
          - api_url: 'https://webexapis.com/v1/messages'
            room_id: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
            send_resolved: false
            http_config:
              proxy_url: XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
              authorization:
                type: 'Bearer'
                credentials: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
            message: |-
              {{ `{{ range .Alerts }}
                "**{{ .Status }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }} Notification**\n\n*Severity:* {{ .Labels.severity }}\n**Alert:** {{ .Annotations.summary }}\n**Message:** {{ .Annotations.message }}\n**Graph:** [Graph URL]({{ .GeneratorURL }})\n**Dashboard:** [Dashboard URL]({{ .Annotations.dashboardurl }})\n**Details:**\n{{ range .Labels.SortedPairs }} • **{{ .Name }}:** {{ .Value }}\n{{ end }}"
              {{ end }}` }}

Note: Alerts from webex_configs don't arrive at any point, without any errors produced & connection working fine. slack_configs fully functional, even when using both configurations together with routes & continue: true for receivers, only slack receives the alert.

7
  • This feels like two completely unrelated problems. 1. Messages are not sent to webex. and 2. You don't know how to format message to webex. First one is off-topic for SO, since it is not development related. I suggest you checking out logs, and rechecking if all configurations for webex are correct. And if needed, asking a separate question (omitting whole ordeal about templates, and using simple dummy message instead) on Super User or DevOps.
    – markalex
    Commented May 10 at 13:09
  • And once that is solved (and if you stil have troubles with template to that point) asking question dedicated to templates.
    – markalex
    Commented May 10 at 13:10
  • @markalex you are correct, didn't put this as straightforward as intended. The problem is the mix of two, because 1. Messages are not sent to webex but 2. this is 99% caused by template. So in this situation, it is problem of the template. I have created simple condition, when there are no alerts, message would be sent to Webex with super simple text "No Alerts". This would work, the messages would arrive in the end, however they get lost or are not generated or I'm not sure what, when I try to use template mentioned above.
    – ddano
    Commented May 10 at 13:53
  • Hmm. I recall templates being sent without substitution if they are wrong, but I guess it might depend. Still very much recommend checking logs. And if there is nothing interesting there, starting with simple dummy message and increasing complexity of template as it goes.
    – markalex
    Commented May 10 at 15:37
  • You can trigger alert from outside to speedup tests: stackoverflow.com/a/75807372/21363224
    – markalex
    Commented May 10 at 15:38

0