-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discord messages not correctly formatted/delivered #3576
Comments
According to this that Discord error message pops up on a various type of format errors, the most frequent one is an empty embed field. I am now trying to do a bit of reverse engineering and modifying a the template to see if that's the case |
After some changes in the template, I was able to make it works, so I can confirm it's due to some empty fields in the embeds title: >-
[{{ .Status | toUpper }}
{{ if eq .Status "firing" }}: {{ .Alerts.Firing | len }}{{ end }}]
{{ with (index .GroupLabels.SortedPairs.Values 0) }}
{{ . }}
{{ end }}
message: |-
{{ if and .Alerts.Firing (gt (len .Alerts.Firing) 0) }}
{{- range .Alerts.Firing }}
{{- if gt (len .Annotations) 0 }}
{{ range .Annotations.SortedPairs }}
- {{ .Name }}: {{ .Value }}
{{- end }}
{{- else }}
(No Annotations)
{{- end }}
{{- end }}
{{- end }} Obviously this is a slim version (I don't need all of the infos) but my suggestion was to check for the fields in the code and not in the template and maybe add a default string |
@dnnnvx Where should I put the settings to use with discord? |
(Note that I'm using the kube-prom-stack chart) in the alertmanager values you need to add a discord receiver (I ended up using the slack title/text templates): alertmanager:
...
receivers:
...
- name: discord
discord_configs:
- webhook_url: "https://discord.com/api/webhooks/..."
send_resolved: true
title: '{{ template "slack.title" . }}'
message: '{{ template "slack.text" . }}' |
I ran into the same issue, and I think it is related to |
My understanding is the error message is identical.
How can we be sure it's not the same? I recognise there has been some triaging here, and changing the template has worked for you. It does confuse me however, as the actual Discord integration works okay. Could you verify you can still reproduce the issue with |
Sorry @uhthomas you're right, I was looking at the wrong log- I deployed |
Received 2 new errors tonight and both were displayed successfully, so I think it can be market as a duplicate. Thanks again! |
@dnnnvx I've attempted several methods to templatize the alerts while using the same kube-prometheus-stack Helm chart as yours. Specifically, I've tried creating templates through a ConfigMap and volume mounting it, but those attempts haven't worked. Additionally, I'm encountering same issue with configuring Discord webhooks for alert notifications. Can anyone provide guidance on how to properly set this up when using Alertmanager through the prometheus-stack Helm chart? |
What did you do?
What did you expect to see?
Discord notifications correctly delivered
What did you see instead? Under which circumstances?
Alertmanager cannot deliver the message, prints the error log:
Such response from Discord means that some Embeds are bad configured, so I guess the JSON payload created is not well formatted. Couldn't find a way to debug the created payload (via
logLevel=debug
)Here's the simple alert I'm testing which always trigger the alert (as stated via the UI too):
Environment
System information:
Linux 5.15.117 x86_64
Alertmanager version:
Prometheus configuration file:
Not relevant
Logs:
The text was updated successfully, but these errors were encountered: