Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. PUT _xpack/watcher/watch/outofmemoryerror
  2. {
  3. "trigger" : {
  4. "schedule" : { "cron" : "0 0/4 * * * ?" }
  5. },
  6. "input" : {
  7. "search" : {
  8. "request" : {
  9. "indices" : [
  10. "</logstash><logstash -{now-1h/d}t{now-1h{HH}}>",
  11. "</logstash><logstash -{now/d}t{now{HH}}>"
  12. ],
  13. "body" : {
  14. "query" : {
  15. "bool" : {
  16. "must" : {
  17. "multi_match": {
  18. "query": "OutOfMemoryError",
  19. "fields": ["message", "log"]
  20. }
  21. },
  22. "filter" : {
  23. "range": {
  24. "@timestamp": {
  25. "from": "{{ctx.trigger.scheduled_time}}||-5m",
  26. "to": "{{ctx.trigger.triggered_time}}"
  27. }
  28. }
  29. }
  30. }
  31. },
  32. "sort" : [
  33. { "@timestamp" : {"order" : "desc"}},
  34. "_score"
  35. ]
  36. }
  37. }
  38. }
  39. },
  40. "condition" : {
  41. "compare" : { "ctx.payload.hits.total" : { "gt" : 0 }}
  42. },
  43. "actions" : {
  44.  
  45. "notify-slack" : {
  46. "throttle_period" : "5m",
  47. "slack" : {
  48. "message" : {
  49. "to" : [ "#ops", "@dev" ],
  50. "text" : "로그 모니터링 알람",
  51. "attachments" : [
  52. {
  53. "title" : "OutOfMemoryError",
  54. "text" : "지난 5분 동안 해당 오류가 {{ctx.payload.hits.total}}회 발생했습니다. 가장 최근의 오류는 다음과 같습니다.",
  55. "color" : "warning"
  56. },
  57. {
  58. "fields": [
  59. {
  60. "title": "환경",
  61. "value": "Prod",
  62. "short": true
  63. },
  64. {
  65. "title": "발생시각",
  66. "value": "{{ctx.payload.hits.hits.0._source.@timestamp}}",
  67. "short": true
  68. },
  69. {
  70. "title": "메시지",
  71. "value": "{{ctx.payload.hits.hits.0._source.message}}",
  72. "short": false
  73. },
  74. {
  75. "title": "확인명령어",
  76. "value": "`GET /{{ctx.payload.hits.hits.0._index}}/{{ctx.payload.hits.hits.0._type}}/{{ctx.payload.hits.hits.0._id}}`",
  77. "short": false
  78. }
  79. ],
  80. "color" : "warning"
  81. }
  82. ]
  83. }
  84. }
  85. }
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement