Reputation: 10305
So I have a common label opsteam
that is supposed to bring DM in slack once alertmanager is fired. However inside slack I get usernames as pure text, not highlighted and these users are not getting any messages.
nodeSelector:
prometheus: "true"
enabled: true
retention: "30d"
extraFlags:
- web.enable-lifecycle
- web.enable-admin-api
strategy:
type: RollingUpdate
global:
scrape_interval: 30s
external_labels:
env: prod
client: client
cluster: project-prod-eks
opsteam: "@U0325FRAD @U01GN7KJHU"
If I change opsteam: "@U0325FRAD @U01GN7KJHU"
to opsteam: "@john @jim"
it does no effects either.
so this is my custom slack notification
notifications.tmpl: |
{{ define "__alert_silence_link" -}}
{{ .ExternalURL }}/#/silences/new?filter=%7B
{{- range .CommonLabels.SortedPairs -}}
{{- if ne .Name "alertname" -}}
{{- .Name }}%3D"{{- .Value -}}"%2C%20
{{- end -}}
{{- end -}}
alertname%3D"{{- .CommonLabels.alertname -}}"%7D
{{- end }}
{{ define "__alert_severity" -}}
{{- if eq .CommonLabels.severity "critical" -}}
*Severity:* `Critical` {{ if eq .Status "firing" }}:fire:{{- else -}}:ok:{{- end -}}
{{- else if eq .CommonLabels.severity "warning" -}}
*Severity:* `Warning`
{{- else if eq .CommonLabels.severity "info" -}}
*Severity:* `Info`
{{- else -}}
*Severity:* :question: {{ .CommonLabels.severity }}
{{- end }}
{{- end }}
{{ define "__alert_client_details" -}}
*Env:* {{ .CommonLabels.env }}
*Client:* {{ .CommonLabels.client }}
*Cluster:* {{ .CommonLabels.cluster }}
{{- end }}
{{ define "slack.title" -}}
[{{ .Status | toUpper -}}
{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{- end -}}
] {{ .CommonLabels.cluster }} - {{ .CommonLabels.alertname }}
{{- end }}
{{ define "slack.text" -}}
{{ .CommonLabels.opsteam }} <<-----------------WANT THEM TO BE User Mentions!!!!!
{{ template "__alert_severity" . }}
{{ template "__alert_client_details" . }}
{{- if (index .Alerts 0).Annotations.summary }}
{{- "\n" -}}
*Summary:* {{ (index .Alerts 0).Annotations.summary }}
{{- end }}
{{ range .Alerts }}
{{- if .Annotations.description }}
{{ .Annotations.description }}{{- "\n" -}}
{{- end }}
{{- if .Annotations.message }}
{{ .Annotations.message }}{{- "\n" -}}
{{- end }}
{{- end }}
{{- end }}
{{ define "slack.color" -}}
{{ if eq .Status "firing" -}}
{{ if eq .CommonLabels.severity "warning" -}}
warning
{{- else if eq .CommonLabels.severity "critical" -}}
danger
{{- else -}}
#439FE0
{{- end -}}
{{ else -}}
good
{{- end }}
{{- end }}
Yes my messages are just text in slack.
Upvotes: 0
Views: 2659
Reputation: 2861
There is a given format to embed usernames in Slack.
https://api.slack.com/reference/surfaces/formatting#mentioning-users
<@userId>
Upvotes: 6