I'm trying to convert the time to my local time, but I get an error, I need to send to the mail the real time which is GMT-5 America/Bogota
{
"trigger": {
"schedule": {
"interval": "1h"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"agenteallot*"
],
"rest_total_hits_as_int": true,
"body": {
"size": 0,
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"gte": "{{ctx.trigger.scheduled_time}}||-5m",
"lte": "{{ctx.trigger.scheduled_time}}",
"format": "strict_date_optional_time||basic_time_no_millis"
}
}
},
{
"term": {
"monitor.name.keyword": "01-1-CAV30328203-DATOS-PPAL-2.7G-99.98"
}
}
]
}
},
"aggs": {
"metricAgg": {
"max": {
"field": "summary.down"
}
}
}
}
}
}
},
"condition": {
"script": {
"source": "if (ctx.payload.aggregations.metricAgg.value >= params.threshold) { return true; } return false;",
"lang": "painless",
"params": {
"threshold": 0.8
}
}
},
"actions": {
"email_1": {
"transform": {
"script": "ZonedDateTime zdt = ZonedDateTime.parse(ctx.execution_time['@timestamp']);"},
"email": {
"profile": "standard",
"attach_data": {
"format": "json"
},
"to": [
"juan.jaramillo@megadvantage.com",
"juancho.jaramillo16@gmail.com",
"victor.vera@megadvantage.com"
],
"subject": "{{ctx.metadata.name}} 01-1-CAV30328203-DATOS-PPAL-2.7G-99.98",
"body": {
"text": """Buen dia, Adjunto registro del reporte.
⚠️ALERTA NODO!!! El siguiente enlace perdió la conexión.
Estado: Down🔴
Nombre del Enlace: 01-1-CAV30328203-DATOS-PPAL-2.7G-99.98
🕧Hora: {{ctx.execution_time}}
Área: Networking
🔔Mensaje Alerta: El enlace ha dejado de responder. Responder correo a telecomunicaciones@udistrital.edu.co
Ingrese aquí para más información: https://72dfe17217744236af40cc31b704a664.us-central1.gcp.cloud.es.io:9243/s/distrital/app/uptime#"""
}
}
}
},
"transform": {
"script": {
"source": "HashMap result = new HashMap(); result.result = ctx.payload.aggregations.metricAgg.value; return result;",
"lang": "painless",
"params": {
"threshold": 0.8
}
}
}
}
this is the error I have
{
"watch_id": "_inlined_",
"node": "ELuSGxpSRICZb2ZHJp4paA",
"state": "executed",
"user": "elastic",
"status": {
"state": {
"active": true,
"timestamp": "2020-10-15T22:11:28.938Z"
},
"last_checked": "2020-10-15T22:11:28.942Z",
"last_met_condition": "2020-10-15T22:11:28.942Z",
"actions": {
"email_1": {
"ack": {
"timestamp": "2020-10-15T22:11:28.938Z",
"state": "awaits_successful_execution"
},
"last_execution": {
"timestamp": "2020-10-15T22:11:28.942Z",
"successful": false,
"reason": "Failed to transform payload"
}
}
},
"execution_state": "executed",
"version": -1
},
"trigger_event": {
"type": "manual",
"triggered_time": "2020-10-15T22:11:28.942Z",
"manual": {
"schedule": {
"scheduled_time": "2020-10-15T22:11:28.942Z"
}
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"agenteallot*"
],
"rest_total_hits_as_int": true,
"body": {
"size": 0,
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"gte": "{{ctx.trigger.scheduled_time}}||-5m",
"lte": "{{ctx.trigger.scheduled_time}}",
"format": "strict_date_optional_time||basic_time_no_millis"
}
}
},
{
"term": {
"monitor.name.keyword": "01-1-CAV30328203-DATOS-PPAL-2.7G-99.98"
}
}
]
}
},
"aggs": {
"metricAgg": {
"max": {
"field": "summary.up"
}
}
}
}
}
}
},
"condition": {
"script": {
"source": "if (ctx.payload.aggregations.metricAgg.value >= params.threshold) { return true; } return false;",
"lang": "painless",
"params": {
"threshold": 0.8
}
}
},
"metadata": {
"name": "Alerta caída enlace 01-1-CAV30328203-DATOS-PPAL-2.7G-99.98",
"xpack": {
"type": "json"
}
},
"result": {
"execution_time": "2020-10-15T22:11:28.942Z",
"execution_duration": 708,
"input": {
"type": "search",
"status": "success",
"payload": {
"_shards": {
"total": 1,
"failed": 0,
"successful": 1,
"skipped": 0
},
"hits": {
"hits": [],
"total": 5,
"max_score": null
},
"took": 705,
"timed_out": false,
"aggregations": {
"metricAgg": {
"value": 1
}
}
},
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"agenteallot*"
],
"rest_total_hits_as_int": true,
"body": {
"size": 0,
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"gte": "2020-10-15T22:11:28.942168Z||-5m",
"lte": "2020-10-15T22:11:28.942168Z",
"format": "strict_date_optional_time||basic_time_no_millis"
}
}
},
{
"term": {
"monitor.name.keyword": "01-1-CAV30328203-DATOS-PPAL-2.7G-99.98"
}
}
]
}
},
"aggs": {
"metricAgg": {
"max": {
"field": "summary.up"
}
}
}
}
}
}
},
"condition": {
"type": "script",
"status": "success",
"met": true
},
"transform": {
"type": "script",
"status": "success",
"payload": {
"result": 1
}
},
"actions": [
{
"id": "email_1",
"type": "email",
"status": "failure",
"transform": {
"type": "script",
"status": "failure",
"reason": "runtime error",
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"zdt = ZonedDateTime.parse(ctx.execution_time['@timestamp']);",
" ^---- HERE"
],
"script": "ZonedDateTime zdt = ZonedDateTime.parse(ctx.execution_time['@timestamp']);",
"lang": "painless",
"position": {
"offset": 43,
"start": 14,
"end": 74
}
}
],
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"zdt = ZonedDateTime.parse(ctx.execution_time['@timestamp']);",
" ^---- HERE"
],
"script": "ZonedDateTime zdt = ZonedDateTime.parse(ctx.execution_time['@timestamp']);",
"lang": "painless",
"position": {
"offset": 43,
"start": 14,
"end": 74
},
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Attempting to address a non-array-like type [org.elasticsearch.script.JodaCompatibleZonedDateTime] as an array."
}
}
},
"reason": "Failed to transform payload"
}
]
},
"messages": []
}