Watcher Timezone problem in email body

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 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.

add a new script field:

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

and use timestamp_local in your alerting

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

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