# Watcher Timezone problem in email body

**URL:** <https://discuss.elastic.co/t/watcher-timezone-problem-in-email-body/285957>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting, painless\
**Created:** [October 5, 2021, 6:21pm UTC](https://discuss.elastic.co/t/watcher-timezone-problem-in-email-body/285957 "2021-10-05T18:21:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tombal](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@Tombal](https://discuss.elastic.co/u/Tombal)\
**Post date:** [October 5, 2021, 6:21pm UTC](https://discuss.elastic.co/t/watcher-timezone-problem-in-email-body/285957/1 "2021-10-05T18:21:42Z")

</div>

Hello ,  
Not a pro of painless language but while my ml job is working fine.  
It seems like timezone is GMT not GMT+3 in my mail body.

> "subject": "Apigw ML Time Alerts...",  
> "body": {  
> "html": "\n \n **\n Elastic Stack Machine Learning Alert\n** \n   
> \n   
> \n\n **\n Job\n** : {{ctx.payload.aggregations.bucket\_results.top\_bucket\_hits.hits.hits.0.\_source.job\_id}}\n   
> \n\n **\n Time\n** : {{ctx.payload.aggregations.bucket\_results.top\_bucket\_hits.hits.hits.0.fields._ **timestamp\_iso8601** _.0}}\n   
> \n\n **\n Anomaly score\n** :

This is timestamp\_8601 stated;

> "timestamp\_iso8601": {  
> "script": {  
> "lang": "painless",  
> "source": "doc["timestamp"].value"  
> }

In My mail body time is shown wrong;  
Below time must be **2021-10-05T01:20** not **2021-10-04T22:20**

> **Job** : apigw\_timecheck  
> **Time** : **2021-10-04T22:20:00.000Z**  
> **Anomaly score** : 91
> 
> [Click here to open in Anomaly Explorer.] xxxxxxxxxxxxxxxxxxxxxxxx
> 
> **Top records:**  
> high\_mean(backend\_time\_elapsed) /tpay/provision/services/restful/getCardToken/getTermsOfServiceContent [99]  
> high\_mean(backend\_time\_elapsed) /tpay/provision/services/restful/getCardToken/getCards [99]

I will be glad if i can add +3hours to time in mail body.

---

<div class="post-metadata">

**Author:** ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)\
**Post date:** [October 6, 2021, 2:20pm UTC](https://discuss.elastic.co/t/watcher-timezone-problem-in-email-body/285957/2 "2021-10-06T14:20:16Z")

</div>

add a new `script` field:

```auto
            "timestamp_local": {
              "script": {
                  "lang": "painless",
                  "source": """Instant.ofEpochMilli(doc["timestamp"].value.millis).atZone(ZoneOffset.ofHours(+3))"""
                }
            },

```

and use `timestamp_local` in your alerting

---

<div class="post-metadata">

**Author:** ![Tombal](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@Tombal](https://discuss.elastic.co/u/Tombal)\
**Post date:** [October 28, 2021, 7:39pm UTC](https://discuss.elastic.co/t/watcher-timezone-problem-in-email-body/285957/3 "2021-10-28T19:39:57Z")

</div>

Sorry for the late return i tried it the day after ,it worked much appreciated...

---

<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:** [November 25, 2021, 7:40pm UTC](https://discuss.elastic.co/t/watcher-timezone-problem-in-email-body/285957/4 "2021-11-25T19:40:54Z")

</div>

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