# Attach path and timestamp of log found, in the e-mail notification

**URL:** https://discuss.elastic.co/t/attach-path-and-timestamp-of-log-found-in-the-e-mail-notification/134738
**Category:** Elasticsearch
**Tags:** elastic-stack-alerting
**Created:** [June 6, 2018, 6:54am UTC](https://discuss.elastic.co/t/attach-path-and-timestamp-of-log-found-in-the-e-mail-notification/134738 "2018-06-06T06:54:42Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![varun48](https://avatars.discourse-cdn.com/v4/letter/v/eb8c5e/32.png) [@varun48](https://discuss.elastic.co/u/varun48)
#### Post date: [June 6, 2018, 6:54am UTC](https://discuss.elastic.co/t/attach-path-and-timestamp-of-log-found-in-the-e-mail-notification/134738/1 "2018-06-06T06:54:42Z")

</div>

I have created a watcher.

When I put the query in Discover search box, I get the following output:

![image](https://us1.discourse-cdn.com/elastic/original/3X/2/5/2569339358d0c2d3a0fb932cdd886e59a9d75576.jpg)

We are searching for a functionality to provide values of path and @timestamp in e-mail notification as shown for each result in the Discover window.

Alternatively, Is there any way to attach all JSON files generated by search result as shown in Discover window of Kibana, in e-mail notification:

![image](https://us1.discourse-cdn.com/elastic/original/3X/a/2/a2d6521e7dce342901ad8facaf7292060c6fbf26.jpg)

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [June 6, 2018, 7:34am UTC](https://discuss.elastic.co/t/attach-path-and-timestamp-of-log-found-in-the-e-mail-notification/134738/2 "2018-06-06T07:34:11Z")

</div>

Hey,

you can use mustache in the email body to access arbitrary data from the input. See the [example in the docs](https://www.elastic.co/guide/en/elastic-stack-overview/6.3/actions-email.html#configuring-email-actions). In order to access the first searchhit, you could try `ctx.payload.hits.hits.0._source.@timestamp`.

Hope this helps!

--Alex

---

<div class="post-metadata">

### Author: ![varun48](https://avatars.discourse-cdn.com/v4/letter/v/eb8c5e/32.png) [@varun48](https://discuss.elastic.co/u/varun48)
#### Post date: [June 6, 2018, 9:57am UTC](https://discuss.elastic.co/t/attach-path-and-timestamp-of-log-found-in-the-e-mail-notification/134738/3 "2018-06-06T09:57:41Z")

</div>

Thanks Alex,

I have used you suggested but not seeing the value of @timestamp in the e-mail.

Used it like this in e-mail body in JSON of watcher:

"body": {  
"text": "Timestamp:{{ctx.payload.hits.hits.0.\_source.@timestamp}}"  
}

I am new to Kibana. May be making a basic mistake.

---

<div class="post-metadata">

### Author: ![varun48](https://avatars.discourse-cdn.com/v4/letter/v/eb8c5e/32.png) [@varun48](https://discuss.elastic.co/u/varun48)
#### Post date: [June 6, 2018, 10:18am UTC](https://discuss.elastic.co/t/attach-path-and-timestamp-of-log-found-in-the-e-mail-notification/134738/4 "2018-06-06T10:18:21Z")

</div>

Hi Alex,

One more thing I found regarding \_source.

When I try to print {{ctx.payload}} in the e-mail, I am not seeing anything in the \_source:

![image](https://us1.discourse-cdn.com/elastic/original/3X/e/4/e4ffff8c28526373e562b67fe5db06bb3163a1b1.png)

Is the empty \_source is the reason I am not able to see value of @timestamp in the e-mail.

Regards,  
Varun

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [June 6, 2018, 3:44pm UTC](https://discuss.elastic.co/t/attach-path-and-timestamp-of-log-found-in-the-e-mail-notification/134738/5 "2018-06-06T15:44:52Z")

</div>

can you retrieve the source of that document by calling `GET index/doc/ID_OF_DOC/_source` and `GET index/doc/ID_OF_DOC` - looks as if there is no JSON in that document.

Also please include the whole query here or better yet the whole watch and the whole execute watch API output instead of snippets. This would ease debugging tremendously.

---

<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: [July 4, 2018, 3:48pm UTC](https://discuss.elastic.co/t/attach-path-and-timestamp-of-log-found-in-the-e-mail-notification/134738/6 "2018-07-04T15:48:44Z")

</div>

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