You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,38 @@ receivers:
57
57
- url: 'http://localhost:9876/alert'
58
58
```
59
59
60
+
## Message templating
61
+
62
+
Sachet supports Alertmanager-like templates for message content. You can do that by simply copying Alertmanager templates to Sachet. Some templates examples can be found in [the Alertmanager documentation](https://prometheus.io/docs/alerting/notification_examples/) as well as [available variables](https://prometheus.io/docs/alerting/notifications/).
63
+
64
+
sachet.yml:
65
+
```yaml
66
+
templates:
67
+
- /etc/sachet/notifications.tmpl
68
+
69
+
receivers:
70
+
- name: 'team-telegram'
71
+
provider: telegram
72
+
text: '{{ template "telegram_message" . }}'
73
+
```
74
+
notifications.tmpl:
75
+
```
76
+
{{ define "telegram_title" }}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .CommonLabels.alertname }} @ {{ .CommonLabels.identifier }} {{ end }}
77
+
78
+
{{ define "telegram_message" }}
79
+
{{ if gt (len .Alerts.Firing) 0 }}
80
+
*Alerts Firing:*
81
+
{{ range .Alerts.Firing }}• {{ .Labels.instance }}: {{ .Annotations.description }}
82
+
{{ end }}{{ end }}
83
+
{{ if gt (len .Alerts.Resolved) 0 }}
84
+
*Alerts Resolved:*
85
+
{{ range .Alerts.Resolved }}• {{ .Labels.instance }}: {{ .Annotations.description }}
0 commit comments