Prometheus Alertmanager SNS email notification always in JSON format

55 views
Skip to first unread message

João Coelho

unread,
Mar 19, 2025, 6:27:37 AM3/19/25
to Prometheus Users
In my Prometheus configuration file, I have the alertmanager_config section, which includes routes, receivers, and template. However, I'm facing an issue where the notification emails are always "the same", and in JSON format, regardless of the template I use or whether templates are defined. Can you help me with this? Is it possible to receive plain text notifications with SNS? Am I missing something?

Here's my Prometheus config:
alert_manager_definition = <<-EOT
template_files:
default_template: |
{{ define "sns.default.message" }}"receiver": "{{ .Receiver }}"{{ end }}
{{ define "sns.default.subject" }}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}]{{ end }}
{{ define "__alertmanager" }}AlertManager{{ end }}
{{ define "__alertmanagerURL" }}{{ .ExternalURL }}/#/alerts?receiver={{ .Receiver | urlquery }}{{ end }}
alertmanager_config: |
global:
templates:
- 'default_template'
route:
receiver: test-grafana
group_wait: 30s
group_interval: 5m
repeat_interval: 10m
group_by: [environment, alertname]
routes:
- receiver: 'grafana-test'
group_wait: 10s
matchers:
- alert_group="node_exporter"
- receiver: 'test-grafana'
group_wait: 10s
matchers:
- alert_group="otelcol"
receivers:
- name: 'test-grafana'
sns_configs:
- topic_arn: my-sns-topic
sigv4:
region: eu-central-1
- name: 'grafana-test'
sns_configs:
- topic_arn: my-sns-topic
sigv4:
region: eu-central-1
EOT

Also tried somethings like these already:
alert_manager_definition = <<-EOT
alertmanager_config: |
route:
receiver: test-grafana
group_wait: 30s
group_interval: 5m
repeat_interval: 10m
group_by: [environment, alertname]
routes:
- receiver: 'grafana-test'
group_wait: 10s
matchers:
- alert_group="node_exporter"
- receiver: 'test-grafana'
group_wait: 10s
matchers:
- alert_group="otelcol"
receivers:
- name: 'test-grafana'
sns_configs:
- topic_arn: my-sns-topic
sigv4:
region: eu-central-1
- name: 'grafana-test'
sns_configs:
- topic_arn: my-sns-topic
sigv4:
region: eu-central-1
EOT

alert_manager_definition = <<-EOT
alertmanager_config: |
route:
receiver: test-grafana
group_wait: 30s
group_interval: 5m
repeat_interval: 10m
group_by: [environment, alertname]
routes:
- receiver: 'grafana-test'
group_wait: 10s
matchers:
- alert_group="custom_exporter"
- receiver: 'test-grafana'
group_wait: 10s
matchers:
- alert_group="otelcol"
receivers:
- name: 'test-grafana'
sns_configs:
- topic_arn: my-sns-topic
message: 'There are {{ len .Alerts.Firing }} firing alerts, and {{ len .Alerts.Resolved }} resolved alerts'
sigv4:
region: eu-central-1
attributes:
test-am: prometheus
- name: 'grafana-test'
sns_configs:
- topic_arn: my-sns-topic
sigv4:
region: eu-central-1
attributes:
test-am: amprometheus
EOT

For all configs showed above, the email notification was alwyas the same, in Json format.

George Robinson

unread,
Mar 19, 2025, 6:37:37 AM3/19/25
to Prometheus Users
I'm not that familiar with SNS, but as far as Alertmanager is concerned, isn't it just sending a message to the SNS topic with the message in the template? The actual email notification format is something that is configured in AWS? I'm just looking at their FAQ What are the different delivery formats/transports for receiving notifications? https://aws.amazon.com/sns/faqs/

Perhaps you are using Email-JSON? If the message from Alertmanager contains YAML, I presume that YAML will be embedded in the JSON.

João Coelho

unread,
Mar 19, 2025, 8:44:30 AM3/19/25
to Prometheus Users
Checked and I'm using email, not email-json. 
Message has been deleted

George Robinson

unread,
Mar 19, 2025, 9:51:47 AM3/19/25
to Prometheus Users
In that case I'm not sure, as I don't use SNS. Could you share the email with the JSON included, at least then we can see if it's coming from Alertmanager or SNS.
Reply all
Reply to author
Forward
0 new messages