Skip to content

Instantly share code, notes, and snippets.

@hilt86
Created December 14, 2018 13:13
Show Gist options
  • Save hilt86/0402f498c4823d42b41d6469c85d2a64 to your computer and use it in GitHub Desktop.
Save hilt86/0402f498c4823d42b41d6469c85d2a64 to your computer and use it in GitHub Desktop.
Watcher alert to notify on failed SSH logins
{
"trigger": {
"schedule": {
"interval": "300s"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"filebeat-*"
],
"types": [],
"body": {
"query": {
"bool": {
"must": [
{
"terms": {
"system.auth.ssh.event": [
"Failed",
"Invalid"
],
"boost": 1
}
},
{
"range": {
"@timestamp": {
"gte": "now-5m"
}
}
}
]
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gt": 1
}
}
},
"actions": {
"notify-slack": {
"throttle_period_in_millis": 300000,
"slack": {
"message": {
"to": [
"#devops"
],
"text": "Encountered {{ctx.payload.hits.total}} failed SSH logins in the last 5 minutes (facepalm)"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment