Browse Source

chore: 添加文档

TwoKe945 2 years ago
parent
commit
2d6fda8dea
3 changed files with 127 additions and 1 deletions
  1. 76 0
      README.md
  2. 50 0
      api.yaml
  3. 1 1
      src/main/resources/application.yml

+ 76 - 0
README.md

@@ -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 # 启用的自定义短信测试服务
+```
+
+
+
+
+

+ 50 - 0
api.yaml

@@ -0,0 +1,50 @@
+openapi: 3.0.3
+info:
+  title: "短信报警提醒"
+  description: "基于SpringBoot的Prometheus短信报警提醒webhook API"
+  version: "1.0.0"
+servers:
+  - url: "http://localhost:8060"
+paths:
+  /sms/webhook/send:
+    post:
+      summary: "短信报警webhook"
+      operationId: "send"
+      requestBody:
+        content:
+          application/json:
+            schema:
+              type: "string"
+              description: "AlertManager服务提醒消息JSON体"
+        required: true
+      responses:
+        "200":
+          description: "OK"
+  /sms/webhook/test-send/{service}:
+    get:
+      summary: "短信服务测试"
+      operationId: "testSend"
+      parameters:
+        - name: "service"
+          in: "path"
+          required: true
+          schema:
+            type: "string"
+      responses:
+        "200":
+          description: "OK"
+          content:
+            '*/*':
+              schema:
+                type: "string"
+  /sms/webhook/version:
+    get:
+      summary: "短信提醒服务版本"
+      operationId: "version"
+      responses:
+        "200":
+          description: "OK"
+          content:
+            '*/*':
+              schema:
+                type: "string"

+ 1 - 1
src/main/resources/application.yml

@@ -2,7 +2,7 @@ server:
   port: 8060
 
 prometheus-alert:
-  active-sms-service: cqxfSms # cqxfSms testSms 启用的短信测试服务
+  active-sms-service: testSms # cqxfSms testSms 启用的短信测试服务
   managers:
 #    - [管理者手机号码]
   cqxfSms: