Hello, good people.
I have a problem with an alert, I get the following error:
{
"watch_id": "_inlined_",
"node": "ELuSGxpSRICZb2ZHJp4paA",
"state": "failed",
"user": "elastic",
"status": {
"state": {
"active": true,
"timestamp": "2021-08-26T17:14:34.455Z"
},
"actions": {
"email_1": {
"ack": {
"timestamp": "2021-08-26T17:14:34.455Z",
"state": "awaits_successful_execution"
}
}
},
"execution_state": "failed",
"version": -1
},
"trigger_event": {
"type": "manual",
"triggered_time": "2021-08-26T17:14:34.460Z",
"manual": {
"schedule": {
"scheduled_time": "2021-08-26T17:14:34.460Z"
}
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"uniandes*"
],
"rest_total_hits_as_int": true,
"body": {
"size": 0,
"query": {
"bool": {
"filter": {
"range": {
"@timestamp": {
"gte": "now-2m/m",
"lt": "now/m"
}
}
}
},
"aggs": {
"terms": {
"size": 10,
"field": "Sysname.keyword"
},
"terms2": {
"size": 10,
"field": "IP.keyword"
},
"metricAgg": {
"max": {
"field": "State"
}
}
}
}
}
}
}
},
"condition": {
"script": {
"source": "if (ctx.payload.aggregations.metricAgg.value == params.threshold) { return true; } return false;",
"lang": "painless",
"params": {
"threshold": 0
}
}
},
"metadata": {
"name": "Alerta Estado uniandes",
"xpack": {
"type": "json"
}
},
"result": {
"execution_time": "2021-08-26T17:14:34.460Z",
"execution_duration": 0,
"input": {
"type": "search",
"status": "failure",
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[bool] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 1,
"col": 95
}
],
"type": "parsing_exception",
"reason": "[bool] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 1,
"col": 95
},
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"uniandes*"
],
"rest_total_hits_as_int": true,
"body": {
"size": 0,
"query": {
"bool": {
"filter": {
"range": {
"@timestamp": {
"gte": "now-2m/m",
"lt": "now/m"
}
}
}
},
"aggs": {
"terms": {
"size": 10,
"field": "Sysname.keyword"
},
"terms2": {
"size": 10,
"field": "IP.keyword"
},
"metricAgg": {
"max": {
"field": "State"
}
}
}
}
}
}
}
},
"actions": []
},
"messages": [
"failed to execute watch input"
]
}
this is my code:
{
"trigger": {
"schedule": {
"interval": "2m"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"uniandes*"
],
"rest_total_hits_as_int": true,
"body": {
"size": 0,
"query": {
"bool": {
"filter":
{
"range": {
"@timestamp": {
"gte": "now-2m/m",
"lt": "now/m"
}
}
}
},
"aggs":{
"terms": {
"size": 10,
"field": "Sysname.keyword"
},
"terms2":{
"size": 10,
"field":"IP.keyword"
},
"metricAgg":{
"max":{
"field":"State"
}
}
}
}
}
}
}
},
"condition": {
"script": {
"source": "if (ctx.payload.aggregations.metricAgg.value == params.threshold) { return true; } return false;",
"lang": "painless",
"params": {
"threshold": 0
}
}
},
"actions": {
"email_1": {
"throttle_period_in_millis": 86400000,
"email": {
"profile": "standard",
"attach_data": {
"format": "yaml"
},
"to": [
"juan.jaramillo@megadvantage.com"
],
"bcc": [
"juancho.jaramillo16@gmail.com"
],
"subject": "{{ctx.metadata.name}} ",
"body": {
"text": """
🚨ALerta Host!! el Estado del equipo {{}} con la IP {{ctx.payload.terms}} ha excedido el umbral, para mas informacion ingrese al siguiente enlace:
"""
}
}
}
},
"transform": {
"script": {
"source": """
return [
'local_execution_time' : ctx.trigger.triggered_time.withZoneSameInstant(ZoneId.of('America/Bogota')).format(DateTimeFormatter.ofPattern('YYYY-MM-dd HH:mm:ss')),
'terms' : ctx.payload.aggregations.terms,
'terms2': ctx.payload.aggregations.terms2,
'metricAgg' : ctx.payload.aggregations.metricAgg.value
]
""",
"lang": "painless"
}
}
}
I hope you can help me, as this is very important, thank you very much!