# Ctx.results in Kibana Alerting

**URL:** <https://discuss.elastic.co/t/ctx-results-in-kibana-alerting/221473>\
**Category:** Kibana\
**Created:** [February 28, 2020, 5:56pm UTC](https://discuss.elastic.co/t/ctx-results-in-kibana-alerting/221473 "2020-02-28T17:56:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Priyan\_Murugan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priyan_murugan/32/61218_2.png) [@Priyan\_Murugan](https://discuss.elastic.co/u/Priyan_Murugan)\
**Post date:** [February 28, 2020, 5:56pm UTC](https://discuss.elastic.co/t/ctx-results-in-kibana-alerting/221473/1 "2020-02-28T17:56:51Z")

</div>

Hi

I have created the below mustache template to send alert notification to slack.

Mustache Template:

- Total hits: {{#ctx.results}}{{#hits}}{{total}}{{/hits}}{{/ctx.results}}
- Period start: {{ctx.periodStart}}
- Period end: {{ctx.periodEnd}}
- Error Details:  
{{#ctx.results}}  
{{#hits}}  
{{#hits}}  
{{#\_source}}  
StoreId: {{StoreId}}  
Env: {{Env}}  
App: {{App}} :  
LogType: {{LogType}}  
LogTime: {{LogTime}}  
LogDetails: {{LogDetails}}  
{{/\_source}}  
{{/hits}}  
{{/hits}}  
{{/ctx.results}}

Result:

- Total hits: 5
- Period start: 2020-02-28T16:58:00Z
- Period end: 2020-02-28T17:03:00Z
- Error Details:  
StoreId: 7523434  
Env: prod  
App: S2SB :  
LogType: API\_ERROR  
LogTime: 2020-02-28T16:28:40  
LogDetails: Error: TypeError: Network request failed  
StoreId: 7523434  
Env: prod  
App: S2SB :  
LogType: API\_ERROR  
LogTime: 2020-02-28T16:35:24  
LogDetails: Error: TypeError: Network request failed  
StoreId: 7523434  
Env: prod  
App: S2SB :  
LogType: API\_ERROR  
LogTime: 2020-02-28T16:48:21  
LogDetails: Error: TypeError: Network request failed  
StoreId: 7523434  
Env: prod  
App: S2SB :  
LogType: API\_ERROR  
LogTime: 2020-02-28T16:58:29  
LogDetails: Error: TypeError: Network request failed  
StoreId: 8973452  
Env: prod  
App: S2SD :  
LogType: API\_ERROR  
LogTime: 2020-02-28T16:46:21  
LogDetails: API ERROR FINAL:

Actually I need the output to be sorted with only one unique store id or I need to list the output in a Table format as StoreId, APP and Log Details alone.  
Is there any possibilities to modify the mustache template according to that. I have tried multiple resources but no examples for unique or table format. If someone could help on this it would be very helpful

---

<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:** [March 27, 2020, 5:57pm UTC](https://discuss.elastic.co/t/ctx-results-in-kibana-alerting/221473/2 "2020-03-27T17:57:04Z")

</div>

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