Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.33 KB | None | 0 0
  1. {
  2. "trigger": {
  3. "schedule": {
  4. "interval": "1m"
  5. }
  6. },
  7. "input": {
  8. "search": {
  9. "request": {
  10. "search_type": "query_then_fetch",
  11. "indices": [
  12. "filebeat"
  13. ],
  14. "rest_total_hits_as_int": true,
  15. "body": {
  16. "size": 0,
  17. "query": {
  18. "bool": {
  19. "filter": {
  20. "range": {
  21. "bb.okd-quotas.timestamp": {
  22. "gte": "{{ctx.trigger.scheduled_time}}||-2m",
  23. "lte": "{{ctx.trigger.scheduled_time}}",
  24. "format": "strict_date_optional_time||epoch_millis"
  25. }
  26. }
  27. }
  28. }
  29. },
  30. "aggs": {
  31. "bucketAgg": {
  32. "terms": {
  33. "field": "bb.okd-quotas.cpu.used_pct",
  34. "size": "15",
  35. "order": {
  36. "metricAgg": "desc"
  37. }
  38. },
  39. "aggs": {
  40. "metricAgg": {
  41. "max": {
  42. "field": "bb.okd-quotas.cpu.used_pct"
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }
  51. },
  52. "condition": {
  53. "script": {
  54. "source": "ArrayList arr = ctx.payload.aggregations.bucketAgg.buckets; for (int i = 0; i < arr.length; i++) { if (arr[i]['metricAgg'].value > params.threshold) { return true; } } return false;",
  55. "lang": "painless",
  56. "params": {
  57. "threshold": 75
  58. }
  59. }
  60. },
  61. "transform": {
  62. "script": {
  63. "source": "HashMap result = new HashMap(); ArrayList arr = ctx.payload.aggregations.bucketAgg.buckets; ArrayList filteredHits = new ArrayList(); for (int i = 0; i < arr.length; i++) { HashMap filteredHit = new HashMap(); filteredHit.key = arr[i].key; filteredHit.value = arr[i]['metricAgg'].value; if (filteredHit.value > params.threshold) { filteredHits.add(filteredHit); } } result.results = filteredHits; return result;",
  64. "lang": "painless",
  65. "params": {
  66. "threshold": 75
  67. }
  68. }
  69. },
  70. "actions": {
  71. "email_1": {
  72. "email": {
  73. "profile": "standard",
  74. "to": [
  75. "ken.veski@bigbank.ee"
  76. ],
  77. "subject": "Watch [{{ctx.metadata.name}}] has exceeded the threshold 75%"
  78. }
  79. },
  80. "pagerduty_1": {
  81. "pagerduty": {
  82. "description": "Watch [{{ctx.metadata.name}}] has exceeded the threshold"
  83. }
  84. }
  85. },
  86. "metadata": {
  87. "name": "OKD_node_CPU_requests",
  88. "watcherui": {
  89. "trigger_interval_unit": "m",
  90. "agg_type": "max",
  91. "time_field": "bb.okd-quotas.timestamp",
  92. "trigger_interval_size": 1,
  93. "term_size": "15",
  94. "time_window_unit": "m",
  95. "threshold_comparator": ">",
  96. "term_field": "bb.okd-quotas.cpu.used_pct",
  97. "index": [
  98. "filebeat"
  99. ],
  100. "time_window_size": 2,
  101. "threshold": 75,
  102. "agg_field": "bb.okd-quotas.cpu.used_pct"
  103. },
  104. "xpack": {
  105. "type": "threshold"
  106. }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement