# Change the timestamp format in Watcher

**URL:** <https://discuss.elastic.co/t/change-the-timestamp-format-in-watcher/210612>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [December 5, 2019, 3:53am UTC](https://discuss.elastic.co/t/change-the-timestamp-format-in-watcher/210612 "2019-12-05T03:53:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karrie\_Koo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karrie_koo/32/52576_2.png) [@Karrie\_Koo](https://discuss.elastic.co/u/Karrie_Koo)\
**Post date:** [December 5, 2019, 3:53am UTC](https://discuss.elastic.co/t/change-the-timestamp-format-in-watcher/210612/1 "2019-12-05T03:53:12Z")

</div>

"actions": {  
"log\_error": {  
"logging": {  
"category": "watcher.logging.bppm.None",  
"level": "info",  
"text": "Found {{ctx.payload.hits.total}} exception in the server logs (EAP)\n{{#ctx.payload.hits.hits}}[MINOR] {{\_source.@timestamp}} {{\_source.hostname}} {{\_source.wlsdomain}} {{\_source.wlsname}} {{\_source.msgId}}\n{{/ctx.payload.hits.hits}}"  
}  
}  
}

My Question is how to change the format of {{\_source.@timestamp}}??

This is the result:  
[None] 2019-12-04 10:45:56 Found 1 exception in the server logs (EAP)  
[MINOR] 2019-Dec-04 10:42:08.782 HKT eapdev1c wlsx\_eprsvc\_dev EprsvcCorpJmsDev\_eapdev1c\_11627 BEA-310003

I would like to change the format from 2019-Dec-04 10:42:08.782 HKT to 2019-12-04 10:42:08.

Many thanks.

---

<div class="post-metadata">

**Author:** ![Karrie\_Koo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karrie_koo/32/52576_2.png) [@Karrie\_Koo](https://discuss.elastic.co/u/Karrie_Koo)\
**Post date:** [December 5, 2019, 3:57am UTC](https://discuss.elastic.co/t/change-the-timestamp-format-in-watcher/210612/2 "2019-12-05T03:57:56Z")

</div>

```
              "range": {
                "@timestamp": {
                  "format": "basic_date_time_no_millis",
                  "time_zone": "Hongkong",
                  "gte": "now-1d/d",
                  "lte": "now"
                }
              }
            },

```

I have tried to change the format, but it doesnt work indeed.

---

<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:** [December 6, 2019, 12:00pm UTC](https://discuss.elastic.co/t/change-the-timestamp-format-in-watcher/210612/3 "2019-12-06T12:00:11Z")

</div>

you need to use a [script transform](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/transform-script.html) and then change the format of the date, before using it in a mustache template.

---

<div class="post-metadata">

**Author:** ![Karrie\_Koo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karrie_koo/32/52576_2.png) [@Karrie\_Koo](https://discuss.elastic.co/u/Karrie_Koo)\
**Post date:** [December 11, 2019, 1:46am UTC](https://discuss.elastic.co/t/change-the-timestamp-format-in-watcher/210612/4 "2019-12-11T01:46:08Z")

</div>

> [@Karrie\_Koo](#):
>
> basic\_date\_time\_no\_millis

GET /eap\_wls\_server\*/\_search  
{  
"\_source":"msgId",  
"query": {  
"match\_all": {}  
},  
"script\_fields": {  
"@timestamp": {  
"script": "doc['@timestamp'].value.toString('yyyy-MM-dd HH:mm:ss')"  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Karrie\_Koo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karrie_koo/32/52576_2.png) [@Karrie\_Koo](https://discuss.elastic.co/u/Karrie_Koo)\
**Post date:** [December 11, 2019, 1:46am UTC](https://discuss.elastic.co/t/change-the-timestamp-format-in-watcher/210612/5 "2019-12-11T01:46:40Z")

</div>

I still cannot transform the format

---

<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:** [January 8, 2020, 1:46am UTC](https://discuss.elastic.co/t/change-the-timestamp-format-in-watcher/210612/6 "2020-01-08T01:46:48Z")

</div>

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