I am using Alertmanager for Prometheus, installed through the Helm kube-prometheus-stack. I wish to add a new notification template. For code clarity reason, I am trying to isolate the template on its own file. Doc leads me to do it through a secret. But I am a bit confused on the steps allowing to follows this through.
I create a secret containing my templates named "alertmanager-templates".
apiVersion: v1
kind: Secret
metadata:
name: alertmanager-templates
data:
mytemplate: Q2VjaSBlc3QgdW5lIGFsZXJ0ZQ==
Where base64 refers to "This is an alert"
I configure my notifications rules in a AlertManagerConfig crd, but this one does not support the addition of "templates" So I add the templates in the AlertManagers crd, like this:
apiVersion: monitoring.coreos.com/v1 kind: Alertmanager ...
spec:
alertmanagerConfiguration:
templates:
- secret:
key: alertmanager-templates
name: alertmanager-templates
And then refer to the template in my receiver definition in AlertManagerConfig:
apiVersion: monitoring.coreos.com/v1alpha1 kind: AlertmanagerConfig
spec:
receivers:
- name: sns
snsConfigs:
message: '{{ template "mytemplate" . }}'
But I get the following error doing so:
notify retry canceled due to unrecoverable error after 1 attempts: unexpected status code 400: Invalid parameter: Empty message","level":"error","msg":"Notify for alerts failed
Is this not the way to be used ?