Lets say, the "Measurement.Value" changes. Image you got more than one "Location.Station". But all data goes to the same elastic index.
I like to create a single watcher (or if not possible a watcher each station) ... to do the following:
each time a "Measurement.Value" bigger than "Measurement.Warning" is written to the index, I want to send a mail to a specified group of people. I want to include a specific text like:
'station 20 exceeded the maximum of 0.2 with the current value of 0.5'
and if possible in the caption of the mail: 'warning for station 20'
currently I'm trying like this, but I didn't find a way to split by station and to ad specific text.
Kibana --> Management --> Watchers --> edit
Match the following condition
WHEN max() OF Measurement.Value OVER all documents IS ABOVE 0.1 FOR THE LAST 1 minute
send a Mail ...
Caption: station [{{ctx.metadata.name}}] exceded limit.
{{ctx.metadata.name}} gives me the name of the watcher. But I didn't make it working showing the name of station and the values.
Check this example may help you,
The idea is a simple scripted query that compare mesured value to warning value and generate a list of stations that should be alerted on, the foreach hit execute an action
PUT _watcher/watch/log_event_watch
{
"metadata": {
"name": "IOT sensors"
},
"trigger": {
"schedule": {
"interval": "5m"
}
},
"input": {
"search": {
"request": {
"indices": "my-sensor-logs",
"body": {
"query": {
"script": {
"script": "doc['mesured_value'].value > doc['warning_level'].value"
}
}
}
}
}
},
"condition": {
"script": "return ctx.payload.hits.total > 1"
},
"actions": {
"log_hits": {
"foreach": "ctx.payload.hits.hits",
"max_iterations": 500,
"logging": {
"text": "executed at {{ctx.execution_time}} watcher [{{ctx.metadata.name}}] and detected a seonsor with high mesure - Found id {{ctx.payload._source.stattion_id}} with value {{ctx.payload._source.mesured_value}}"
}
},
"send_email": {
"foreach": "ctx.payload.hits.hits",
"max_iterations": 500,
"email": {
"to": "yassine.lasri@gmail.com",
"subject": "Watcher Notification | Stattion {{ctx.payload._source.stattion_id}}",
"body": "executed at {{ctx.execution_time}} watcher [{{ctx.metadata.name}}] and detected a seonsor with high mesure - Found id {{ctx.payload._source.stattion_id}} with value {{ctx.payload._source.mesured_value}}"
}
}
}
}
I added the Indexpattern like this..."indices": "my-sensor-l*",
But it didnt fire. Maybe it's the Number of docs. To shrink the size, i think I should implement a time range in the filter ... I had something like this before:
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.