Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save darkshade9/2f1bcf608edb823563de2d4d9c42e0db to your computer and use it in GitHub Desktop.

Select an option

Save darkshade9/2f1bcf608edb823563de2d4d9c42e0db to your computer and use it in GitHub Desktop.
{
"trigger": {
"schedule": {
"interval": "60s"
}
},
"input": {
"search": {
"request": {
"indices": [
"haproxy-*"
],
"body": {
"query": {
"filtered": {
"query": {
"match": {
"http_status_code": "502"
}
},
"filter": {
"range": {
"@timestamp": {
"gt": "now-5m"
}
}
}
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gt": 10
}
}
},
"actions": {
"email_admin": {
"throttle_period": "15m",
"email": {
"to": [ "[email protected]" ],
"subject": "Errors Detected",
"body": "Within the last 5 minutes, I have detected {{ctx.payload.hits.total}} errors that match the description of the subject. Attached is the payload.",
"attachments": {
"attached_data": {
"data": {
"format": "json"
}
}
},
"priority": "high"
}
}
}
}
@darkshade9
Copy link
Author

darkshade9 commented Nov 28, 2016

Searches every 60 seconds inside of the haproxy-* index for the field http_status_code that matches 502 between now and 5 minutes against the @timestamp date/time frame, and if the number of events exceed 10 then send a high priority email, but do not repeat this email for 15 minutes. Include the payload of the hits in the email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment