discord - "unrecoverable error"

872 views
Skip to first unread message

Emil Fabrice Semti

unread,
Aug 30, 2022, 3:03:42 AM8/30/22
to Prometheus Users
Hi Everyone,

Seeking some help here - very new to Prometheus/Alert Manager, must add.


- log errors are similar to this:

ts=2022-08-30T06:50:59.456Z caller=dispatch.go:354 level=error component=dispatcher msg="Notify for alerts failed" num_alerts=3 err="discord/slack[0]: notify retry canceled due to unrecoverable error after 1 attempts: channel \"#prometheus\": unexpected status code 400: {\"attachments\": [\"0\"]}"

- I used this site to test the webhook

- the test - with the same parameters used in the manifest - was successful (see attached screenshot), therefore I think my settings are correct.

Any suggestions what am I missing please?

Thanks,
F.
Screenshot from 2022-08-30 07-53-54.png

Brian Candler

unread,
Aug 30, 2022, 6:10:59 AM8/30/22
to Prometheus Users
You haven't said what you've configured as the receiver (target) of the webhook.

Whatever it is, it is responding with a 400 error, which means that the request being sent is invalid.

The format of the webhook payload sent by Alertmanager is *fixed*.Ā  For an example see:

This will be different to what a "Discord webhook tester" sends.

Therefore, if you're pointing the Prometheus alertmanager webhook receiver *directly* at a Discord API, it definitely won't work. You will need some middleware to translate the Alertmanager webhook payload into something the target API understands.Ā  Google "alertmanager discord" for some options.

As for sending to slack, you should use the Alertmanager built-in slack integration, not webhook:

You can of course make one alertmanager receiver which does both, which is perhaps what you're already doing:

receivers:
- name: discord/slack
Ā  slack_configs:
Ā  Ā  - ...
Ā  webhook_configs:
Ā  Ā  - ...

Fabrice Semti

unread,
Aug 30, 2022, 9:00:04 AM8/30/22
to promethe...@googlegroups.com



---------- Forwarded message ---------
Feladó: Fabrice Semti <fab...@fabricesemti.com>
Date: 2022. aug. 30., K, 13:42
Subject: Re: [prometheus-users] Re: discord - "unrecoverable error"
To: Brian Candler <b.ca...@pobox.com>


Hi Brian,

Thanks for the reply.

You haven't said what you've configured as the receiver (target) of the webhook.

So I have created a webhook on my discord channel. (The same webhook was tested on the online tester)

image.png

Therefore, if you're pointing the Prometheus alertmanager webhook receiver *directly* at a Discord API, it definitely won't work. You will need some middleware to translate the Alertmanager webhook payload into something the target API understands.Ā  Google "alertmanager discord" for some options.

I have based my config on this one, which seems to be in line with what I found for "alertmanager discord"...

My config is:

Ā  alertmanager:
Ā  Ā  Ā  config:
Ā  Ā  Ā  Ā  global:
Ā  Ā  Ā  Ā  Ā  slack_api_url: "${SECRET_ALERT_MANAGER_DISCORD_WEBHOOK}"
Ā  Ā  Ā  Ā  Ā  resolve_timeout: 5m
Ā  Ā  Ā  Ā  receivers:
Ā  Ā  Ā  Ā  Ā  - name: "null"
Ā  Ā  Ā  Ā  Ā  - name: "discord"
Ā  Ā  Ā  Ā  Ā  Ā  slack_configs:
Ā  Ā  Ā  Ā  Ā  Ā  Ā  - channel: "#prometheus"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  icon_url: https://avatars3.githubusercontent.com/u/3380462
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  username: "Prometheus"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  send_resolved: true
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  title: |-
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  [{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ if ne .CommonAnnotations.summary ""}}{{ .CommonAnnotations.summary }}{{ else }}{{ .CommonLabels.alertname }}{{ end }}
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  text: >-
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  {{ range .Alerts -}}
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  **Alert:** {{ .Annotations.title }}{{ if .Labels.severity }} - `{{ .Labels.severity }}`{{ end }}
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  **Description:** {{ if ne .Annotations.description ""}}{{ .Annotations.description }}{{else}}N/A{{ end }}
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  **Details:**
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  {{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}`
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  {{ end }}
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  {{ end }}
Ā  Ā  Ā  Ā  route:
Ā  Ā  Ā  Ā  Ā  group_by: ["alertname", "job"]
Ā  Ā  Ā  Ā  Ā  group_wait: 30s
Ā  Ā  Ā  Ā  Ā  group_interval: 5m
Ā  Ā  Ā  Ā  Ā  repeat_interval: 6h
Ā  Ā  Ā  Ā  Ā  receiver: "discord"
Ā  Ā  Ā  Ā  Ā  routes:
Ā  Ā  Ā  Ā  Ā  Ā  - receiver: "null"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  match:
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  alertname: Watchdog
Ā  Ā  Ā  Ā  Ā  Ā  - receiver: "discord"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  match_re:
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  severity: critical|warning|error
Ā  Ā  Ā  Ā  Ā  Ā  Ā  continue: true
Ā  Ā  Ā  Ā  inhibit_rules:
Ā  Ā  Ā  Ā  Ā  - source_match:
Ā  Ā  Ā  Ā  Ā  Ā  Ā  severity: "critical"
Ā  Ā  Ā  Ā  Ā  Ā  target_match:
Ā  Ā  Ā  Ā  Ā  Ā  Ā  severity: "warning"
Ā  Ā  Ā  Ā  Ā  Ā  equal: ["alertname", "namespace"]

Ā  Ā  Ā  ingress:
Ā  Ā  Ā  Ā  enabled: true
Ā  Ā  Ā  Ā  pathType: Prefix
Ā  Ā  Ā  Ā  ingressClassName: "nginx"
Ā  Ā  Ā  Ā  annotations:
Ā  Ā  Ā  Ā  Ā  cert-manager.io/cluster-issuer: "letsencrypt-production"
Ā  Ā  Ā  Ā  Ā  external-dns.alpha.kubernetes.io/target: "ipv4.${SECRET_DOMAIN}"
Ā  Ā  Ā  Ā  Ā  external-dns/is-public: "true"
Ā  Ā  Ā  Ā  Ā  hajimari.io/enable: "true"
Ā  Ā  Ā  Ā  Ā  hajimari.io/icon: "fire-alert"
Ā  Ā  Ā  Ā  Ā  # nginx.ingress.kubernetes.io/auth-url: "https://oauth.${SECRET_DOMAIN}/oauth2/auth"
Ā  Ā  Ā  Ā  Ā  # nginx.ingress.kubernetes.io/auth-signin: "https://oauth.${SECRET_DOMAIN}/oauth2/start?rd=$scheme://$best_http_host$request_uri"
Ā  Ā  Ā  Ā  Ā  # nginx.ingress.kubernetes.io/auth-response-headers: "x-auth-request-user, x-auth-request-email, x-auth-request-access-token"
Ā  Ā  Ā  Ā  hosts:
Ā  Ā  Ā  Ā  Ā  - &host "alert-manager.${SECRET_DOMAIN}"
Ā  Ā  Ā  Ā  tls:
Ā  Ā  Ā  Ā  Ā  - hosts:
Ā  Ā  Ā  Ā  Ā  Ā  Ā  - *host
Ā  Ā  Ā  Ā  Ā  Ā  secretName: "alert-manager-tls"
Ā  Ā  Ā  alertmanagerSpec:
Ā  Ā  Ā  Ā  storage:
Ā  Ā  Ā  Ā  Ā  volumeClaimTemplate:
Ā  Ā  Ā  Ā  Ā  Ā  spec:
Ā  Ā  Ā  Ā  Ā  Ā  Ā  storageClassName: "hdd-nfs-storage"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  resources:
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  requests:
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  storage: 1Gi

Ā  Ā  Ā  resources:
Ā  Ā  Ā  Ā  requests:
Ā  Ā  Ā  Ā  Ā  cpu: 11m
Ā  Ā  Ā  Ā  Ā  memory: 37M



You can of course make one alertmanager receiver which does both, which is perhaps what you're already doing:

receivers:
- name: discord/slack
Ā  slack_configs:
Ā  Ā  - ...
Ā  webhook_configs:
Ā  Ā  - ...


Yes, pretty much that is what I am aiming for, and I only lightly modified what I have seen in other repos (such as above or this one ), so I am not sure what is not right...
Any further clues would be much appreciated...

Ā 

Best regards,

Fabrice Semti

šŸ“§Ā fab...@fabricesemti.comĀ Ā Ā šŸ“§Ā emilf...@gmail.comĀ 
🌐 fabricesemti.com



--
You received this message because you are subscribed to a topic in the Google Groups "Prometheus Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/prometheus-users/uqNf-alj0i0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/e7f7f14f-514f-474c-8052-5bae2c0a6a64n%40googlegroups.com.

Brian Candler

unread,
Aug 30, 2022, 9:15:23 AM8/30/22
to Prometheus Users
I think the part you've missed is that an *alertmanager* webhook message is completely different to a *discord* webhook message.Ā  You need an application in between to translate - that is, it receives an alertmanager webhook message, and send it on to discord with a different payload.

If you google "alertmanager discord" then the first two hits are projects which do exactly this:

Now, you linked to this bit of helm chart:

That doesn't use alertmanager webhooks at all.Ā  It uses the *slack* sending capability of alertmanager.

Does Discord accept Slack-formatted API messages?Ā  If so, then it might work.Ā  This suggests that it could:
But there's a separate API endpoint for accepting Slack-format requests:

So either:
1. you're not POSTing to the correct endpoint (the Slack-compatible one)
2. something about alertmanager's request makes Discord unhappy (i.e. it's not as Slack-compatible as it claims to be)

If you think it's case (2) then you can take it up with Discord support - although they probably will want to see the body of the HTTP request, and the body of the 400 response that comes back.

Fabrice Semti

unread,
Aug 30, 2022, 10:22:03 AM8/30/22
to Brian Candler, Prometheus Users
Thanks for your reply.

I mean, if I replace the SECRET_ALERT_MANAGER_DISCORD_WEBHOOK with SECRET_ALERT_MANAGER_SLACK_WEBHOOK(so using instead of a Discord webhook an actual Slack one - to a freshly created slack channel of mine)Ā  the alerts are indeed coming in..


image.png

image.png
So indeed something must be amiss between alert manager and/or Discord...will do some reading / reaching out to Discord support, I thought the Discord webhook by default interchangeable with the Slack-one, at least the helmreleases I have seen seemed to indicate this.
Will circle back here if that avenue is exhausted...

Brian Candler

unread,
Aug 30, 2022, 10:51:48 AM8/30/22
to Prometheus Users
And the URL you've configured, it definitely looks like
Ā  Ā  /webhooks/{webhook.id}/{webhook.token}/slack
?

Fabrice Semti

unread,
Aug 30, 2022, 11:45:01 AM8/30/22
to Brian Candler, Prometheus Users
Sorry for the delay. Updated my config based on your suggestion, and indeed I think that fixed it so I am very grateful, thank you very much!

Ā  Ā  Ā  Ā  Ā  slack_api_url: "${SECRET_ALERT_MANAGER_DISCORD_WEBHOOK}/slack" ## ? Discord
Ā  Ā  Ā  Ā  Ā  # slack_api_url: "${ SECRET_ALERT_MANAGER_SLACK_WEBHOOK}" ## ? Slack

Was just waiting for Prom to fire an alert to Discord after the changes, which just happened.

Thanks again for your help!
Reply all
Reply to author
Forward
0 new messages