The purpose of this query is to get the status and the email adress where send the notification
Then I made two triggers : one when the status change to down and the other when it changes to up.
The first trigger condition (change_status_down) is the following one :
// If the cardinality aggregation value is greater than 1 (there is a change of status)
// AND the latest status value received is "down" : it's a breakdown
if (ctx.results[0].aggregations.distinct_status_count.value > 1 && ctx.results[0].aggregations.latest_status.hits.hits[0]._source.status.equals("down") ) {
return true
} else {
return false
}
The query and the trigger works fine. But now, I would like to re-use the email adress I get from the document to send the notification and it seems not to be possible
@vincent2mots Thanks for the detailed explanation. To send notifications with Email, Slack or other actions, you need to first create a Channel. This object must exist before defining the Monitor itself. Therefore the output of the query can’t be used to define a new Channel dynamically.