prometheusalert.sql 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. -- ----------------------------
  2. -- Records of prometheus_alert_d_b
  3. -- ----------------------------
  4. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (1, 'dd', 'Prometheus', 'prometheus-dd', '{{ $var := .externalURL}}{{ range $k,$v:=.alerts }}
  5. {{if eq $v.status "resolved"}}
  6. ## [Prometheus恢复信息]({{$v.generatorURL}})
  7. #### [{{$v.labels.alertname}}]({{$var}})
  8. ###### 告警级别:{{$v.labels.level}}
  9. ###### 开始时间:{{TimeFormat $v.startsAt "2006-01-02 15:04:05"}}
  10. ###### 结束时间:{{TimeFormat $v.endsAt "2006-01-02 15:04:05"}}
  11. ###### 故障主机IP:{{$v.labels.instance}}
  12. ##### {{$v.annotations.description}}
  13. ![Prometheus](https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png)
  14. {{else}}
  15. ## [Prometheus告警信息]({{$v.generatorURL}})
  16. #### [{{$v.labels.alertname}}]({{$var}})
  17. ###### 告警级别:{{$v.labels.level}}
  18. ###### 开始时间:{{TimeFormat $v.startsAt "2006-01-02 15:04:05"}}
  19. ###### 结束时间:{{TimeFormat $v.endsAt "2006-01-02 15:04:05"}}
  20. ###### 故障主机IP:{{$v.labels.instance}}
  21. ##### {{$v.annotations.description}}
  22. ![Prometheus](https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png)
  23. {{end}}
  24. {{ end }}
  25. {{ $urimsg:=""}}{{ range $key,$value:=.commonLabels }}{{$urimsg = print $urimsg $key "%3D%22" $value "%22%2C" }}{{end}}[*** 点我屏蔽该告警]({{$var}}/#/silences/new?filter=%7B{{SplitString $urimsg 0 -3}}%7D)', '2022-05-26 10:00:05');
  26. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (2, 'wx', 'Prometheus', 'prometheus-wx', '{{ $var := .externalURL}}{{ range $k,$v:=.alerts }}{{if eq $v.status "resolved"}}[PROMETHEUS-恢复信息]({{$v.generatorURL}})
  27. > **[{{$v.labels.alertname}}]({{$var}})**
  28. > <font color="info">告警级别:</font> {{$v.labels.level}}
  29. > <font color="info">开始时间:</font> {{$v.startsAt}}
  30. > <font color="info">结束时间:</font> {{$v.endsAt}}
  31. > <font color="info">故障主机IP:</font> {{$v.labels.instance}}
  32. > <font color="info">**{{$v.annotations.description}}**</font>{{else}}[PROMETHEUS-告警信息]({{$v.generatorURL}})
  33. > **[{{$v.labels.alertname}}]({{$var}})**
  34. > <font color="warning">告警级别:</font> {{$v.labels.level}}
  35. > <font color="warning">开始时间:</font> {{$v.startsAt}}
  36. > <font color="warning">结束时间:</font> {{$v.endsAt}}
  37. > <font color="warning">故障主机IP:</font> {{$v.labels.instance}}
  38. > <font color="warning">**{{$v.annotations.description}}**</font>{{end}}{{ end }}
  39. {{ $urimsg:=""}}{{ range $key,$value:=.commonLabels }}{{$urimsg = print $urimsg $key "%3D%22" $value "%22%2C" }}{{end}}[*** 点我屏蔽该告警]({{$var}}/#/silences/new?filter=%7B{{SplitString $urimsg 0 -3}}%7D)', '2022-05-26 09:59:49');
  40. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (3, 'fs', 'Prometheus', 'prometheus-fs', '{{ $var := .externalURL}}{{ range $k,$v:=.alerts }}{{if eq $v.status "resolved"}}**[Prometheus恢复信息]({{$v.generatorURL}})**
  41. *[{{$v.labels.alertname}}]({{$var}})*
  42. 告警级别:{{$v.labels.level}}
  43. 开始时间:{{TimeFormat $v.startsAt "2006-01-02 15:04:05"}}
  44. 结束时间:{{TimeFormat $v.endsAt "2006-01-02 15:04:05"}}
  45. 故障主机IP:{{$v.labels.instance}}
  46. **{{$v.annotations.description}}**{{else}}**[Prometheus告警信息]({{$v.generatorURL}})**
  47. *[{{$v.labels.alertname}}]({{$var}})*
  48. 告警级别:{{$v.labels.level}}
  49. 开始时间:{{TimeFormat $v.startsAt "2006-01-02 15:04:05"}}
  50. 结束时间:{{TimeFormat $v.endsAt "2006-01-02 15:04:05"}}
  51. 故障主机IP:{{$v.labels.instance}}
  52. **{{$v.annotations.description}}**{{end}}{{ end }}
  53. {{ $urimsg:=""}}{{ range $key,$value:=.commonLabels }}{{$urimsg = print $urimsg $key "%3D%22" $value "%22%2C" }}{{end}}[*** 点我屏蔽该告警]({{$var}}/#/silences/new?filter=%7B{{SplitString $urimsg 0 -3}}%7D)', '2022-05-26 10:10:03');
  54. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (4, 'txdx', 'Prometheus', 'prometheus-dx', '{{ range $k,$v:=.alerts }}{{if eq $v.status "resolved"}}
  55. [Prometheus恢复信息]
  56. {{$v.labels.alertname}}
  57. 告警级别:{{$v.labels.level}}
  58. 故障主机IP:{{$v.labels.instance}}
  59. {{$v.annotations.description}}
  60. {{else}}
  61. [Prometheus告警信息]
  62. {{$v.labels.alertname}}
  63. 告警级别:{{$v.labels.level}}
  64. 故障主机IP:{{$v.labels.instance}}
  65. {{$v.annotations.description}}
  66. {{end}}
  67. {{ end }}', '2021-09-24 08:44:36');
  68. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (5, 'txdh', 'Prometheus', 'prometheus-dh', '{{ range $k,$v:=.alerts }}{{if eq $v.status "resolved"}}恢复信息故障主机IP{{$v.labels.instance}}{{$v.annotations.description}}{{else}}告警信息故障主机IP{{$v.labels.instance}}{{$v.annotations.description}}{{end}}{{ end }}', '2020-07-29 09:39:56');
  69. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (6, 'email', 'Prometheus', 'prometheus-email', '{{ $var := .externalURL}}{{ range $k,$v:=.alerts }}
  70. {{if eq $v.status "resolved"}}
  71. <h1><a href ={{$v.generatorURL}}>Prometheus恢复信息</a></h1>
  72. <h2><a href ={{$var}}>{{$v.labels.alertname}}</a></h2>
  73. <h5>告警级别:{{$v.labels.level}}</h5>
  74. <h5>开始时间:{{$v.startsAt}}</h5>
  75. <h5>结束时间:{{$v.endsAt}}</h5>
  76. <h5>故障主机IP:{{$v.labels.instance}}</h5>
  77. <h3>{{$v.annotations.description}}</h3>
  78. <img src=https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png />
  79. {{else}}
  80. <h1><a href ={{$v.generatorURL}}>Prometheus告警信息</a></h1>
  81. <h2><a href ={{$var}}>{{$v.labels.alertname}}</a></h2>
  82. <h5>告警级别:{{$v.labels.level}}</h5>
  83. <h5>开始时间:{{$v.startsAt}}</h5>
  84. <h5>结束时间:{{$v.endsAt}}</h5>
  85. <h5>故障主机IP:{{$v.labels.instance}}</h5>
  86. <h3>{{$v.annotations.description}}</h3>
  87. <img src=https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png />
  88. {{end}}
  89. {{ end }}', '2020-09-30 09:46:05');
  90. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (7, 'dd', 'Graylog2', 'graylog2-dd', '## [Graylog2告警信息](http://graylog.org)
  91. #### {{.check_result.result_description}}
  92. {{ range $k,$v:=.check_result.matching_messages }}
  93. ###### 告警索引:{{$v.index}}
  94. ###### 开始时间:{{GetCSTtime $v.timestamp}}
  95. ###### 告警主机:{{$v.fields.gl2_remote_ip}}:{{$v.fields.gl2_remote_port}}
  96. ##### {{$v.message}}
  97. {{end}}
  98. ![Prometheus](https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png)', '2020-07-29 09:45:33');
  99. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (8, 'wx', 'Graylog2', 'graylog2-wx', '[Graylog2告警信息](http://graylog.org)
  100. >**{{.check_result.result_description}}**
  101. {{ range $k,$v:=.check_result.matching_messages }}
  102. >告警索引:{{$v.index}}
  103. 开始时间:{{GetCSTtime $v.timestamp}}
  104. 告警主机:{{$v.fields.gl2_remote_ip}}:{{$v.fields.gl2_remote_port}}
  105. **{{$v.message}}**
  106. {{end}}', '2020-07-29 09:49:58');
  107. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (9, 'fs', 'Graylog2', 'graylog2-fs', '**[Graylog2告警信息](http://graylog.org)**
  108. *{{.check_result.result_description}}*
  109. {{ range $k,$v:=.check_result.matching_messages }}
  110. 告警索引:{{$v.index}}
  111. 开始时间:{{GetCSTtime $v.timestamp}}
  112. 告警主机:{{$v.fields.gl2_remote_ip}}:{{$v.fields.gl2_remote_port}}
  113. **{{$v.message}}**
  114. {{end}}', '2020-09-30 10:08:04');
  115. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (10, 'txdx', 'Graylog2', 'graylog2-dx', '{{ range $k,$v:=.check_result.matching_messages }}
  116. 告警主机 {{$v.fields.gl2_remote_ip}}端口 {{$v.fields.gl2_remote_port}}告警消息 {{$v.message}}
  117. {{end}}', '2020-07-29 09:55:27');
  118. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (20, 'txdh', 'Graylog2', 'graylog2-dh', '{{ range $k,$v:=.check_result.matching_messages }}
  119. 告警主机 {{$v.fields.gl2_remote_ip}}端口 {{$v.fields.gl2_remote_port}}告警消息 {{$v.message}}
  120. {{end}}', '2020-07-29 09:56:14');
  121. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (27, 'email', 'Graylog2', 'graylog2-email', '<h1><a href =http://graylog.org>Graylog2告警信息</a></h1>
  122. <h2>{{.check_result.result_description}}</h2>
  123. {{ range $k,$v:=.check_result.matching_messages }}
  124. <h5>告警索引:{{$v.index}}</h5>
  125. <h5>开始时间:{{GetCSTtime $v.timestamp}}</h5>
  126. <h5>告警主机:{{$v.fields.gl2_remote_ip}}:{{$v.fields.gl2_remote_port}}</h5>
  127. <h3>{{$v.message}}</h3>
  128. {{end}}
  129. <img src=https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png />', '2020-07-29 09:59:08');
  130. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (28, 'dd', 'Graylog3', 'graylog3-dd', '## [Graylog3告警信息](.check_result.Event.Source)
  131. #### {{.check_result.event_definition_description}}
  132. {{ range $k,$v:=.backlog }}
  133. ###### 告警索引:{{$v.index}}
  134. ###### 开始时间:{{GetCSTtime $v.timestamp}}
  135. ###### 告警主机:{{$v.fields.gl2_remote_ip}}:{{$v.fields.gl_2_remote_port}}
  136. ##### {{$v.message}}
  137. {{end}}
  138. ![Prometheus](https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png)', '2020-07-29 10:00:32');
  139. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (29, 'wx', 'Graylog3', 'graylog3-wx', '[Graylog3告警信息](.check_result.Event.Source)
  140. >**{{.check_result.event_definition_description}}**
  141. {{ range $k,$v:=.backlog }}
  142. >告警索引:{{$v.index}}
  143. 开始时间:{{GetCSTtime $v.timestamp}}
  144. 告警主机:{{$v.fields.gl2_remote_ip}}:{{$v.fields.gl_2_remote_port}}
  145. **{{$v.message}}**
  146. {{end}}', '2020-07-29 10:03:29');
  147. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (30, 'fs', 'Graylog3', 'graylog3-fs', '**[Graylog3告警信息](.check_result.Event.Source)**
  148. *{{.check_result.event_definition_description}}*
  149. {{ range $k,$v:=.backlog }}
  150. 告警索引:{{$v.index}}
  151. 开始时间:{{GetCSTtime $v.timestamp}}
  152. 告警主机:{{$v.fields.gl2_remote_ip}}:{{$v.fields.gl_2_remote_port}}
  153. **{{$v.message}}**
  154. {{end}}', '2020-09-30 09:52:11');
  155. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (31, 'txdx', 'Graylog3', 'graylog3-dx', '{{ range $k,$v:=.backlog }}
  156. 告警主机 {{$v.fields.gl2_remote_ip}}端口 {{$v.fields.gl_2_remote_port}}告警消息 {{$v.message}}
  157. {{end}}', '2020-07-29 10:50:06');
  158. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (32, 'txdh', 'Graylog3', 'graylog3-dh', '{{ range $k,$v:=.backlog }}
  159. 告警主机 {{$v.fields.gl2_remote_ip}}端口 {{$v.fields.gl_2_remote_port}}告警消息 {{$v.message}}
  160. {{end}}', '2020-07-29 10:50:30');
  161. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (33, 'email', 'Graylog3', 'graylog3-email', '<h1><a href =.check_result.Event.Source>Graylog3告警信息</a></h1>
  162. <h2>{{.check_result.event_definition_description}}</h2>
  163. {{ range $k,$v:=.backlog }}
  164. <h5>告警索引:{{$v.index}}</h5>
  165. <h5>开始时间:{{GetCSTtime $v.timestamp}}</h5>
  166. <h5>告警主机:{{$v.fields.gl2_remote_ip}}:{{$v.fields.gl_2_remote_port}}</h5>
  167. <h3>{{$v.message}}</h3>
  168. {{end}}
  169. <img src=https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png />', '2020-07-29 10:53:20');
  170. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (34, 'dd', 'Grafana', 'grafana-dd', '{{if eq .state "ok"}}
  171. ## [Grafana恢复信息]({{.ruleUrl}})
  172. #### {{.ruleName}}
  173. ###### 告警级别:严重
  174. ###### 开始时间:{{GetCSTtime ""}}
  175. ##### {{.message}}
  176. {{else}}
  177. ## [Grafana告警信息]({{.ruleUrl}})
  178. #### {{.ruleName}}
  179. ###### 告警级别:严重
  180. ###### 开始时间:{{GetCSTtime ""}}
  181. ##### {{.message}}
  182. {{end}}
  183. ![Prometheus](https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png)', '2020-07-29 11:40:33');
  184. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (35, 'wx', 'Grafana', 'grafana-wx', '{{if eq .state "ok"}}
  185. [Grafana恢复信息]({{.ruleUrl}})
  186. >**{{.ruleName}}**
  187. >告警级别:严重
  188. 开始时间:{{GetCSTtime ""}}
  189. {{.message}}
  190. {{else}}
  191. [Grafana告警信息]({{.ruleUrl}})
  192. >**{{.ruleName}}**
  193. >告警级别:严重
  194. 开始时间:{{GetCSTtime ""}}
  195. {{.message}}
  196. {{end}}', '2020-07-29 11:41:07');
  197. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (36, 'fs', 'Grafana', 'grafana-fs', '{{if eq .state "ok"}}
  198. **[Grafana恢复信息]({{.ruleUrl}})**
  199. *{{.ruleName}}*
  200. 告警级别:严重
  201. 开始时间:{{GetCSTtime ""}}
  202. **{{.message}}**
  203. {{else}}
  204. **[Grafana告警信息]({{.ruleUrl}})**
  205. *{{.ruleName}}*
  206. 告警级别:严重
  207. 开始时间:{{GetCSTtime ""}}
  208. **{{.message}}**
  209. {{end}}', '2020-09-30 09:53:04');
  210. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (37, 'txdx', 'Grafana', 'grafana-dx', '{{if eq .state "ok"}}
  211. Grafana恢复信息{{.message}}
  212. {{else}}
  213. Grafana告警信息{{.message}}
  214. {{end}}', '2020-07-29 11:44:28');
  215. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (38, 'txdh', 'Grafana', 'grafana-dh', '{{if eq .state "ok"}}
  216. Grafana恢复信息{{.message}}
  217. {{else}}
  218. Grafana告警信息{{.message}}
  219. {{end}}', '2020-07-29 11:44:49');
  220. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (39, 'email', 'Grafana', 'grafana-email', '{{if eq .state "ok"}}
  221. <h1><a href ={{.ruleUrl}}>Grafana恢复信息</a></h1>
  222. <h2>{{.ruleName}}</h2>
  223. <h5>告警级别:严重</h5>
  224. <h5>开始时间:{{GetCSTtime ""}}</h5>
  225. <h3>{{.message}}</h3>
  226. {{else}}
  227. <h1><a href ={{.ruleUrl}}>Grafana恢复信息</a></h1>
  228. <h2>{{.ruleName}}</h2>
  229. <h5>告警级别:严重</h5>
  230. <h5>开始时间:{{GetCSTtime ""}}</h5>
  231. <h3>{{.message}}</h3>
  232. {{end}}
  233. <img src=https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png />', '2020-07-29 11:52:25');
  234. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (40, 'dd', 'SonarQube', 'sonar-dd-example', '## [Sonar告警信息]({{.serverUrl}})
  235. ###### 检测状态:{{.status}}
  236. ###### 检测时间:{{.analysedAt}}
  237. ###### ---------------------------------
  238. {{ range $k,$v:=.qualityGate.conditions}}
  239. ###### metric:{{$v.metric}}
  240. ###### errorThreshold:{{$v.errorThreshold}}
  241. ###### operator:{{$v.operator}}
  242. ###### status:{{$v.status}}
  243. ###### -----------------------------------
  244. {{ end }}
  245. ![Prometheus](https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png)', '2020-07-29 11:53:35');
  246. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (41, 'dd', 'Jenkins', 'jenkins-dd-example', '## [Jenkins构建信息]({{.buildUrl}})
  247. ###### Jenkins地址:[{{.buildUrl}}]({{.buildUrl}})
  248. ###### 构建项目:{{.projectName}}
  249. ###### 构建事件:{{.event}}
  250. ###### 构建名称:{{.buildName}}
  251. ###### 构建时间:{{GetCSTtime ""}}
  252. ![Prometheus](https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png)', '2020-07-29 11:54:02');
  253. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (42, 'fs', 'Prometheus', 'prometheus-fsv2', '{{ $var := .externalURL}}{{ range $k,$v:=.alerts }}
  254. {{if eq $v.status "resolved"}}
  255. **[Prometheus恢复信息]({{$v.generatorURL}})**
  256. *[{{$v.labels.alertname}}]({{$var}})*
  257. 告警级别:{{$v.labels.level}}
  258. 开始时间:{{$v.startsAt}}
  259. 结束时间:{{$v.endsAt}}
  260. 故障主机IP:{{$v.labels.instance}}
  261. **{{$v.annotations.description}}**
  262. {{else}}
  263. **[Prometheus告警信息]({{$v.generatorURL}})**
  264. *[{{$v.labels.alertname}}]({{$var}})*
  265. 告警级别:{{$v.labels.level}}
  266. 开始时间:{{$v.startsAt}}
  267. 结束时间:{{$v.endsAt}}
  268. 故障主机IP:{{$v.labels.instance}}
  269. **{{$v.annotations.description}}**
  270. {{end}}
  271. {{ end }}', '2020-11-20 08:05:04');
  272. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (43, 'workwechat', 'Prometheus', 'prometheus-wechatapp', '{{ $var := .externalURL}}{{ range $k,$v:=.alerts }}
  273. {{if eq $v.status "resolved"}}
  274. [Prometheus恢复信息]($v.generatorURL}})
  275. >**[{{$v.labels.alertname}}]({{$var}})**
  276. >告警级别: {{$v.labels.level}}
  277. 开始时间: {{$v.startsAt}}
  278. 结束时间: {{$v.endsAt}}
  279. 故障主机IP: {{$v.labels.instance}}
  280. **{{$v.annotations.description}}**
  281. {{else}}
  282. [Prometheus告警信息]($v.generatorURL}})
  283. >**[{{$v.labels.alertname}}]({{$var}})**
  284. >告警级别: {{$v.labels.level}}
  285. 开始时间: {{$v.startsAt}}
  286. 结束时间: {{$v.endsAt}}
  287. 故障主机IP: {{$v.labels.instance}}
  288. **{{$v.annotations.description}}**
  289. {{end}}
  290. {{ end }}', '2021-01-18 08:13:55');
  291. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (44, 'rl', 'Prometheus', 'prometheus-ruliu', '{{ $var := .externalURL}}{{ range $k,$v:=.alerts }}
  292. {{if eq $v.status "resolved"}}
  293. ## [Prometheus恢复信息]({{$v.generatorURL}})
  294. #### [{{$v.labels.alertname}}]({{$var}})
  295. ###### 告警级别:{{$v.labels.level}}
  296. ###### 开始时间:{{$v.startsAt}}
  297. ###### 结束时间:{{$v.endsAt}}
  298. ###### 故障主机IP:{{$v.labels.instance}}
  299. ##### {{$v.annotations.description}}
  300. ![Prometheus](https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png)
  301. {{else}}
  302. ## [Prometheus告警信息]({{$v.generatorURL}})
  303. #### [{{$v.labels.alertname}}]({{$var}})
  304. ###### 告警级别:{{$v.labels.level}}
  305. ###### 开始时间:{{$v.startsAt}}
  306. ###### 结束时间:{{$v.endsAt}}
  307. ###### 故障主机IP:{{$v.labels.instance}}
  308. ##### {{$v.annotations.description}}
  309. ![Prometheus](https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png)
  310. {{end}}
  311. {{ end }}', '2021-02-02 07:45:30');
  312. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (45, 'webhook', 'WebHook', 'prometheus-webhook', '{
  313. {{ $var := index .alerts 0}}
  314. {{if eq $var.status "resolved"}}
  315. "title": "Prometheus恢复信息",
  316. "prometheus-url": "{{$var.generatorURL}}",
  317. "alert-name": "{{$var.labels.alertname}}",
  318. "alertmanager-url": "{{.externalURL}}",
  319. "alert-level": "{{$var.labels.level}}",
  320. "alert-start-time": "{{$var.startsAt}}",
  321. "alert-end-time": "{{$var.endsAt}}",
  322. "alert-instance": "{{$var.labels.instance}}",
  323. "message": "{{$var.annotations.description}}"
  324. {{else}}
  325. "title": "Prometheus告警信息",
  326. "prometheus-url": "{{$var.generatorURL}}",
  327. "alert-name": "{{$var.labels.alertname}}",
  328. "alertmanager-url": "{{.externalURL}}",
  329. "alert-level": "{{$var.labels.level}}",
  330. "alert-start-time": "{{$var.startsAt}}",
  331. "alert-end-time": "{{$var.endsAt}}",
  332. "alert-instance": "{{$var.labels.instance}}",
  333. "message": "{{$var.annotations.description}}"
  334. {{end}}
  335. }', '2021-04-29 08:04:12');
  336. INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (46, 'wx', 'ALiYun', 'aliyun', 'ALiYun {{.AlertState}}信息
  337. >**{{.AlertName}}**
  338. >告警级别: {{.TriggerLevel}}
  339. 开始时间: {{GetTime .Timestamp}}
  340. 故障主机: {{.InstanceName}}
  341. ------------详细信息--------------
  342. metricName: {{.MetricName}}
  343. expression: {{.Expression}}
  344. signature: {{.Signature}}
  345. metricProject: {{.MetricProject}}
  346. userId: {{.UserId}}
  347. namespace: {{.Namespace}}
  348. preTriggerLevel: {{.PreTriggerLevel}}
  349. ruleId: {{.RuleId}}
  350. dimensions: {{.Dimensions}}
  351. **当前值:{{.CurValue}}**', '2021-07-14 06:57:31');