Configure Discord-Alert-Template

  • What Grafana version and what operating system are you using?
    8.3.3

  • What are you trying to achieve?
    Hello all,
    is it possible to remove the link to Grafana in a Discord alert template?
    What is meant is what can be seen in the screenshot.
    I would like to output only text in a Discord channel, but there should be no link to Grafana.
    Thank you.

  • How are you trying to achieve it?
    I have already created my own template for the Discord message:

{{ define "Discord" }}
  {{ if gt (len .Alerts.Firing) 0 }}
    {{ range .Alerts.Firing }} {{ template "alert" .}} {{ end }}
  {{ end }}
  {{ if gt (len .Alerts.Resolved) 0 }}
    {{ range .Alerts.Resolved }} {{ template "alert" .}} {{ end }}
  {{ end }}
{{ end }}

Alert:

{{ define "alert" }}
{{ .Labels.alertname }}

  {{ if gt (len .Annotations) 0 }}
  {{ range .Annotations.SortedPairs }}
    {{ .Name }}: {{ .Value }}
  {{ end }}
  {{ end }}

{{ end }}
  • What happened?

  • What did you expect to happen?
    The [FIRING:1] (TestAlert Grafana) should not be displayed.

  • Can you copy/paste the configuration(s) that you are having problems with?
    See above

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    ///

  • Did you follow any online instructions? If so, what is the URL?
    ///

Has nobody an idea? :confused:

The Discord contact point type uses tmpl(DefaultMessageTitleEmbed) for its title, which is hardcoded to:

{{ template "default.title" . }}

as seen in ngalert/notifier/channels/discord.go.

You can technically override this value by manually changing the __default__.tmpl on disk and then locking the file so Grafana doesn’t automatically reset it. You can also create an alert in Grafana called default, but it will automatically get overwritten with the actual defaults.

I don’t believe there is an effective way to rename the title in the Discord embed unless the Discord notifier is modified to accept a custom template string for the title.

However: the Slack notifier offers a field for both the embed title and body, and Discord webhooks are compatible with Slack if you add a “/slack” to the end of the URL.

1 Like

I need help as well…

This is such a daunting experience :slight_smile: I don’t even know if grafana behaves fundamentally different depending on the contact point you’re using.