# How to configure custom subject to send an emails

**URL:** <https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239>\
**Category:** PMM 2.x\
**Created:** [October 28, 2022, 12:48pm UTC](https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239 "2022-10-28T12:48:41Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [October 28, 2022, 12:48pm UTC](https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239/1 "2022-10-28T12:48:41Z")

</div>

I want to expecting the email subject like below, can some one please help how can i get the custom email subject whenever any issue happen.

Actual Subject: [FIRING:1]

Expecting Subject: [CRITICAL]:[Environment] \<Service\_Name\> down On \<Host\_Name/Server\_Name\>

EX1: [CRITICAL]:[DEV] MySQL down (C-DEV6-403) On tesDev101 server

EX2: [CRITICAL]:[QA] MySQL down (C-QA-403) On tesQA101 server

EX3: [CRITICAL]:[PROD] MySQL down (C-Prod-Db) On testProd201 server

Can we have example how can we get the email sub name like [CRITICAL]:[Environment] down \<Service\_Name\> On ?

We don’t have any documentation for this in the PMM2 site.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/f/f5a0ac4eb661500ef814ee358304d94954c1a60b.png)

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [October 29, 2022, 5:56am UTC](https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239/2 "2022-10-29T05:56:24Z")

</div>

Can somebody help me on this?

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [October 31, 2022, 9:22am UTC](https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239/3 "2022-10-31T09:22:59Z")

</div>

Can somebody help me on this?

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [November 2, 2022, 5:24pm UTC](https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239/4 "2022-11-02T17:24:06Z")

</div>

Can somebody help me on this?

---

<div class="post-metadata">

**Author:** ![steve.hoffman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/steve.hoffman/32/66_2.png) [@steve.hoffman](https://forums.percona.com/u/steve.hoffman)\
**Post date:** [November 2, 2022, 8:36pm UTC](https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239/5 "2022-11-02T20:36:22Z")

</div>

The ability to modify the email subject comes from upstream grafana and [here’s](https://grafana.com/docs/grafana/latest/alerting/contact-points/) the docs with the info you’re after starts. By using this [PR](https://github.com/grafana/grafana/pull/49742) as a guide, I was able to get some of the data using the test button for the contact point based on these template variables [here](https://grafana.com/docs/grafana/latest/alerting/contact-points/message-templating/template-data/)

Any of:  
{{ .Status }} {{ .CommonAnnotations }} {{ .GroupLabels }} worked using the test button but the moment I tried {{ .severity }} or {{ .Labels.severity }} or {{ $Labels.severity }} it would send the test but not render the subject in the email and I see the following in the /srv/logs/grafana.logs file:  
`level=warn msg="failed to template email message" err="template: :1:11: executing \"\" at <.labels.severity>: can't evaluate field labels in type *channels.ExtendedData"`

which makes sense because it’s a test email not a real alert with labels added to it…my problem is that I broke something somewhere else in my setup so I can’t get a real email to generate to see if they would work on a legitimate firing alert but may be enough to get you pointed in the right direction.

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [November 3, 2022, 1:55pm UTC](https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239/6 "2022-11-03T13:55:37Z")

</div>

Hi @steve.hoffman

Thanks for the help. I tried the following options {{ .severity }} or {{ .Labels.severity }} or {{ $Labels.severity }} with genuine error, but still I am getting subject like empty or (no subject).

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [November 6, 2022, 6:36pm UTC](https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239/7 "2022-11-06T18:36:37Z")

</div>

Hi @steve.hoffman

Any luck from your end? or can you please request for any documentation or fix the issue?

---

<div class="post-metadata">

**Author:** ![steve.hoffman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/steve.hoffman/32/66_2.png) [@steve.hoffman](https://forums.percona.com/u/steve.hoffman)\
**Post date:** [November 6, 2022, 6:40pm UTC](https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239/8 "2022-11-06T18:40:39Z")

</div>

I asked on the grafana forums since this is technically a grafana feature but haven’t had any luck on my end getting it to work.

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [November 7, 2022, 7:25am UTC](https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239/9 "2022-11-07T07:25:00Z")

</div>

Thanks for the update @steve.hoffman

Please update if found any solution or update from Grafana team.

As a user, he/she should customize Subject and Body.

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [November 29, 2022, 11:57am UTC](https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239/10 "2022-11-29T11:57:54Z")

</div>

Hi @steve.hoffman

Finally, I got the solution for the above.

1. Firstly we have to create template like below.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/1/12eda8d1b527bda1f299c4fa025517c294b86f36.png)

1. And then in the email contact point set to the subject to:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/4/41e59f5f201615b6f8678941c9834adbdd01c62c.png)

---

<div class="post-metadata">

**Author:** ![steve.hoffman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/steve.hoffman/32/66_2.png) [@steve.hoffman](https://forums.percona.com/u/steve.hoffman)\
**Post date:** [November 29, 2022, 2:46pm UTC](https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239/11 "2022-11-29T14:46:45Z")

</div>

AWESOME!! going to set it up on my end and will get this added to our docs to save someone future headache!!! Thanks for chasing this down!!!

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [November 29, 2022, 3:10pm UTC](https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239/12 "2022-11-29T15:10:41Z")

</div>

Sure. Now, I am trying for email body as well to simplify the content with more informative.

---

<div class="post-metadata">

**Author:** ![beckzg](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/32.png) [@beckzg](https://forums.percona.com/u/beckzg)\
**Post date:** [January 24, 2025, 4:33pm UTC](https://forums.percona.com/t/how-to-configure-custom-subject-to-send-an-emails/18239/13 "2025-01-24T16:33:21Z")

</div>

Did you resolved the mail body customization?
