alerts.jsonnet 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. local numAlerts = std.extVar('alerts');
  2. local condition = std.extVar('condition');
  3. local arr = std.range(1, numAlerts);
  4. local alertDashboardTemplate = {
  5. "editable": true,
  6. "gnetId": null,
  7. "graphTooltip": 0,
  8. "id": null,
  9. "links": [],
  10. "panels": [
  11. {
  12. "alert": {
  13. "conditions": [
  14. {
  15. "evaluator": {
  16. "params": [
  17. 65
  18. ],
  19. "type": "gt"
  20. },
  21. "operator": {
  22. "type": "and"
  23. },
  24. "query": {
  25. "params": [
  26. "A",
  27. "5m",
  28. "now"
  29. ]
  30. },
  31. "reducer": {
  32. "params": [],
  33. "type": "avg"
  34. },
  35. "type": "query"
  36. }
  37. ],
  38. "executionErrorState": "alerting",
  39. "frequency": "10s",
  40. "handler": 1,
  41. "name": "bulk alerting",
  42. "noDataState": "no_data",
  43. "notifications": [
  44. {
  45. "id": 2
  46. }
  47. ]
  48. },
  49. "aliasColors": {},
  50. "bars": false,
  51. "dashLength": 10,
  52. "dashes": false,
  53. "datasource": "Prometheus",
  54. "fill": 1,
  55. "gridPos": {
  56. "h": 9,
  57. "w": 12,
  58. "x": 0,
  59. "y": 0
  60. },
  61. "id": 2,
  62. "legend": {
  63. "avg": false,
  64. "current": false,
  65. "max": false,
  66. "min": false,
  67. "show": true,
  68. "total": false,
  69. "values": false
  70. },
  71. "lines": true,
  72. "linewidth": 1,
  73. "nullPointMode": "null",
  74. "percentage": false,
  75. "pointradius": 5,
  76. "points": false,
  77. "renderer": "flot",
  78. "seriesOverrides": [],
  79. "spaceLength": 10,
  80. "stack": false,
  81. "steppedLine": false,
  82. "targets": [
  83. {
  84. "$$hashKey": "object:117",
  85. "expr": "go_goroutines",
  86. "format": "time_series",
  87. "intervalFactor": 1,
  88. "refId": "A"
  89. }
  90. ],
  91. "thresholds": [
  92. {
  93. "colorMode": "critical",
  94. "fill": true,
  95. "line": true,
  96. "op": "gt",
  97. "value": 50
  98. }
  99. ],
  100. "timeFrom": null,
  101. "timeShift": null,
  102. "title": "Panel Title",
  103. "tooltip": {
  104. "shared": true,
  105. "sort": 0,
  106. "value_type": "individual"
  107. },
  108. "type": "graph",
  109. "xaxis": {
  110. "buckets": null,
  111. "mode": "time",
  112. "name": null,
  113. "show": true,
  114. "values": []
  115. },
  116. "yaxes": [
  117. {
  118. "format": "short",
  119. "label": null,
  120. "logBase": 1,
  121. "max": null,
  122. "min": null,
  123. "show": true
  124. },
  125. {
  126. "format": "short",
  127. "label": null,
  128. "logBase": 1,
  129. "max": null,
  130. "min": null,
  131. "show": true
  132. }
  133. ]
  134. }
  135. ],
  136. "schemaVersion": 16,
  137. "style": "dark",
  138. "tags": [],
  139. "templating": {
  140. "list": []
  141. },
  142. "time": {
  143. "from": "now-6h",
  144. "to": "now"
  145. },
  146. "timepicker": {
  147. "refresh_intervals": [
  148. "5s",
  149. "10s",
  150. "30s",
  151. "1m",
  152. "5m",
  153. "15m",
  154. "30m",
  155. "1h",
  156. "2h",
  157. "1d"
  158. ],
  159. "time_options": [
  160. "5m",
  161. "15m",
  162. "1h",
  163. "6h",
  164. "12h",
  165. "24h",
  166. "2d",
  167. "7d",
  168. "30d"
  169. ]
  170. },
  171. "timezone": "",
  172. "title": "New dashboard",
  173. "uid": null,
  174. "version": 0
  175. };
  176. {
  177. ['alert-' + std.toString(x) + '.json']:
  178. alertDashboardTemplate + {
  179. panels: [
  180. alertDashboardTemplate.panels[0] +
  181. {
  182. alert+: {
  183. name: 'Alert rule ' + x,
  184. conditions: [
  185. alertDashboardTemplate.panels[0].alert.conditions[0] +
  186. {
  187. evaluator+: {
  188. params: [condition]
  189. }
  190. },
  191. ],
  192. },
  193. },
  194. ],
  195. uid: 'alert-' + x,
  196. title: 'Alert ' + x
  197. },
  198. for x in arr
  199. }