hello good, I need help with the trigger of an alert, I want it to run when another alert has been executed, I do not know if you explain to me when I detect that another alert has been executed this is executed. I do not know if this is possible, but I need to know if it can be done, thanks.
this is the alert I need to activate when the other one has been executed...
{
"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": "04-1-CAV30CI1012712-VIVERO-PPAL-384M-99.8"
}
}
]
}
},
"aggs": {
"metricAgg": {
"max": {
"field": "summary.down"
}
}
}
}
}
}
},
"condition": {
"script": {
"source": "if (ctx.payload.aggregations.metricAgg.value >= params.threshold) { return false; } return true;",
"lang": "painless",
"params": {
"threshold": 0.8
}
}
},
"actions": {
"email_1": {
"email": {
"profile": "standard",
"attach_data": {
"format": "yaml"
},
"to": [
"victor.vera@megadvantage.com",
"telecomunicaciones@udistrital.edu.co",
"juan.jaramillo@megadvantage.com",
"juancho.jaramillo16@gmail.com",
"oscar.ninog.pr@etb.com.co",
"jose.caceresg@etb.com.co",
"karen.marriagaj.pr@etb.com.co"
],
"subject": "{{ctx.metadata.name}} ",
"body": {
"text": """Buen dia, Adjunto registro del reporte.
鈿狅笍ALERTA NODO!!! El siguiente enlace ha restablecido la conexi贸n.
Estado: UP馃煝
Nombre del Enlace: 04-1-CAV30CI1012712-VIVERO-PPAL-384M-99.8
馃暓Hora: {{ctx.payload.time_triggered}} {{ctx.result.execution_time}}
脕rea: Networking
馃敂Mensaje Alerta: El enlace ha vuelto a 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": "return [ 'time_triggered': Instant.ofEpochMilli(ctx.trigger.triggered_time.getMillis()).atZone(ZoneId.of('America/Bogota')).format(DateTimeFormatter.ofPattern('YYYY-MM-dd HH:mm:ss')) ];",
"lang": "painless"
}
}
}
and this is the alert that is executed before the previous one is activated....
{
"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": "04-1-CAV30CI1012712-VIVERO-PPAL-384M-99.8"
}
}
]
}
},
"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": {
"email": {
"profile": "standard",
"attach_data": {
"format": "yaml"
},
"to": [
"victor.vera@megadvantage.com",
"telecomunicaciones@udistrital.edu.co",
"juan.jaramillo@megadvantage.com",
"juancho.jaramillo16@gmail.com",
"oscar.ninog.pr@etb.com.co",
"jose.caceresg@etb.com.co",
"karen.marriagaj.pr@etb.com.co"
],
"subject": "{{ctx.metadata.name}} ",
"body": {
"text": """Buen dia, Adjunto registro del reporte.
鈿狅笍ALERTA NODO!!! El siguiente enlace perdi贸 la conexi贸n.
Estado: Down馃敶
Nombre del Enlace: 04-1-CAV30CI1012712-VIVERO-PPAL-384M-99.8
馃暓Hora: {{ctx.payload.time_triggered}} {{ctx.result.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": "return [ 'time_triggered': Instant.ofEpochMilli(ctx.trigger.triggered_time.getMillis()).atZone(ZoneId.of('America/Bogota')).format(DateTimeFormatter.ofPattern('YYYY-MM-dd HH:mm:ss')) ];",
"lang": "painless"
}
}
}