alert_tab.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <div ng-if="ctrl.panel.alert">
  2. <div class="alert alert-error m-b-2" ng-show="ctrl.error">
  3. <i class="fa fa-warning"></i> {{ctrl.error}}
  4. </div>
  5. <div class="panel-options-group">
  6. <div class="panel-options-group__body">
  7. <div class="gf-form-group">
  8. <h4 class="section-heading">Rule</h4>
  9. <div class="gf-form-inline">
  10. <div class="gf-form">
  11. <span class="gf-form-label width-6">Name</span>
  12. <input type="text" class="gf-form-input width-20" ng-model="ctrl.alert.name">
  13. </div>
  14. <div class="gf-form">
  15. <span class="gf-form-label width-9">Evaluate every</span>
  16. <input class="gf-form-input max-width-6" type="text" ng-model="ctrl.alert.frequency">
  17. </div>
  18. <div class="gf-form max-width-11">
  19. <label class="gf-form-label width-5">For</label>
  20. <input type="text" class="gf-form-input max-width-6" ng-model="ctrl.alert.for"
  21. spellcheck='false' placeholder="5m">
  22. <info-popover mode="right-absolute">
  23. If an alert rule has a configured For and the query violates the configured
  24. threshold it
  25. will first go from OK to Pending.
  26. Going from OK to Pending Grafana will not send any notifications. Once the alert
  27. rule
  28. has
  29. been firing for more than For duration, it will change to Alerting and send alert
  30. notifications.
  31. </info-popover>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="gf-form-group">
  36. <h4 class="section-heading">Conditions</h4>
  37. <div class="gf-form-inline" ng-repeat="conditionModel in ctrl.conditionModels">
  38. <div class="gf-form">
  39. <metric-segment-model css-class="query-keyword width-5" ng-if="$index"
  40. property="conditionModel.operator.type" options="ctrl.evalOperators"
  41. custom="false"></metric-segment-model>
  42. <span class="gf-form-label query-keyword width-5" ng-if="$index===0">WHEN</span>
  43. </div>
  44. <div class="gf-form">
  45. <query-part-editor class="gf-form-label query-part width-9"
  46. part="conditionModel.reducerPart"
  47. handle-event="ctrl.handleReducerPartEvent(conditionModel, $event)">
  48. </query-part-editor>
  49. <span class="gf-form-label query-keyword">OF</span>
  50. </div>
  51. <div class="gf-form">
  52. <query-part-editor class="gf-form-label query-part" part="conditionModel.queryPart"
  53. handle-event="ctrl.handleQueryPartEvent(conditionModel, $event)">
  54. </query-part-editor>
  55. </div>
  56. <div class="gf-form">
  57. <metric-segment-model property="conditionModel.evaluator.type" options="ctrl.evalFunctions"
  58. custom="false" css-class="query-keyword"
  59. on-change="ctrl.evaluatorTypeChanged(conditionModel.evaluator)"></metric-segment-model>
  60. <input class="gf-form-input max-width-9" type="number" step="any"
  61. ng-hide="conditionModel.evaluator.params.length === 0"
  62. ng-model="conditionModel.evaluator.params[0]"
  63. ng-change="ctrl.evaluatorParamsChanged()" />
  64. <label class="gf-form-label query-keyword"
  65. ng-show="conditionModel.evaluator.params.length === 2">TO</label>
  66. <input class="gf-form-input max-width-9" type="number" step="any"
  67. ng-if="conditionModel.evaluator.params.length === 2"
  68. ng-model="conditionModel.evaluator.params[1]"
  69. ng-change="ctrl.evaluatorParamsChanged()" />
  70. </div>
  71. <div class="gf-form">
  72. <label class="gf-form-label">
  73. <a class="pointer" tabindex="1" ng-click="ctrl.removeCondition($index)">
  74. <i class="fa fa-trash"></i>
  75. </a>
  76. </label>
  77. </div>
  78. </div>
  79. <div class="gf-form">
  80. <label class="gf-form-label dropdown">
  81. <a class="pointer dropdown-toggle" data-toggle="dropdown">
  82. <i class="fa fa-plus"></i>
  83. </a>
  84. <ul class="dropdown-menu" role="menu">
  85. <li ng-repeat="ct in ctrl.conditionTypes" role="menuitem">
  86. <a ng-click="ctrl.addCondition(ct.value);">{{ct.text}}</a>
  87. </li>
  88. </ul>
  89. </label>
  90. </div>
  91. </div>
  92. <div class="gf-form-group">
  93. <h4 class="section-heading">No Data & Error Handling</h4>
  94. <div class="gf-form-inline">
  95. <div class="gf-form">
  96. <span class="gf-form-label width-15">If no data or all values are null</span>
  97. </div>
  98. <div class="gf-form">
  99. <span class="gf-form-label query-keyword">SET STATE TO</span>
  100. <div class="gf-form-select-wrapper">
  101. <select class="gf-form-input" ng-model="ctrl.alert.noDataState"
  102. ng-options="f.value as f.text for f in ctrl.noDataModes">
  103. </select>
  104. </div>
  105. </div>
  106. </div>
  107. <div class="gf-form-inline">
  108. <div class="gf-form">
  109. <span class="gf-form-label width-15">If execution error or timeout</span>
  110. </div>
  111. <div class="gf-form">
  112. <span class="gf-form-label query-keyword">SET STATE TO</span>
  113. <div class="gf-form-select-wrapper">
  114. <select class="gf-form-input" ng-model="ctrl.alert.executionErrorState"
  115. ng-options="f.value as f.text for f in ctrl.executionErrorModes">
  116. </select>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. <div class="panel-options-group">
  124. <div class="panel-options-group__header">Notifications</div>
  125. <div class="panel-options-group__body">
  126. <div class="gf-form-inline">
  127. <div class="gf-form">
  128. <span class="gf-form-label width-8">Send to</span>
  129. </div>
  130. <div class="gf-form" ng-repeat="nc in ctrl.alertNotifications">
  131. <span class="gf-form-label" ng-style="{'background-color': nc.bgColor }">
  132. <i class="{{nc.iconClass}}"></i>&nbsp;{{nc.name}}&nbsp;
  133. <i class="fa fa-remove pointer muted" ng-click="ctrl.removeNotification(nc)" ng-if="nc.isDefault === false"></i>
  134. </span>
  135. </div>
  136. <div class="gf-form">
  137. <metric-segment segment="ctrl.addNotificationSegment"
  138. get-options="ctrl.getNotifications()"
  139. on-change="ctrl.notificationAdded()"></metric-segment>
  140. </div>
  141. </div>
  142. <div class="gf-form gf-form--v-stretch">
  143. <span class="gf-form-label width-8">Message</span>
  144. <textarea class="gf-form-input" rows="10" ng-model="ctrl.alert.message"
  145. placeholder="Notification message details..."></textarea>
  146. </div>
  147. </div>
  148. </div>
  149. </div>