# Can't get document message fields printed in my alerts using ctx

**URL:** https://discuss.elastic.co/t/cant-get-document-message-fields-printed-in-my-alerts-using-ctx/242513
**Category:** Kibana
**Created:** [July 24, 2020, 12:52pm UTC](https://discuss.elastic.co/t/cant-get-document-message-fields-printed-in-my-alerts-using-ctx/242513 "2020-07-24T12:52:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![danona45](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danona45/32/70726_2.png) [@danona45](https://discuss.elastic.co/u/danona45)
#### Post date: [July 24, 2020, 12:52pm UTC](https://discuss.elastic.co/t/cant-get-document-message-fields-printed-in-my-alerts-using-ctx/242513/1 "2020-07-24T12:52:30Z")

</div>

Hi,

I am trying to setup my trigger to send message to slack and embed some fields from documents sampled by my monitor.

I am using Opendistro 7.4.0 in AWS.

I only managed to reference the total hits though using the following:

```
Monitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue.
- Trigger: {{ctx.trigger.name}}
- Severity: {{ctx.trigger.severity}}
- Period start: {{ctx.periodStart}}
- Period end: {{ctx.periodEnd}}

Total hits: {{#ctx.results}}{{#hits}}{{total}}{{/hits}}{{/ctx.results}}

```

> Severity: 1
> 
> - Period start: 2020-07-24T12:35:09.949Z
> - Period end: 2020-07-24T12:36:09.949Z  
> Total hits: {value=2, relation=eq}

How do I reference fields in my message like the following?

 ![Screen Shot 2020-07-24 at 8.52.05 AM](https://us1.discourse-cdn.com/elastic/original/3X/e/2/e2c0fcf770c4cf6ef312f03e237c5f4443a27128.png)

---

<div class="post-metadata">

### Author: ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)
#### Post date: [August 12, 2020, 7:09am UTC](https://discuss.elastic.co/t/cant-get-document-message-fields-printed-in-my-alerts-using-ctx/242513/2 "2020-08-12T07:09:15Z")

</div>

Hi @danona45,

I'd recommend to open an issue at Opendistro forum: [https://discuss.opendistrocommunity.dev/latest](https://discuss.opendistrocommunity.dev/latest)

Regards,  
Marta

---

<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: [September 9, 2020, 7:09am UTC](https://discuss.elastic.co/t/cant-get-document-message-fields-printed-in-my-alerts-using-ctx/242513/3 "2020-09-09T07:09:32Z")

</div>

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