# How to print my error stack trace from watchers or/and alerts in an email?

**URL:** <https://discuss.elastic.co/t/how-to-print-my-error-stack-trace-from-watchers-or-and-alerts-in-an-email/270296>\
**Category:** Kibana\
**Tags:** elastic-stack-alerting\
**Created:** [April 15, 2021, 6:35pm UTC](https://discuss.elastic.co/t/how-to-print-my-error-stack-trace-from-watchers-or-and-alerts-in-an-email/270296 "2021-04-15T18:35:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rem](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@Rem](https://discuss.elastic.co/u/Rem)\
**Post date:** [April 15, 2021, 6:35pm UTC](https://discuss.elastic.co/t/how-to-print-my-error-stack-trace-from-watchers-or-and-alerts-in-an-email/270296/1 "2021-04-15T18:35:37Z")

</div>

The title said it all.

```auto
"actions": {
        "email_action": {
          "throttle_period_in_millis": 900000,
          "email": {
            "profile": "standard",
            "to": [
              "myEmail@SMTP.com"
            ],
            "subject": "{{ctx.payload.hits.total}} Errors have occured in the logs",
            "body": {
              "text": "{{ctx.payload.hits.total}} Errors have occured in the logs in the last X minute. You can check the latest in the below link",
              "html": "Error name or error stack trace: {ctx._source.@timestamp} {{ctx._source.@timestamp}} {{ctx.payload.hits.2._source.@timestamp}} {{ctx.payload.hits.3._source.@timestamp}}"
            }
          }
        }
      },

```

That does not work. Any cue?

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [April 22, 2021, 1:24pm UTC](https://discuss.elastic.co/t/how-to-print-my-error-stack-trace-from-watchers-or-and-alerts-in-an-email/270296/2 "2021-04-22T13:24:29Z")

</div>

Are you getting any errors when running that or just not displaying any results?

---

<div class="post-metadata">

**Author:** ![Rem](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@Rem](https://discuss.elastic.co/u/Rem)\
**Post date:** [April 27, 2021, 3:23pm UTC](https://discuss.elastic.co/t/how-to-print-my-error-stack-trace-from-watchers-or-and-alerts-in-an-email/270296/3 "2021-04-27T15:23:38Z")

</div>

Sorry for my late reply.

I'm not having any errors because I receive the email.  
In the email, it is not displaying any results often replacing the variable by blank.

Like that:  
**HostName**

&& && Query Link: [https://URL](https://URL) [{ctx.\_source.@timestamp}]

Between the '&', there are only blanks.

---

<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:** [May 25, 2021, 3:24pm UTC](https://discuss.elastic.co/t/how-to-print-my-error-stack-trace-from-watchers-or-and-alerts-in-an-email/270296/4 "2021-05-25T15:24:35Z")

</div>

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