From 26cb183d681025fd1bce44b6d08f162114b471ae Mon Sep 17 00:00:00 2001
From: Tao Chen <42793494+IamTaoChen@users.noreply.github.com>
Date: Sun, 6 Oct 2024 11:53:28 +0800
Subject: [PATCH] Add Matrix notification guide documentation (#99)
- Created detailed instructions on how to configure Matrix notifications for Nezha monitoring.
- Included parameter explanations and step-by-step setup guide.
- Added English version of the documentation.
---
docs/en_US/guide/notifications.md | 49 +++++++++++++++++++++++++++++++
docs/guide/notifications.md | 48 ++++++++++++++++++++++++++++++
2 files changed, 97 insertions(+)
diff --git a/docs/en_US/guide/notifications.md b/docs/en_US/guide/notifications.md
index 457e39c9..7166f0f6 100644
--- a/docs/en_US/guide/notifications.md
+++ b/docs/en_US/guide/notifications.md
@@ -182,6 +182,55 @@ You can remove or add relevant information as needed.
+### Matrix Notification Example
+
+
+ Click to expand/collapse
+
+#### Parameter Explanation
+
+* All variables starting with `$` need to be replaced with your actual values.
+ * **`YOUR_HOME_SERVER`**: The address of your Matrix server.
+ * **`YOUR_NEZHA_URL`**: The URL of your Nezha dashboard.
+ * **`YOUR_MATRIX_USERNAME`** and **`YOUR_MATRIX_PASSWD`**: Your Matrix username and password.
+ * **`YOUR_MATRIX_TOKEN`** retrieval method:
+ ```sh
+ curl -XPOST -d '{"type": "m.login.password", "identifier": {"user": "$YOUR_MATRIX_USERNAME", "type": "m.id.user"}, "password": "$YOUR_MATRIX_PASSWD"}' "https://$YOUR_HOME_SERVER/_matrix/client/r0/login"
+ ```
+
+#### Request Configuration
+
+- **Name**: Matrix
+- **URL**: `https://$YOUR_HOME_SERVER/_matrix/client/r0/rooms/$ROOM_ID/send/m.room.message`
+- **Request Method**: `POST`
+- **Request Type**: `JSON`
+- **Header**:
+ ```json
+ {
+ "Authorization": "Bearer $YOUR_MATRIX_TOKEN"
+ }
+ ```
+- **Body**:
+ ```json
+ {
+ "msgtype": "m.text",
+ "format": "org.matrix.custom.html",
+ "formatted_body": "Nezha Dashboard- datetime: #DATETIME#
- Message: #NEZHA#
",
+ "body": "#NEZHA#"
+ }
+ ```
+
+#### Usage Steps
+
+1. **Replace Variables**: Replace `$YOUR_HOME_SERVER`, `$YOUR_NEZHA_URL`, `$YOUR_MATRIX_USERNAME`, `$YOUR_MATRIX_PASSWD`, and `$YOUR_MATRIX_TOKEN` with your own values.
+2. **Retrieve Token**: Use the `curl` command provided above to get `YOUR_MATRIX_TOKEN`, making sure to replace all relevant variables.
+3. **Configure Request**: Set up your request using the configuration provided above, ensuring the correct URL, headers, and body are used.
+4. **Send Notification**: Send the Matrix message using the configured request to integrate Nezha monitoring notifications into your Matrix room.
+
+Once configured, you will receive formatted Nezha dashboard information in your Matrix room whenever a notification is triggered.
+
+
+
## Notification Rule Explanation
### Basic Rules
diff --git a/docs/guide/notifications.md b/docs/guide/notifications.md
index 9e4380d4..984cc5e9 100755
--- a/docs/guide/notifications.md
+++ b/docs/guide/notifications.md
@@ -217,6 +217,54 @@ outline: deep
+### Matrix 通知示例
+
+
+ 点击展开/收起
+
+#### 参数说明
+
+* 以 `$` 开头的大写变量都需要替换为你的实际值。
+ * **`YOUR_HOME_SERVER`**: Matrix 服务器的地址。
+ * **`YOUR_NEZHA_URL`**: 你的哪吒面板的 URL。
+ * **`YOUR_MATRIX_USERNAME`** 和 **`YOUR_MATRIX_PASSWD`**: Matrix 用户名和密码。
+ * **`YOUR_MATRIX_TOKEN`** 获取方式:
+ ```sh
+ curl -XPOST -d '{"type": "m.login.password", "identifier": {"user": "$YOUR_MATRIX_USERNAME", "type": "m.id.user"}, "password": "$YOUR_MATRIX_PASSWD"}' "https://$YOUR_HOME_SERVER/_matrix/client/r0/login"
+ ```
+
+#### 请求配置
+
+- **名称**: Matrix
+- **URL**: `https://$YOUR_HOME_SERVER/_matrix/client/r0/rooms/$ROOM_ID/send/m.room.message`
+- **请求方式**: `POST`
+- **请求类型**: `JSON`
+- **Header**:
+ ```json
+ {
+ "Authorization": "Bearer $YOUR_MATRIX_TOKEN"
+ }
+ ```
+- **Body**:
+ ```json
+ {
+ "msgtype": "m.text",
+ "format": "org.matrix.custom.html",
+ "formatted_body": "Nezha Dashboard- datetime: #DATETIME#
- Message: #NEZHA#
",
+ "body": "#NEZHA#"
+ }
+ ```
+#### 使用步骤
+
+1. **替换变量**: 将 `$YOUR_HOME_SERVER`, `$YOUR_NEZHA_URL`, `$YOUR_MATRIX_USERNAME`, `$YOUR_MATRIX_PASSWD`, 以及 `$YOUR_MATRIX_TOKEN` 替换为你自己的值。
+2. **获取 Token**: 使用上面提供的 `curl` 命令来获取 `YOUR_MATRIX_TOKEN`,确保替换所有相关的变量。
+3. **配置请求**: 使用上述配置来设置你的请求,确保使用正确的 URL、请求头和请求体。
+4. **发送通知**: 通过配置后的请求发送 Matrix 消息,完成哪吒监控的通知集成。
+
+这样设置好后,每次触发通知时,你的 Matrix 房间中就会收到格式化的哪吒面板信息。
+
+
+
## 告警规则说明
### 基本规则