alert_tab.html 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <div ng-if="ctrl.panel.alert">
  2. <div class="alert alert-error m-b-2" ng-show="ctrl.error">
  3. <icon name="'exclamation-triangle'"></icon> {{ctrl.error}}
  4. </div>
  5. <div class="gf-form-group">
  6. <h4 class="section-heading">Rule</h4>
  7. <div class="gf-form-inline">
  8. <div class="gf-form">
  9. <span class="gf-form-label width-6">Name</span>
  10. <input type="text" class="gf-form-input width-20 gf-form-input--has-help-icon" ng-model="ctrl.alert.name" />
  11. <info-popover mode="right-absolute">
  12. If you want to apply templating to the alert rule name, you must use the following syntax - ${Label}
  13. </info-popover>
  14. </div>
  15. <div class="gf-form">
  16. <span class="gf-form-label width-9">Evaluate every</span>
  17. <input
  18. class="gf-form-input max-width-6"
  19. type="text"
  20. ng-model="ctrl.alert.frequency"
  21. ng-blur="ctrl.checkFrequency()"
  22. />
  23. </div>
  24. <div class="gf-form max-width-11">
  25. <label class="gf-form-label width-5">For</label>
  26. <input
  27. type="text"
  28. class="gf-form-input max-width-6 gf-form-input--has-help-icon"
  29. ng-model="ctrl.alert.for"
  30. spellcheck="false"
  31. placeholder="5m"
  32. ng-pattern="/(^\d+([dhms])$)|(0)|(^$)/"
  33. />
  34. <info-popover mode="right-absolute">
  35. If an alert rule has a configured and the query violates the configured threshold, then it goes from OK
  36. to Pending. Grafana does not send any notifications for that change. Once the alert rule has been
  37. firing for more than For duration, then the alert changes to Alerting and sends alert notifications.
  38. </info-popover>
  39. </div>
  40. </div>
  41. <div class="gf-form" ng-if="ctrl.frequencyWarning">
  42. <label class="gf-form-label text-warning">
  43. <icon name="'exclamation-triangle'"></icon> {{ctrl.frequencyWarning}}
  44. </label>
  45. </div>
  46. </div>
  47. <div class="gf-form-group">
  48. <h4 class="section-heading">Conditions</h4>
  49. <div class="gf-form-inline" ng-repeat="conditionModel in ctrl.conditionModels">
  50. <div class="gf-form">
  51. <metric-segment-model
  52. css-class="query-keyword width-5"
  53. ng-if="$index"
  54. property="conditionModel.operator.type"
  55. options="ctrl.evalOperators"
  56. custom="false"
  57. ></metric-segment-model>
  58. <span class="gf-form-label query-keyword width-5" ng-if="$index===0">WHEN</span>
  59. </div>
  60. <div class="gf-form">
  61. <query-part-editor
  62. class="gf-form-label query-part width-9"
  63. part="conditionModel.reducerPart"
  64. handle-event="ctrl.handleReducerPartEvent(conditionModel, $event)"
  65. >
  66. </query-part-editor>
  67. <span class="gf-form-label query-keyword">OF</span>
  68. </div>
  69. <div class="gf-form">
  70. <query-part-editor
  71. class="gf-form-label query-part"
  72. part="conditionModel.queryPart"
  73. handle-event="ctrl.handleQueryPartEvent(conditionModel, $event)"
  74. >
  75. </query-part-editor>
  76. </div>
  77. <div class="gf-form">
  78. <metric-segment-model
  79. property="conditionModel.evaluator.type"
  80. options="ctrl.evalFunctions"
  81. custom="false"
  82. css-class="query-keyword"
  83. on-change="ctrl.evaluatorTypeChanged(conditionModel.evaluator)"
  84. ></metric-segment-model>
  85. <input
  86. class="gf-form-input max-width-9"
  87. type="number"
  88. step="any"
  89. ng-hide="conditionModel.evaluator.params.length === 0"
  90. ng-model="conditionModel.evaluator.params[0]"
  91. ng-change="ctrl.evaluatorParamsChanged()"
  92. />
  93. <label class="gf-form-label query-keyword" ng-show="conditionModel.evaluator.params.length === 2">TO</label>
  94. <input
  95. class="gf-form-input max-width-9"
  96. type="number"
  97. step="any"
  98. ng-if="conditionModel.evaluator.params.length === 2"
  99. ng-model="conditionModel.evaluator.params[1]"
  100. ng-change="ctrl.evaluatorParamsChanged()"
  101. />
  102. </div>
  103. <div class="gf-form">
  104. <label class="gf-form-label">
  105. <a class="pointer" tabindex="1" ng-click="ctrl.removeCondition($index)">
  106. <icon name="'trash-alt'"></icon>
  107. </a>
  108. </label>
  109. </div>
  110. </div>
  111. <div class="gf-form">
  112. <label class="gf-form-label dropdown">
  113. <a class="pointer dropdown-toggle" data-toggle="dropdown">
  114. <icon name="'plus-circle'"></icon>
  115. </a>
  116. <ul class="dropdown-menu" role="menu">
  117. <li ng-repeat="ct in ctrl.conditionTypes" role="menuitem">
  118. <a ng-click="ctrl.addCondition(ct.value);">{{ct.text}}</a>
  119. </li>
  120. </ul>
  121. </label>
  122. </div>
  123. </div>
  124. <div class="gf-form-group">
  125. <h4 class="section-heading">No data and error handling</h4>
  126. <div class="gf-form-inline">
  127. <div class="gf-form">
  128. <span class="gf-form-label width-15">If no data or all values are null</span>
  129. </div>
  130. <div class="gf-form">
  131. <span class="gf-form-label query-keyword">set state to</span>
  132. <div class="gf-form-select-wrapper">
  133. <select
  134. class="gf-form-input"
  135. ng-model="ctrl.alert.noDataState"
  136. ng-options="f.value as f.text for f in ctrl.noDataModes"
  137. >
  138. </select>
  139. </div>
  140. </div>
  141. </div>
  142. <div class="gf-form-inline">
  143. <div class="gf-form">
  144. <span class="gf-form-label width-15">If execution error or timeout</span>
  145. </div>
  146. <div class="gf-form">
  147. <span class="gf-form-label query-keyword">set state to</span>
  148. <div class="gf-form-select-wrapper">
  149. <select
  150. class="gf-form-input"
  151. ng-model="ctrl.alert.executionErrorState"
  152. ng-options="f.value as f.text for f in ctrl.executionErrorModes"
  153. >
  154. </select>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. <h4 class="section-heading">Notifications</h4>
  160. <div class="gf-form-inline">
  161. <div class="gf-form">
  162. <span class="gf-form-label width-8">Send to</span>
  163. </div>
  164. <div class="gf-form" ng-repeat="nc in ctrl.alertNotifications">
  165. <span class="gf-form-label">
  166. <icon name="'{{nc.iconClass}}'"></icon>
  167. &nbsp;{{nc.name}}&nbsp;<span ng-if="nc.isDefault">(default)</span>
  168. <icon
  169. name="'times'"
  170. class="pointer muted"
  171. ng-click="ctrl.removeNotification(nc)"
  172. ng-if="nc.isDefault === false"
  173. ></icon>
  174. </span>
  175. </div>
  176. <div class="gf-form">
  177. <metric-segment
  178. segment="ctrl.addNotificationSegment"
  179. get-options="ctrl.getNotifications()"
  180. on-change="ctrl.notificationAdded()"
  181. ></metric-segment>
  182. </div>
  183. </div>
  184. <div class="gf-form gf-form--v-stretch">
  185. <span class="gf-form-label width-8">Message</span>
  186. <textarea
  187. class="gf-form-input gf-form-input--has-help-icon"
  188. rows="10"
  189. ng-model="ctrl.alert.message"
  190. placeholder="Notification message details..."
  191. ></textarea>
  192. <info-popover mode="right-absolute">
  193. If you want to apply templating to the alert rule name, use the following syntax - ${Label}
  194. </info-popover>
  195. </div>
  196. <div class="gf-form">
  197. <span class="gf-form-label width-8">Tags</span>
  198. <div class="gf-form-group">
  199. <div class="gf-form-inline" ng-repeat="(name, value) in ctrl.alert.alertRuleTags">
  200. <label class="gf-form-label width-15">{{ name }}</label>
  201. <input
  202. class="gf-form-input width-15"
  203. placeholder="Tag value..."
  204. ng-model="ctrl.alert.alertRuleTags[name]"
  205. type="text"
  206. />
  207. <label class="gf-form-label">
  208. <a class="pointer" tabindex="1" ng-click="ctrl.removeAlertRuleTag(name)">
  209. <icon name="'trash-alt'"></icon>
  210. </a>
  211. </label>
  212. </div>
  213. <div class="gf-form-inline">
  214. <div class="gf-form">
  215. <input
  216. class="gf-form-input width-15"
  217. placeholder="New tag name..."
  218. ng-model="ctrl.newAlertRuleTag.name"
  219. type="text"
  220. />
  221. <input
  222. class="gf-form-input width-15"
  223. placeholder="New tag value..."
  224. ng-model="ctrl.newAlertRuleTag.value"
  225. type="text"
  226. />
  227. </div>
  228. </div>
  229. <div class="gf-form">
  230. <label class="gf-form-label">
  231. <a class="pointer" tabindex="1" ng-click="ctrl.addAlertRuleTag()">
  232. <icon name="'plus-circle'"></icon>&nbsp;Add Tag
  233. </a>
  234. </label>
  235. </div>
  236. </div>
  237. </div>
  238. </div>