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.
This commit is contained in:
Tao Chen 2024-10-06 11:53:28 +08:00 committed by GitHub
parent ebc49c5178
commit 26cb183d68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 97 additions and 0 deletions

View File

@ -182,6 +182,55 @@ You can remove or add relevant information as needed.
</details>
### Matrix Notification Example
<details>
<summary>Click to expand/collapse</summary>
#### 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": "<html><head><title>Nezha Dashboard</title></head><body><h1><a href=\"$YOUR_NEZHA_URL\" target=\"_blank\">Nezha Dashboard</a></h1><ul><li>datetime: #DATETIME#</li><li>Message: #NEZHA#</li></ul></body></html>",
"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.
</details>
## Notification Rule Explanation
### Basic Rules

View File

@ -217,6 +217,54 @@ outline: deep
</details>
### Matrix 通知示例
<details>
<summary>点击展开/收起</summary>
#### 参数说明
* 以 `$` 开头的大写变量都需要替换为你的实际值。
* **`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": "<html><head><title>Nezha Dashboard</title></head><body><h1><a href=\"$YOUR_NEZHA_URL\" target=\"_blank\">Nezha Dashboard</a></h1><ul><li>datetime: #DATETIME#</li><li>Message: #NEZHA#</li></ul></body></html>",
"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 房间中就会收到格式化的哪吒面板信息。
</details>
## 告警规则说明
### 基本规则