2014-08-11 12:11:03 -04:00
|
|
|
alerting
|
|
|
|
========
|
|
|
|
|
|
|
|
This is the elasticsearch alerting plugin repo.
|
2014-08-13 13:05:56 -04:00
|
|
|
|
2014-11-13 13:56:33 -05:00
|
|
|
Creating an alert :
|
2014-08-21 12:47:45 -04:00
|
|
|
|
2014-11-13 13:56:33 -05:00
|
|
|
````
|
|
|
|
PUT _alert/testalert
|
2014-08-21 12:47:45 -04:00
|
|
|
{
|
2014-11-13 13:56:33 -05:00
|
|
|
"request" : {
|
|
|
|
"indices" : [
|
|
|
|
"logstash*"
|
|
|
|
],
|
|
|
|
"body" : {
|
|
|
|
"query" : {
|
|
|
|
"filtered": {
|
|
|
|
"query": {
|
|
|
|
"match": {
|
|
|
|
"response": 404
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"filter": {
|
|
|
|
"range": {
|
|
|
|
"@timestamp" : {
|
|
|
|
"from": "{{SCHEDULED_FIRE_TIME}}||-5m",
|
|
|
|
"to": "{{SCHEDULED_FIRE_TIME}}"
|
|
|
|
}
|
|
|
|
}
|
2014-08-21 12:47:45 -04:00
|
|
|
}
|
2014-11-13 13:56:33 -05:00
|
|
|
}
|
2014-08-21 12:47:45 -04:00
|
|
|
}
|
2014-11-13 13:56:33 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
,
|
|
|
|
"trigger" : { "script" : {
|
|
|
|
"script" : "hits.total > 1",
|
|
|
|
"script_lang" : "groovy"
|
|
|
|
} },
|
|
|
|
"actions" :
|
|
|
|
{
|
|
|
|
"email" : {
|
|
|
|
"addresses" : ["brian.murphy@elasticsearch.com"]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
"schedule" : "0 0/1 * * * ?",
|
|
|
|
"enable" : true
|
|
|
|
}
|
2014-08-21 12:47:45 -04:00
|
|
|
|
2014-11-13 13:56:33 -05:00
|
|
|
````
|
|
|
|
Expected response :
|
|
|
|
````
|
2014-08-21 12:47:45 -04:00
|
|
|
{
|
2014-11-13 13:56:33 -05:00
|
|
|
"_index": ".alerts",
|
|
|
|
"_type": "alert",
|
|
|
|
"_id": "testalert",
|
|
|
|
"_version": 1,
|
|
|
|
"created": true
|
2014-08-21 12:47:45 -04:00
|
|
|
}
|
2014-11-13 13:56:33 -05:00
|
|
|
````
|
2014-08-21 12:47:45 -04:00
|
|
|
|
2014-11-13 13:56:33 -05:00
|
|
|
Viewing an existing alert :
|
|
|
|
````
|
2014-08-21 12:47:45 -04:00
|
|
|
{
|
2014-11-13 13:56:33 -05:00
|
|
|
"found": true,
|
|
|
|
"_index": ".alerts",
|
|
|
|
"_type": "alert",
|
|
|
|
"_id": "testalert",
|
|
|
|
"_version": 1,
|
|
|
|
"alert": {
|
|
|
|
"trigger": {
|
|
|
|
"script": {
|
|
|
|
"script_lang": "groovy",
|
|
|
|
"script": "hits.total > 1"
|
2014-08-21 12:47:45 -04:00
|
|
|
}
|
2014-11-13 13:56:33 -05:00
|
|
|
},
|
|
|
|
"schedule": "0 0/1 * * * ?",
|
|
|
|
"request": {
|
|
|
|
"body": {
|
|
|
|
"query": {
|
|
|
|
"filtered": {
|
|
|
|
"query": {
|
|
|
|
"match": {
|
|
|
|
"response": 404
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"filter": {
|
|
|
|
"range": {
|
|
|
|
"@timestamp": {
|
|
|
|
"to": "{{SCHEDULED_FIRE_TIME}}",
|
|
|
|
"from": "{{SCHEDULED_FIRE_TIME}}||-5m"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-08-21 12:47:45 -04:00
|
|
|
},
|
2014-11-13 13:56:33 -05:00
|
|
|
"indices": [
|
|
|
|
"logstash*"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"enable": true,
|
|
|
|
"actions": {
|
|
|
|
"email": {
|
|
|
|
"addresses": [
|
|
|
|
"brian.murphy@elasticsearch.com"
|
|
|
|
]
|
2014-08-21 12:47:45 -04:00
|
|
|
}
|
2014-11-13 13:56:33 -05:00
|
|
|
}
|
|
|
|
}
|
2014-08-21 12:47:45 -04:00
|
|
|
}
|
2014-08-13 13:05:56 -04:00
|
|
|
````
|
|
|
|
|
2014-11-13 13:56:33 -05:00
|
|
|
Deleting an alert :
|
|
|
|
````
|
|
|
|
DELETE _alert/testalert
|
|
|
|
````
|
2014-08-13 13:05:56 -04:00
|
|
|
|
2014-11-13 13:56:33 -05:00
|
|
|
Expected output :
|
2014-08-13 13:05:56 -04:00
|
|
|
````
|
2014-11-13 13:56:33 -05:00
|
|
|
{
|
|
|
|
"found": true,
|
|
|
|
"_index": ".alerts",
|
|
|
|
"_type": "alert",
|
|
|
|
"_id": "testalert",
|
|
|
|
"_version": 4
|
2014-08-13 13:05:56 -04:00
|
|
|
}
|
2014-11-13 13:56:33 -05:00
|
|
|
````
|
2014-08-13 13:05:56 -04:00
|
|
|
|
|
|
|
|