# Watcher mail body formatting

**URL:** <https://discuss.elastic.co/t/watcher-mail-body-formatting/172929>\
**Category:** Kibana\
**Created:** [March 19, 2019, 9:41am UTC](https://discuss.elastic.co/t/watcher-mail-body-formatting/172929 "2019-03-19T09:41:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sumanth\_Varma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sumanth_varma/32/54918_2.png) [@Sumanth\_Varma](https://discuss.elastic.co/u/Sumanth_Varma)\
**Post date:** [March 19, 2019, 9:41am UTC](https://discuss.elastic.co/t/watcher-mail-body-formatting/172929/1 "2019-03-19T09:41:01Z")

</div>

I am trying to get the mail of Container which are down through mail with respective the pod name and the namespaces included. I wanted it to be table but not able to get same.I tried few things,by which i was able to get the data in the body but still not in good format.

"html": "

# Please find the Attachment for logs
  
  
**AlertType:App ALerts** {{ctx.metadata.\_cne-alertType}}  
**AlertSeverity: High**  
\<  
The Errors are observed on . {{#ctx.payload.hits.hits}} {{\_source.containername}} {{/ctx.payload.hits.hits}} Container with respective pod {{#ctx.payload.hits.hits}} {{\_source.podname}} {{/ctx.payload.hits.hits}} **Trigger Time:** {{ctx.trigger.triggered\_time}}  
"

---

<div class="post-metadata">

**Author:** ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)\
**Post date:** [March 19, 2019, 9:36pm UTC](https://discuss.elastic.co/t/watcher-mail-body-formatting/172929/2 "2019-03-19T21:36:09Z")

</div>

Hi there, it sounds like you're trying to insert an HTML table into your email. Is that correct? If so, could you share you watch action configuration? According to the [docs](https://www.elastic.co/guide/en/x-pack/current/actions-email.html) you should be able to specify a `body.html` attribute for the watch action.

Thanks,  
CJ

---

<div class="post-metadata">

**Author:** ![Sumanth\_Varma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sumanth_varma/32/54918_2.png) [@Sumanth\_Varma](https://discuss.elastic.co/u/Sumanth_Varma)\
**Post date:** [March 20, 2019, 6:12am UTC](https://discuss.elastic.co/t/watcher-mail-body-formatting/172929/3 "2019-03-20T06:12:43Z")

</div>

My action is below:

```auto
 "subject": "ALERT!! Containers are Down",
        "body": {
          "html": "<br><br><b>AlertType:App Alert</b> {{ctx.metadata._cne-alertType}}<br><b>AlertSeverity: High</b><b><br><br> Containers Down: {{#ctx.payload.hits.hits}} {{_source.kubernetes.container.name}}, {{/ctx.payload.hits.hits}}</b><b><br><br> RESPECTIVE PODS : {{#ctx.payload.hits.hits}} {{_source.kubernetes.pod.name}}, {{/ctx.payload.hits.hits}}</b><b><br><br> RESPECTIVE NAMESPACES : {{#ctx.payload.hits.hits}} {{_source.kubernetes.namespace}}, {{/ctx.payload.hits.hits}}</b><br><br><br><br><b>Trigger Time:</b> {{ctx.trigger.triggered_time}}<br><p></p>"
        }

```

output i am getting

```auto
**AlertType:App Alert**
<b>AlertSeverity: High

Containers Down: httpd, httpd, httpd, httpd, httpd, httpd,

RESPECTIVE PODS : reverse-proxy-service, reverse-proxy-service, reverse-proxy-service, reverse-proxy-service, reverse-proxy-service, reverse-proxy-service,

RESPECTIVE NAMESPACES : my-namespaces-monitoring, my-namespaces-monitoring, my-namespaces-monitoring, my-namespaces-monitoring, my-namespaces-monitoring, my-namespaces-monitoring,

```

--- expecting. I wanted to be well formatted(maybe in table format like below)

```auto
Containers PODS NAMESPACES

httpd reverse-proxy-service my-namespaces-monitoring

```

---

<div class="post-metadata">

**Author:** ![Sumanth\_Varma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sumanth_varma/32/54918_2.png) [@Sumanth\_Varma](https://discuss.elastic.co/u/Sumanth_Varma)\
**Post date:** [March 20, 2019, 11:50am UTC](https://discuss.elastic.co/t/watcher-mail-body-formatting/172929/4 "2019-03-20T11:50:16Z")

</div>

i am actual able to get the tabular format required but i am getting duplicate value.can you help with that

| Containers Down | POD | NAMESPACE |
| --- | --- | --- |
| httpd | reverse-proxy-service-77ccd8dc5b-4wclv | ugbu-eap--stg--mt-monitoring--1-4 |
| httpd | reverse-proxy-service-66d57d5dd6-ckgfj | ugbu-eap--prd--mt-monitoring--1-4 |
| httpd | reverse-proxy-service-77ccd8dc5b-4wclv | ugbu-eap--stg--mt-monitoring--1-4 |
| httpd | reverse-proxy-service-66d57d5dd6-ckgfj | ugbu-eap--prd--mt-monitoring--1-4 |
| httpd | reverse-proxy-service-66d57d5dd6-ckgfj | ugbu-eap--prd--mt-monitoring--1-4 |
| httpd | reverse-proxy-service-77ccd8dc5b-4wclv | ugbu-eap--stg--mt-monitoring--1-4 |

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 17, 2019, 11:50am UTC](https://discuss.elastic.co/t/watcher-mail-body-formatting/172929/5 "2019-04-17T11:50:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
