Cryo21

Watcher Input

Oct 10th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 1.92 KB | None | 0 0
  1. {
  2.   "trigger": {
  3.     "schedule": {
  4.       "interval": "10s"
  5.     }
  6.   },
  7.   "input": {
  8.     "search": {
  9.       "request": {
  10.         "search_type": "dfs_query_then_fetch",
  11.         "indices": [
  12.           "<filebeat-{now/d}>"
  13.         ],
  14.         "types": [],
  15.         "body": {
  16.           "query": {
  17.             "bool": {
  18.               "must": [
  19.                 {
  20.                   "query_string": {
  21.                     "query": "NOT remote_ip:**IP ADDRESS**\\/24 OR NOT remote_ip:**IP ADDRESS**\\/24 OR NOT remote_ip:**IP ADDRESS**\\/16 OR NOT remote_ip:**IP ADDRESS**\\/24 OR NOT remote_ip:**IP ADDRESS**",
  22.                     "analyze_wildcard": true
  23.                   }
  24.                 },
  25.                 {
  26.                   "range": {
  27.                     "@timestamp": {
  28.                       "gte": "now-60s"
  29.                     }
  30.                   }
  31.                 }
  32.               ],
  33.               "must_not": []
  34.             }
  35.           },
  36.           "size": 0,
  37.           "aggs": {
  38.             "2": {
  39.               "terms": {
  40.                 "field": "remote_ip",
  41.                 "order": {
  42.                   "_count": "desc"
  43.                 }
  44.               },
  45.               "aggs": {
  46.                 "3": {
  47.                   "sum": {
  48.                     "field": "bytes"
  49.                   }
  50.                 }
  51.               }
  52.             }
  53.           }
  54.         }
  55.       }
  56.     }
  57.   },
  58.   "condition" : {
  59.     "compare" : {
  60.       "ctx.payload.aggregations.2.buckets.3.3.value" : {
  61.         "gt" : "10000"
  62.       }
  63.     }
  64.   },
  65.   "actions": {
  66.     "send_email": {
  67.       "email": {
  68.           "to": "**EMAIL ADDRESS**",
  69.           "subject": "Watcher Test Alert",
  70.         "body": "The IP [{{#ctx.payload.aggregations.2.buckets.3}}{{key}} {{/ctx.payload.aggregations.2.buckets.3}}] spiked useage with [{{#ctx.payload.aggregations.2.buckets.3.3}}{{value}} {{/ctx.payload.aggregations.2.buckets.3.3}}]"
  71.       }
  72.     }
  73.   }
  74. }
Add Comment
Please, Sign In to add comment