I get:
error occurs at 2015-10-19T04:30:00.000Z
But our time zone is GMT+8
, So it should be 2015-10-19T12:30:00.000Z
. Is there a way do it in Email Action?
I get:
error occurs at 2015-10-19T04:30:00.000Z
But our time zone is GMT+8
, So it should be 2015-10-19T12:30:00.000Z
. Is there a way do it in Email Action?
Hey there,
you can use the the joda date time formatters to do this. This is just a quick test and it worked, I think you can do this more efficiently.
curl -XPUT 'http://localhost:9200/_watcher/watch/log_error_watch' -d '{
"trigger" : { "schedule" : { "interval" : "10s" } },
"input" : {
"search" : {
"request" : {
"indices" : [ "logs" ],
"body" : {
"query" : {
"match" : { "message": "error" }
}
}
}
}
},
"actions" : {
"log_error" : {
"transform" : {
"script" : "time = org.joda.time.format.ISODateTimeFormat.dateTime().withZone(org.joda.time.DateTimeZone.forID(\"Europe/Berlin\")).parseDateTime(ctx.trigger.triggered_time.toString()).toString() ; return [ time_as_string : time ]"
},
"logging" : {
"text" : "Converted time {{ctx.payload.time_as_string}} vs {{ctx.trigger.triggered_time}}"
}
}
}
}'
--Alex
A great thanks for your kind help! I will try it!
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.