Telegram notifier ignores HTML tags
Opened this issue ยท 0 comments
ntk148v commented
What did you do?
Setup Prometheus and Alertmanager to send message to Telegram. Message is sent as raw text, no HTML tags are parsed.
What did you expect to see?
Message is formatted.
What did you see instead? Under which circumstances?
Environment
-
System information:
-
Alertmanager version:
Alertmanager image tag 'main':
docker pull quay.io/prometheus/alertmanager@sha256:1e5f1f22c0875ebffad1c39ffb5f831c94ba6dcf0be4d5e5d910cfaade11b1b7
-
Prometheus version:
-
Alertmanager configuration file:
route:
group_wait: 5s
group_interval: 30s
receiver: 'telegram'
templates:
- iaas-alertmanager.tmpl
receivers:
- name: 'telegram'
telegram_configs:
- bot_token: 'xxxx'
chat_id: -xxxx
message: '{{ template "telegram.iaas.message" . }}'
parse_mode: 'HTML'
iaas-alertmanager.tmpl
file (simple notification template with HTML tags)
{{ define "__iaas_alert_list" }}
{{ range . }}
---
๐ชช <b>{{ .Labels.alertname }}</b>
<b></b>
{{- if .Annotations.summary }}
๐ Summary: {{ .Annotations.summary }}{{ end }}{{- if .Annotations.title }}
๐ Title: {{ .Annotations.title }}{{ end }}{{- if .Annotations.description }}
๐ Description:
<code>{{ .Annotations.description }}</code>{{ end }}{{ if .Annotations.assignees }}
๐ท๏ธ Labels:{{ if .Labels.severity }}
<i>Instance</i>: <code>{{ .Labels.instance }}</code>{{ end }}{{ if .Labels.job }}
<i>Job</i>: <code>{{ .Labels.job }}</code>{{ end }}
Owner: <code>Iaas team</code>
Since: <code>{{ .StartsAt.Local.Format "02/01/2006 15:04:05" }}</code>
{{ if not .EndsAt.IsZero }}
Ended: <code>{{ .EndsAt.Local.Format "02/01/2006 15:04:05" }}</code>{{ end }}
{{ end }}
{{ end }}
{{ define "telegram.iaas.message" }}
{{- if gt (len .Alerts.Firing) 0 }}
๐ฅ Alerts Firing ๐ฅ
{{- template "__iaas_alert_list" .Alerts.Firing }}
{{- end }}
{{- if gt (len .Alerts.Resolved) 0 }}
โ
Alerts Resolved โ
{{- template "__iaas_alert_list" .Alerts.Resolved }}
{{- end }}
{{- end }}
{{ define "telegram.iaas.message.summary" }}
{{if eq .Status "firing"}}
<b>๐ {{.CommonAnnotations.summary}}</b>
{{ (index .Alerts 0).StartsAt.Local.Format "02/01/2006 15:04:05" }}
<b></b>
{{- range $val := .Alerts }}
{{ $val.Labels.alertname }}
{{ $val.Annotations.description }}
{{- end }}
{{ end }}
{{ end }}
- Prometheus configuration file:
global:
scrape_interval: 1s
evaluation_interval: 1s
rule_files:
- 'rules.yml'
# alert
alerting:
alertmanagers:
- scheme: http
static_configs:
- targets:
- 'localhost:9093'
scrape_configs:
- job_name: prometheus
metrics_path: /metrics/
authorization:
credentials: my_random_prometheus_secret
static_configs:
- targets: ['host.docker.internal:8080']
- Logs:
nothing special