# Grafana won't fully render Slack template

**URL:** <https://community.grafana.com/t/grafana-wont-fully-render-slack-template/102900>\
**Category:** Alerting\
**Tags:** templating, alerting\
**Created:** [September 5, 2023, 3:28pm UTC](https://community.grafana.com/t/grafana-wont-fully-render-slack-template/102900 "2023-09-05T15:28:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![horizn](https://avatars.discourse-cdn.com/v4/letter/h/e99b99/32.png) [@horizn](https://community.grafana.com/u/horizn)\
**Post date:** [September 5, 2023, 3:28pm UTC](https://community.grafana.com/t/grafana-wont-fully-render-slack-template/102900/1 "2023-09-05T15:28:54Z")

</div>

I have Grafana alerting to Slack and now I want to add additional annotation: `traces` to be displayed in the alert. For some reason it is not being shown in the alert, but I can see this new annotation in Grafana alert in the UI.

My Grafana Slack template:

```auto
{{ define "alert_severity_prefix_emoji" -}}
        {{- if ne .Status "firing" -}}
                :white_check_mark:
        {{- else if eq .CommonLabels.severity "critical" -}}
                :red_circle:
        {{- else if eq .CommonLabels.severity "warning" -}}
                :warning:
        {{- end -}}
{{- end -}}

{{ define "slack.title" -}}
  {{ template "alert_severity_prefix_emoji" . }}
        [{{- .Status | toUpper -}}{{- if eq .Status "firing" }} x {{ .Alerts.Firing | len -}}{{- end }}]: {{ .CommonLabels.alertname -}}
{{- end -}}

{{- define "slack.text" -}}
{{- range .Alerts -}}
{{ if gt (len .Annotations ) 0 }}
*Description*: {{ .Annotations.description }}
*Instance*:
{{ range .Labels.SortedPairs }}{{ if or (eq .Name "env") (eq .Name "instance") (eq .Name "cluster") (eq .Name "http_host")}}• {{ .Name }}: `{{ .Value }}`
{{ end }}{{ end }}
*Silence alert*: {{ .SilenceURL }}
*Go to dashboard*: {{ .DashboardURL }}
*Go to panel directly*: {{ .PanelURL }}
*Go to traces*: {{ .Annotations.traces }}
{{ end }}
{{ end }}
{{ end }}

```

In the alert rule I have:

```auto
resource "grafana_rule_group" "prometheus_metrics_rule_group" {
  name = "Prometheus metrics"
  folder_uid = grafana_folder.prometheus_rule_folder.uid
  interval_seconds = 300
  org_id = 1
  rule {
    name = "5xx HTTP server side errors"
    for = "2m"
    condition = "B"
    no_data_state = "OK"
    exec_err_state = "Alerting"
    annotations = {
      __dashboardUid__ = grafana_dashboard.prometheus_http_errors.uid
      __panelId__ = "1"
      "description" = "{{ with $values }} 5xx server side HTTP errors have exceeded 10% of all requests within the last 10 minutes"
      "traces" = "{{ graphLink \"{\"expr\": \"up\", \"datasource\": \"Tempo\"}\" }}"

```

For the test purposes I’ve tried set “traces” annotation to just a “test” string but with no luck. What I am doing wrong here?

---

<div class="post-metadata">

**Author:** ![georgerobinson](https://avatars.discourse-cdn.com/v4/letter/g/ad7895/32.png) [@georgerobinson](https://community.grafana.com/u/georgerobinson)\
**Post date:** [September 5, 2023, 7:42pm UTC](https://community.grafana.com/t/grafana-wont-fully-render-slack-template/102900/2 "2023-09-05T19:42:42Z")

</div>

It works for me 😕 I’m testing it in the Preview feature in Grafana 10

 ![Screenshot 2023-09-05 at 8.42.26 pm](https://us1.discourse-cdn.com/grafana/original/3X/a/3/a3ae5b95e8368571fb5b0ade26db6f62b156ca26.png)

---

<div class="post-metadata">

**Author:** ![horizn](https://avatars.discourse-cdn.com/v4/letter/h/e99b99/32.png) [@horizn](https://community.grafana.com/u/horizn)\
**Post date:** [September 6, 2023, 8:56am UTC](https://community.grafana.com/t/grafana-wont-fully-render-slack-template/102900/3 "2023-09-06T08:56:46Z")

</div>

It works for me in preview too, but won’t show in Slack message. Is there any limit for message length?

---

<div class="post-metadata">

**Author:** ![horizn](https://avatars.discourse-cdn.com/v4/letter/h/e99b99/32.png) [@horizn](https://community.grafana.com/u/horizn)\
**Post date:** [September 6, 2023, 12:12pm UTC](https://community.grafana.com/t/grafana-wont-fully-render-slack-template/102900/4 "2023-09-06T12:12:32Z")

</div>

So during my trial and error tests I found that replacing/moving:

```auto
*Go to traces*: {{ .Annotations.traces }}

```

with:

```auto
*Silence alert*: {{ .SilenceURL }}

```

worked and now I can see it in the Slack alert message. I suspected some kind of character limit in single Slack message but it is not that. I would say this is a bug except there is another explanation for this.
