Alerting in Kibana
In this post i will explain how to manage alerts based on data stored into indexes.
This page will help you with many different demos to understand alertings: https://www.elastic.co/webinars/watcher-alerting-for-elasticsearch?blade=video&hulk=youtube
There are two ways to create alerts:
- Either from the Kibana interface:
- The interface has a limitation where it can only create alerts from metrics so to be able to create alerts for text analysis, you will have to use the dev tool: https://www.elastic.co/guide/en/kibana/current//watcher-ui.html#watcher-create-threshold-alert
- Or From the Dev Tool:
- To create an alert from the dev tool, we are going to send to the Watch API of elastic an HTTP PUT operation
- In this exampl the alert is configured with a cron, targets all the logstash indexes, search for the 404 reponse in the json body field during a certain time range, if the condition matches, an email is sent.
PUT _watcher/watch/my-watch
{
"trigger" : {
"schedule" : { "cron" : "0 0/1 * * * ?" }
},
"input" : {
"search" : {
"request" : {
"indices" : [
"logstash*"
],
"body" : {
"query" : {
"bool" : {
"must" : {
"match": {
"response": 404
}
},
"filter" : {
"range": {
"@timestamp": {
"from": "{{ctx.trigger.scheduled_time}}||-5m",
"to": "{{ctx.trigger.triggered_time}}"
}
}
}
}
}
}
}
}
},
"condition" : {
"compare" : { "ctx.payload.hits.total" : { "gt" : 0 }}
},
"actions" : {
"email_admin" : {
"email" : {
"to" : "admin@domain.host.com",
"subject" : "404 recently encountered"
}
}
}
}
Restrictions:
- The alerting can really help to monitor message passing through the log, but there are some limitations.
- To be able to use some connectors, the minimum subscription is to have the GOLD subscription.
- With the free and basic subscription, the only connector available are Log server (Write your message alert into a log file), Index (Create an index with your message alert into it).
- So without a GOLD subscription, i suggest to not focus a lot on alerting seen that the only connector types will need another monitoring system to be notified.