# I want to configure threshold alert if totaltime exceeds 500 then mail should sent to the User

**URL:** https://discuss.elastic.co/t/i-want-to-configure-threshold-alert-if-totaltime-exceeds-500-then-mail-should-sent-to-the-user/248136
**Category:** Elasticsearch
**Tags:** elastic-stack-reporting, elastic-stack-alerting
**Created:** [September 10, 2020, 8:53am UTC](https://discuss.elastic.co/t/i-want-to-configure-threshold-alert-if-totaltime-exceeds-500-then-mail-should-sent-to-the-user/248136 "2020-09-10T08:53:16Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![AKumar123](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@AKumar123](https://discuss.elastic.co/u/AKumar123)
#### Post date: [September 10, 2020, 8:53am UTC](https://discuss.elastic.co/t/i-want-to-configure-threshold-alert-if-totaltime-exceeds-500-then-mail-should-sent-to-the-user/248136/1 "2020-09-10T08:53:16Z")

</div>

I am able to send mail with some information but Particular data i want to fetch in table.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/5/85672bbd0ac87ad5a85d29a83dcef1b3cdf10bfa.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/b/9b7364207f56db8d453cd49c4cae0e45d0a2a928.png)

Alert Configuration i pasted in this link:[https://pastebin.com/A6fDZYKY](https://pastebin.com/A6fDZYKY)

Field Name and index name as follows:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/2/62def45dbdb5dc42760b732df4b3157b1d7dc1e4.png)

---

<div class="post-metadata">

### Author: ![Josip\_Cagalj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/josip_cagalj/32/42899_2.png) [@Josip\_Cagalj](https://discuss.elastic.co/u/Josip_Cagalj)
#### Post date: [September 10, 2020, 9:16am UTC](https://discuss.elastic.co/t/i-want-to-configure-threshold-alert-if-totaltime-exceeds-500-then-mail-should-sent-to-the-user/248136/2 "2020-09-10T09:16:12Z")

</div>

Hi Anant  
Glad I could help you with your code earlier. One thing I didn't correct in that code is the `"size": 0,` part. You should remove it because this is causing no document (hit) is returned, only the count! That's why you see no data. You could limit what fields are returned also if you want.

You could try to run just the `query` part of your watcher trough Kibana console (developer tools) to see if you'll get hits (you could also play with the time period to get more hits)

---

<div class="post-metadata">

### Author: ![AKumar123](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@AKumar123](https://discuss.elastic.co/u/AKumar123)
#### Post date: [September 10, 2020, 10:08am UTC](https://discuss.elastic.co/t/i-want-to-configure-threshold-alert-if-totaltime-exceeds-500-then-mail-should-sent-to-the-user/248136/3 "2020-09-10T10:08:29Z")

</div>

Yes It worked but data not coming in table form:

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

---

<div class="post-metadata">

### Author: ![Josip\_Cagalj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/josip_cagalj/32/42899_2.png) [@Josip\_Cagalj](https://discuss.elastic.co/u/Josip_Cagalj)
#### Post date: [September 10, 2020, 10:30am UTC](https://discuss.elastic.co/t/i-want-to-configure-threshold-alert-if-totaltime-exceeds-500-then-mail-should-sent-to-the-user/248136/4 "2020-09-10T10:30:04Z")

</div>

Ok, did you sanitized HTML tags? Look [here](https://www.elastic.co/guide/en/elasticsearch/reference/7.9/actions-email.html#email-html-sanitization)  
You can inspect your watcher execution history to see what happened. In Kibana on the left side under the Elasticsearch group select Watcher, then from the list select your watcher, then from a list of execution history select one, e.g. most recent one. That will open a JSON file in the right part of your screen. Navigate towards the bottom of it and find the email action (if the watcher condition was met the action will be performed). There you should see your email HTML body, inspect it if it was constructed as you need it to be (are all the tags needed for a table there, or you can copy the whole HTML and paste it in some online HTML editor or something).  
You can get the watcher execution result if you run it through developer tools (Kibana console) by executing  
`PUT _watcher/watch/*<your_watcher_name>*/_execute`  
and look for the email body as explained above.

P.S.  
Copy the email body, hide the sensitive data (replace them with something) and paste it here so we can see it

---

<div class="post-metadata">

### Author: ![AKumar123](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@AKumar123](https://discuss.elastic.co/u/AKumar123)
#### Post date: [September 10, 2020, 11:12am UTC](https://discuss.elastic.co/t/i-want-to-configure-threshold-alert-if-totaltime-exceeds-500-then-mail-should-sent-to-the-user/248136/5 "2020-09-10T11:12:06Z")

</div>

> [@Josip\_Cagalj](#):
>
> PUT \_watcher/watch/_\<your\_watcher\_name\>_/\_execute

Yes I have configured:  
xpack.notification.email.html.sanitization.allow: true  
xpack.notification.email.html.sanitization:  
allow: \_tables, \_blocks  
disallow: h4, h5, h6

Watcher json Data:[{ "watch\_id": "9c92d55f-169d-4b9c-8671-4fff54f6e5cd", "node": "Ov4pBby1T7q - Pastebin.com](https://pastebin.com/SrBpts5X)

mail Output and alert Config:

> **[Mail Output:Hello Team,There are 4 long running process on these sever in th...](https://pastebin.com/Mj9Nph1Y)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

elastic config:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/d/cda16d2b9f91f56428f82300f175f46d9c91aa56.png)

---

<div class="post-metadata">

### Author: ![Josip\_Cagalj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/josip_cagalj/32/42899_2.png) [@Josip\_Cagalj](https://discuss.elastic.co/u/Josip_Cagalj)
#### Post date: [September 10, 2020, 12:31pm UTC](https://discuss.elastic.co/t/i-want-to-configure-threshold-alert-if-totaltime-exceeds-500-then-mail-should-sent-to-the-user/248136/6 "2020-09-10T12:31:25Z")

</div>

If you're constructing the table as I showed you how, with the styles for `<table>`, `<th>`, and `<td>` tags

```auto
"body": {
	"html": "<p>Hello Team,There are {{ctx.payload.hits.total}} long running process on these sever in the last minute. Find details below:</p><p><table style='border-collapse:collapse;border-spacing:0;border-color:#ccc'><th style='font-weight:bold;padding:4px 8px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:inherit;color:#333333;background-color:#c0c0c0;text-align:center;vertical-align:middle'>Server</th><th style='font-weight:bold;padding:4px 8px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:inherit;color:#333333;background-color:#c0c0c0;text-align:center;vertical-align:middle'>Process</th><th style='font-weight:bold;padding:4px 8px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:inherit;color:#333333;background-color:#c0c0c0;text-align:center;vertical-align:middle'>User</th><th style='font-weight:bold;padding:4px 8px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:inherit;color:#333333;background-color:#c0c0c0;text-align:center;vertical-align:middle'>Time</th></tr> {{#ctx.payload.hits.hits}} <tr><td style='padding:4px 8px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#ccc;color:#333;background-color:#fff;text-align:left;vertical-align:top'> {{_source.server}}</td><td style='padding:4px 8px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#ccc;color:#333;background-color:#fff;text-align:left;vertical-align:top'> {{_source.process}}</td><td style='padding:4px 8px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#ccc;color:#333;background-color:#fff;text-align:left;vertical-align:top'> {{_source.user}}</td><td style='padding:4px 8px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#ccc;color:#333;background-color:#fff;text-align:left;vertical-align:top'> {{_source.totaltime}}</td> </tr> {{/ctx.payload.hits.hits}} </table></p> <p>Regards, Team Admin</p>"
}

```

then the problem could be that you need to add `_styles` to your allowed sanitized items. E.g. this is my settings:

```auto
xpack:
  notification:
    email:
      html:
        sanitization:
          allow: "_tables, _blocks, _formating, _styles"  

```

---

<div class="post-metadata">

### Author: ![AKumar123](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@AKumar123](https://discuss.elastic.co/u/AKumar123)
#### Post date: [September 11, 2020, 11:29am UTC](https://discuss.elastic.co/t/i-want-to-configure-threshold-alert-if-totaltime-exceeds-500-then-mail-should-sent-to-the-user/248136/7 "2020-09-11T11:29:22Z")

</div>

- List item

1. List item

Yes Thanks It worked for me.Thanks for the solution which you provided.

1. List item

I am using Kibana 7.9 Version and Using alert and Reporting feature with Trail One month License.My question is there any way i can install any plugin like sentinl which is not compatble with 7.9.

If you suggest any plugin which i can use free open source instead of buying license

---

<div class="post-metadata">

### Author: ![AKumar123](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@AKumar123](https://discuss.elastic.co/u/AKumar123)
#### Post date: [September 11, 2020, 6:27pm UTC](https://discuss.elastic.co/t/i-want-to-configure-threshold-alert-if-totaltime-exceeds-500-then-mail-should-sent-to-the-user/248136/8 "2020-09-11T18:27:02Z")

</div>

Hi Josip

Do you have idea

---

<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: [October 9, 2020, 6:27pm UTC](https://discuss.elastic.co/t/i-want-to-configure-threshold-alert-if-totaltime-exceeds-500-then-mail-should-sent-to-the-user/248136/9 "2020-10-09T18:27:03Z")

</div>

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