tried to add the default.tmpl into directory /etc/alertmanager/template/ and restarted alertmanager process, but it failed with error:
time="2016-03-02T11:00:20Z" level=error msg="Loading configuration file failed: template: redefinition of template "__text_alert_list"" file="/alertmanager.conf" source="main.go:128"
the configuration as below:
templates:
any document or guides can help me?
The default.tmpl is compiled into the binary. You cannot overwrite anything specified in there.
You have to create a new template file with custom template names and reference those in the configuration.
@fabxc it's fine now. thanks for your help
one more question, what's the configuration parameter for the email subject?
i know the parameter for body is 'html".
Subject is a regular email header. So in the header map of the
configuration, you can set a custom "Subject" entry.
On Thu, Mar 3, 2016 at 2:46 AM tj13 [email protected] wrote:
@fabxc https://github.com/fabxc it's fine now. thanks for your help
one more question, what's the configuration parameter for the email
subject?
i know the parameter for body is 'html".—
Reply to this email directly or view it on GitHub
https://github.com/prometheus/alertmanager/issues/259#issuecomment-191534820
.
It seams that I can only ADD subjects, but can not overwrite or change the default subject.
Is that right? @fabxc
You can change the default subject, just provide a value for that header.
I want to change the alerting mail subject to "SYSTEM ALERT". My headers configuration as below:
headers:
'Subject': 'SYSTEM ALERT'
However, the alertmanager just put "SYSTEM ALERT" ahead of its default subject.
In the email, I found that alertmanager put another subject header before its default subject header.
Did I misconfigure? How to make it right?
By the way, my alertmanager is v0.1.0.
That's fixed at head now.
I just ran across this same issue. The root of this issue seems to be twofold.
1) the docs suck
2) who cares if i redefine one of your template parameters, your default template should be defaults, I should be allowed to override them all day long. Is there some issue that prevents this?
1) the docs suck
noted
2) who cares if i redefine one of your template parameters, your default template should be defaults, I should be allowed to override them all day long. Is there some issue that prevents
What exactly do you mean?
The one regarding the subject was a bug that was fixed. Any other instances?
I have also been very confused by the docs and I'm reading source-code now to figure out how stuff actually works. For example, for someone not used to golang templating, the fact that the template-specification in the configuration does not actually refer to a file, but instead just a section, and that sections are loaded independently of the files they are in (when using *.tmpl to import) and the fact that you get errors IF you actually add and try to edit the default.tmpl makes everything extremely confusing.
A good exercise would be to document the process of adding a custom e-mail template step-by-step as if to a five-year-old. And also working examples of the corresponding config parameters (the current sample config does not show anything templating related)
Go templating certainly has an entry barrier as well but it is working really well in the way it does – plus all questions you can Google for Go templates automatically help Alertmanager users. This aspect won't change.
But the docs from our side are still lacking but we are very open to contributions in that area.
Here is a basic blog post that might help a bit: https://prometheus.io/blog/2016/03/03/custom-alertmanager-templates/
Nice. Bookmarked. I might have a stab at creating a more coherent tutorial if I find the time!
That's be great, we'd be happy to accept a guest blog post.
There really should be an plain text counterpart. HTML email is unreadable. :(

For documentation, multipart and thus plain text is tracked in https://github.com/prometheus/alertmanager/issues/290
This is a simple example!
http://tailnode.tk/2017/03/alertmanager%E9%82%AE%E4%BB%B6%E6%A8%A1%E7%89%88/
I know this is an old issue, but the documentation is still not helpful. The only section in the docs that talks about templating refers to Slack alerts. Can we have better docs around adding custom _email_ templates?
Most helpful comment
I just ran across this same issue. The root of this issue seems to be twofold.
1) the docs suck
2) who cares if i redefine one of your template parameters, your default template should be defaults, I should be allowed to override them all day long. Is there some issue that prevents this?