# Ctx.payload.hits.hits in a tabular format within email box

**URL:** <https://discuss.elastic.co/t/ctx-payload-hits-hits-in-a-tabular-format-within-email-box/173976>\
**Category:** Kibana\
**Tags:** elastic-stack-alerting\
**Created:** [March 26, 2019, 5:11pm UTC](https://discuss.elastic.co/t/ctx-payload-hits-hits-in-a-tabular-format-within-email-box/173976 "2019-03-26T17:11:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mariner191](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@Mariner191](https://discuss.elastic.co/u/Mariner191)\
**Post date:** [March 26, 2019, 5:11pm UTC](https://discuss.elastic.co/t/ctx-payload-hits-hits-in-a-tabular-format-within-email-box/173976/1 "2019-03-26T17:11:53Z")

</div>

Hi there,

Following the Jan 20 2018 post, "Include fields in watcher email alert"

How to transform payload hits into a table format, making it easy to read for end-users? Running this format as a stand-alone JSON phrase does not produce a tabular result.  
So far: Please see Example: 2 Keys, Runs OK. Just looking to format as a Table.

Thank you,

 ![hits%20in%20a%20tabular%20format%20within%20email%20box](https://us1.discourse-cdn.com/elastic/original/3X/5/b/5b5db29eb220e0450eb3bf9e0fe998e39b5639e3.jpeg)

> [@Include Fields in Watcher Email Alert](https://discuss.elastic.co/t/include-fields-in-watcher-email-alert/115700/17):
>
> as that is a completely new topic, making it separate makes a ton of sense. You could use an html body in an email and make use of a table. You can loop through the hits like this {#ctx.payload.hits.hits}\* {\_source.my\_field}{/ctx.payload.hits.hits}

---

<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 26, 2019, 8:37pm UTC](https://discuss.elastic.co/t/ctx-payload-hits-hits-in-a-tabular-format-within-email-box/173976/2 "2019-03-26T20:37:28Z")

</div>

Hi there, have you taken a look at [Watcher Email has Incorrect Format Using Mustache Template](https://discuss.elastic.co/t/watcher-email-has-incorrect-format-using-mustache-template/29344)? This user also asked about formatting of tables in HTML. For that user, they were able to define a body like this to create an HTML table:

```auto
<head> <h1>Long Running Processes</h1> </head> <body> <table> <tr><th>Number
     1</th> <th>Number 2</th> </tr>{{#ctx.payload.hits.hits}} <tr><td>1</td> <td>2</td> </tr>
     {{/ctx.payload.hits.hits}}</table> </body>

```

I think you could adapt this to your use case too.

Hope this helps,  
CJ

---

<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 23, 2019, 8:37pm UTC](https://discuss.elastic.co/t/ctx-payload-hits-hits-in-a-tabular-format-within-email-box/173976/3 "2019-04-23T20:37:32Z")

</div>

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