|
@@ -0,0 +1,76 @@
|
|
|
+# Prometheus Sms Alert webhook
|
|
|
+
|
|
|
+## 简介
|
|
|
+
|
|
|
+基于SpringBoot的Prometheus短信报警提醒webhook,接入AlertManager的报警系统。
|
|
|
+
|
|
|
+*短信提醒发送接口*
|
|
|
+
|
|
|
+```shell
|
|
|
+/sms/webhook/send
|
|
|
+```
|
|
|
+
|
|
|
+*短信提醒版本*
|
|
|
+
|
|
|
+```shell
|
|
|
+/sms/webhook/version
|
|
|
+```
|
|
|
+
|
|
|
+*短信提醒测试联通*
|
|
|
+
|
|
|
+```shell
|
|
|
+/sms/webhook/test-send/{service}
|
|
|
+```
|
|
|
+service是短信测试服务的名称,如cqxfSms、testSms
|
|
|
+
|
|
|
+## 短信提醒配置
|
|
|
+
|
|
|
+```yaml
|
|
|
+server:
|
|
|
+ port: 8060
|
|
|
+
|
|
|
+prometheus-alert:
|
|
|
+ # cqxfSms testSms
|
|
|
+ # 重庆消防短信提醒服务 cqxfSms
|
|
|
+ # 测试短信服务,不会发送短信,会打印短信内容日志 testSms
|
|
|
+ active-sms-service: cqxfSms
|
|
|
+ managers:
|
|
|
+# - [管理者手机号码]
|
|
|
+ - 185xxxxxxxx
|
|
|
+ - 150xxxxxxxx
|
|
|
+ cqxfSms:
|
|
|
+ # 短信发送地址
|
|
|
+ url: http://xxxx.xxx/job/sendMsg
|
|
|
+```
|
|
|
+
|
|
|
+## 自定义短信服务
|
|
|
+
|
|
|
+实现MessageService接口,实现其中的发送短信接口
|
|
|
+
|
|
|
+```java
|
|
|
+@Component("customSms")
|
|
|
+@Slf4j
|
|
|
+public class CustomMessageService implements MessageService {
|
|
|
+
|
|
|
+ public void send(String to, String content) {
|
|
|
+ // TODO implements send(String to, String content)
|
|
|
+ }
|
|
|
+
|
|
|
+ public send(String[] tos, String content) {
|
|
|
+ // TODO implements send(String[] tos, String content)
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+实现接口之后,启动项目时配置启用CustomMessageService
|
|
|
+
|
|
|
+```yaml
|
|
|
+prometheus-alert:
|
|
|
+ active-sms-service: customSms # 启用的自定义短信测试服务
|
|
|
+```
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|