优化更新中英文文档-管理面板-告警

This commit is contained in:
Kris 2024-05-14 17:46:29 +02:00
parent d5a754ffff
commit 8688538e0e
No known key found for this signature in database
GPG Key ID: 36AFAA97D2910652
3 changed files with 459 additions and 372 deletions

View File

@ -1,224 +1,275 @@
Nezha Monitoring supports monitoring of server load, CPU, memory, hard disk, data transfer, monthly data transfer, number of processes, number of connections, and sends alarm notifications when one of these items reaches a user-set limit.
<br/>
<br/>
## Flexible notification methods
---
outline: deep
---
In panel messages, the placeholder `#DATETIME#` represents the timestamp of when an event occurs. When the notification is triggered, the panel automatically replaces #DATETIME# with the actual time of the event.
Nezha Monitoring supports monitoring server load, CPU, memory, disk, traffic, monthly traffic, process count, and connection count, and sending notifications when user-defined thresholds are reached.
`#NEZHA#` is the panel message placeholder, the panel will automatically replace the placeholder with the actual message when it triggers the notification
## Flexible Notification Methods
The content of Body is in `JSON` format**When the request type is FORM**the value is in the form of `key:value``value` can contain placeholders that will be automatically replaced when notified. **When the request type is JSON** It will only do string substitution and submit to the `URL` directly.
- In Dashboard messages, the placeholder `#DATETIME#` represents the timestamp of the event. When the notification is triggered, the Dashboard automatically replaces `#DATETIME#` with the actual event time.
- `#NEZHA#` is a placeholder for Dashboard messages, and the Dashboard automatically replaces the placeholder with the actual message when the notification is triggered.
- The body content is in `JSON` format: **When the request type is FORM**, the value is in `key:value` form, and placeholders can be placed inside `value`. The placeholders will be automatically replaced during notification. **When the request type is JSON**, only simple string replacement is performed before being submitted to the `URL`.
- Placeholders can also be placed inside the URL, and simple string replacement will be performed during the request.
Placeholders can also be placed inside the URL, and it will perform a simple string substitution when requested.
**Refer to the following notification method examples, and you can also flexibly set the push method according to your needs.**
### Bark Example
<details>
<summary>Click to expand/collapse</summary>
- Name: Bark
- URL structure: /:key/:body or /:key/:title/:body or /:key/:category/:title/:body
- Request Method: GET
- Request Type: Default
- Body: Empty
- Name: Bark
- URL structure: /push
- Request Method: POST
- Request Type: form
- Body: `{"title": "#SERVER.NAME#","device_key":"xxxxxxxxx","body":"#NEZHA#","icon":"https://xxxxxxxx/nz.png"}`
</details>
### Slack Example Contributor: [@白歌](https://github.com/cantoblanco)
<details>
<summary>Click to expand/collapse</summary>
#### URL Parameter Acquisition Instructions
Prepare your Slack Workspace in advance and create an App for this Workspace. If you have not created one, you can create an App at [Slack API](https://api.slack.com/apps).
After creating the App, you need to add an Incoming Webhook to the App. In the App's settings page, find Incoming Webhooks, enable Activate Incoming Webhooks, and at the bottom of the page, find and click Add New Webhook to Workspace, choose a Channel, and click Allow. After creating, you will get a Webhook URL, which you will use to replace the example URL below.
- Name: Slack
- URL: https://hooks.slack.com/services/xxxxxxxxx/xxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx
- Request Method: POST
- Request Type: JSON
- Body: `{"text":"#NEZHA#"}`
</details>
### Telegram Example Contributor: [@白歌](https://github.com/cantoblanco)
<details>
<summary>Click to expand/collapse</summary>
#### URL Parameter Acquisition Instructions
Create a bot in Telegram and get the bot's token and your Telegram user ID.
The token and user ID are alphanumeric strings. You can get your user ID by chatting with @userinfobot on Telegram. Create a bot by chatting with @BotFather, and you will get the bot's token.
Replace botXXXXXX with your bot token and YYYYYY with your user ID in the URL below. Note that you need to chat with the bot first, otherwise the bot cannot send messages to you.
- Name: Telegram
- URL: https://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&text=#NEZHA#
- Request Method: GET
- Request Type: Default
- Body: Empty
</details>
Refer to the example below, it is very flexible.
### Email Notification Example - Outlook Contributor: [@白歌](https://github.com/cantoblanco)
<details>
<summary>Click to expand/collapse</summary>
- **Bark Example**
- Name: Bark
- URL: The first part is the key, followed by three matches/: key/: body or/: key/: title/: body or/: key/: category/: title/: body
- Request method: GET
- Request Type: Default
- Body: null
- Name: Bark
- URL:/push
- Request method: POST
- Request type: FORM
- Body: `{"title": "#SERVER.NAME#","device_key":"xxxxxxxxx","body":"#NEZHA#","icon":" https://xxxxxxxx/nz.png "}`
**Note: SendCloud has a daily free email sending limit. This is just an example. You can choose a paid service or other similar free services. The usage method is similar.**
- **Telegram Example, contributed by [@haitau](https://github.com/haitau)**
#### URL Parameter Acquisition Instructions
- NameTelegram Robot message notification
- URLhttps://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&text=#NEZHA#
- Request method: GET
- Request type: default
- Body: null
- Notes for this methodThe XXXXXX in botXXXXXX is the token provided when you follow the official @Botfather in Telegram and enter /newbot to create a new bot. (In the line after _Use this token to access the HTTP API_). The 'bot' are essential. After creating a bot, you need to talk to the BOT in Telegram (send a random message) before you can send a message by using API. YYYYYY is Telegram user's ID, you can get it by talking to the bot @userinfobot.
This example uses SendCloud as the email service. You need to register an account on [SendCloud](https://www.sendcloud.net/), create a sender email, and then obtain the APIUSER and APIKEY [here](https://www.sendcloud.net/sendSetting/apiuser).
- **Email notification example - Outlook**
- Name: MS Mail Notification
- URLhttps://graph.microsoft.com/v1.0/me/microsoft.graph.sendMail
- Request method: POST
- Request type: JSON
- Header: `{"Content-type":"application/json",
"Authorization":"Bearer {Token}"}`
- Body:
```json
{
"message": {
"subject": "Server Status Notification",
"body": {
"contentType": "Text",
"content": "#NEZHA#"
},
"toRecipients": [
{
"emailAddress": {
"address": "ADDRESS FOR RECEVING EMAILS"
}
}
]
}
}
```
Replace `<replaceAPIUSER>` and `<replaceAPIKEY>` in the example URL below with your APIUSER and APIKEY, and replace `<customSenderEmail>` and `<customRecipientEmail>` with any sender and recipient email addresses.
Notes for this method: This method requires calling Microsoft Graph V1.0, you need to go to Microsoft Graph and create your own application, give `Mail.Send` permission and get the Token, or you can go [Microsoft Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer) directly to give permission and get the Token, just replace the Token in the Header with the actual Token.
- **DingTalk Group bot notification Example**
- Name: DingTalk Group
- URL: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxx
- Request method: POST
- Request Type: JSON
- Header: `{"Content-Type": "application/json"}`
- Body: `{"msgtype": "text","text": {"content":"nezha\n#NEZHA#"}}`
- Notes for this methodURL:Creating bot in DingTalk groups to obtain bot URLs, Security settings validation set to custom keywordsThe security settings validation is set to a custom keyword, and the keyword must be included in the content field of the body, such as nezha
- **Wechat Work Group bot Example, contributed by [@ChowRex](https://github.com/ChowRex)**
Support placeholders:
- Name: MS Mail Notification
- URLhttps://graph.microsoft.com/v1.0/me/microsoft.graph.sendMail
- Request method: POST
- Request type: JSON
- Header: `{"Content-type":"application/json",
"Authorization":"Bearer {Token}"}`
- Body:
```json
{
"content": "#NEZHA#",
"ServerName": "#SERVER.NAME#",
"ServerIP": "#SERVER.IP#",
"ServerIPV4": "#SERVER.IPV4#",
"ServerIPV6": "#SERVER.IPV6#",
"CPU": "#SERVER.CPU#",
"MEM": "#SERVER.MEM#",
"SWAP": "#SERVER.SWAP#",
"DISK": "#SERVER.DISK#",
"NetInSpeed": "#SERVER.NETINSPEED#",
"NetOutSpeed": "#SERVER.NETOUTSPEED#",
"TransferIn": "#SERVER.TRANSFERIN#",
"TranferOut": "#SERVER.TRANSFEROUT#",
"Load1": "#SERVER.LOAD1#",
"Load5": "#SERVER.LOAD5#",
"Load15": "#SERVER.LOAD15#",
"TCP_CONN_COUNT": "#SERVER.TCPCONNCOUNT", # Invalid
"UDP_CONN_COUNT": "#SERVER.UDPCONNCOUNT", # Invalid
"message": {
"subject": "Server Status Notification",
"body": {
"contentType": "Text",
"content": "#NEZHA#"
},
"toRecipients": [
{
"emailAddress": {
"address": "ADDRESS FOR RECEVING EMAILS"
}
}
]
}
}
```
</details>
### DingTalk Group Bot Configuration Example
<details>
<summary>Click to expand/collapse</summary>
#### URL Parameter Acquisition Instructions
Create a bot in DingTalk in advance and get the bot's token.
The bot URL is obtained after creating a bot in the DingTalk group - Manage Bot - Create Bot. Choose custom keywords for the security method, and the Body content value must contain these keywords.
- Name: Nezha Assistant
- URL: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxx
- Request Method: POST
- Request Type: JSON
- Header: `{"Content-Type": "application/json"}`
- Body: `{"msgtype": "text","text": {"content":"Nezha Probe:\n#NEZHA#"}}`
</details>
### WeChat Work Group Bot Example Contributor: [@ChowRex](https://github.com/ChowRex)
<details>
<summary>Click to expand/collapse</summary>
Supported placeholders list
```json
{
"content": "#NEZHA#",
"ServerName": "#SERVER.NAME#",
"ServerIP": "#SERVER.IP#",
"ServerIPV4": "#SERVER.IPV4#",
"ServerIPV6": "#SERVER.IPV6#",
"CPU": "#SERVER.CPU#",
"MEM": "#SERVER.MEM#",
"SWAP": "#SERVER.SWAP#",
"DISK": "#SERVER.DISK#",
"NetInSpeed": "#SERVER.NETINSPEED#",
"NetOutSpeed": "#SERVER.NETOUTSPEED#",
"TransferIn": "#SERVER.TRANSFERIN#",
"TranferOut": "#SERVER.TRANSFEROUT#",
"Load1": "#SERVER.LOAD1#",
"Load5": "#SERVER.LOAD5#",
"Load15": "#SERVER.LOAD15#",
"TCP_CONN_COUNT": "#SERVER.TCPCONNCOUNT", # invalid
"UDP_CONN_COUNT": "#SERVER.UDPCONNCOUNT", # invalid
}
```
> This document is **NOT** available in English.
>
> [Group Bot Configuration Instructions - Document - WeChat Work Developer Center](https://developer.work.weixin.qq.com/document/path/91770#markdown%E7%B1%BB%E5%9E%8B)
- Name: WeChat Work Group Bot
- URL: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_BOT_KEY
- Request Method: POST
- Request Type: JSON
- Body:
```json
{
"msgtype": "markdown",
"markdown": {
"content": "# Nezha Notification\n\n\"#NEZHA#\"\n\n> Name: \"#SERVER.NAME#\"\n> IP: \"#SERVER.IP#\"\n> IPv4: \"#SERVER.IPV4#\"\nIPv6: \"#SERVER.IPV6#\"\n> CPU: \"#SERVER.CPU#\"\n> Memory: \"#SERVER.MEM#\"\n> Swap: \"#SERVER.SWAP#\"\n> Disk: \"#SERVER.DISK#\"\n> Upload Speed: \"#SERVER.NETINSPEED#\"\n> Download Speed: \"#SERVER.NETOUTSPEED#\"\n> Total Upload: \"#SERVER.TRANSFERIN#\"\n> Total Download: \"#SERVER.TRANSFEROUT#\"\n> Load1: \"#SERVER.LOAD1#\"\n> Load5: \"#SERVER.LOAD5#\"\n> Load15: \"#SERVER.LOAD15#\"\n> TCP Connection Count: \"#SERVER.TCPCONNCOUNT\"\n> UDP Connection Count: \"#SERVER.UDPCONNCOUNT\"\n\n"
}
}
```
> Sorry, this document is **NOT** available in English.
>
> [群机器人配置说明 - 文档 - 企业微信开发者中心](https://developer.work.weixin.qq.com/document/path/91770#markdown%E7%B1%BB%E5%9E%8B)
- NameWechatWork Group bot notification
- URLhttps://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_BOT_KEY
- Request method: POST
- Request type: JSON
- Body:
```json
{
"msgtype": "markdown",
"markdown": {
"content": "# Nezha Notification\n\n\"#NEZHA#\"\n\n> ServerName: \"#SERVER.NAME#\"\n> IP: \"#SERVER.IP#\"\n> IPv4: \"#SERVER.IPV4#\"\n> IPv6: \"#SERVER.IPV6#\"\n> CPU: \"#SERVER.CPU#\"\n> Memory: \"#SERVER.MEM#\"\n> SWAP: \"#SERVER.SWAP#\"\n> Storage: \"#SERVER.DISK#\"\n> Real-time Upload: \"#SERVER.NETINSPEED#\"\n> Real-time Download: \"#SERVER.NETOUTSPEED#\"\n> Total Upload: \"#SERVER.TRANSFERIN#\"\n> Total Download: \"#SERVER.TRANSFEROUT#\"\n> 1m Load: \"#SERVER.LOAD1#\"\n> 5m Load: \"#SERVER.LOAD5#\"\n> 15m Load: \"#SERVER.LOAD15#\"\n> TCP Connections: \"#SERVER.TCPCONNCOUNT\"\n> UDP Connections: \"#SERVER.UDPCONNCOUNT\"\n\n"
}
}
```
Delete relevant content information as needed
![Notice Picture](https://user-images.githubusercontent.com/30169860/223605886-b7736825-24b8-4b6c-8bc9-96ac388599ef.png)
You can remove or add relevant information as needed.
<br/>
<br/>
</details>
## Description of notification rules
## Notification Rule Explanation
### Basic Rules
- Type: one or more types can be selected, such as in a rule to select more than one type, you need to **meet all the selected types at the same time** to trigger the notification (see the example later)
- `cpu``memory``swap``disk`
- `net_in_speed` Inbound speed, `net_out_speed` Outbound speed, `net_all_speed` Inbound + Outbound speed, `transfer_in` Inbound Transfer, `transfer_out` Outbound Transfer, `transfer_all` Total Transfer
- `offline` Offline monitoring
- `load1``load5``load15` Load
- `process_count` Number of processes _Currently, counting the number of processes takes up too many resources and is not supported at the moment_
- `tcp_conn_count``udp_conn_count` Number of connections
- durationLasting for a few seconds, the notification will only be triggered when the sampling record reaches 30% or more within a few seconds
- min/max
- Transfer, network speed, and other values of the same type. Unit is byte (1KB=1024B1MB = 1024\*1024B)
- Memory, hard disk, CPU. units are usage percentages
- No setup required for offline monitoring
- cover `[{"type":"offline","duration":10, "cover":0, "ignore":{"5": true}}]`
- `0` Cover all, use `ignore` to ignore specific servers
- `1` Ignore all, use `ignore` to monitoring specific servers
For example: `[{"type":"offline","duration":10, "cover":0, "ignore":{"5": true}}]`
- ignore: Select to ignore specific servers, use with `cover` with server id and boolean, e.g.: `{"1": true, "2":false}`
- `type`: You can choose one or more types. If multiple types are selected in one rule, **all selected types must be satisfied** to trigger a notification (refer to the examples below)
- `cpu`, `memory`, `swap`, `disk`
- `net_in_speed` inbound network speed, `net_out_speed` outbound network speed, `net_all_speed` total network speed, `transfer_in` inbound traffic, `transfer_out` outbound traffic, `transfer_all` total traffic
- `offline` offline monitoring
- `load1`, `load5`, `load15` load
- `process_count` process count (currently resource-intensive due to thread count, not supported temporarily)
- `tcp_conn_count`, `udp_conn_count` connection count
- `duration`: Duration in seconds. An notification is triggered if 30% or more of the samples exceed the threshold within this duration (to prevent data spikes).
- `min` or `max`:
- For traffic and network speed, the unit is bytes (1KB = 1024B, 1MB = 1024 * 1024B)
- For memory, disk, and CPU, the unit is percentage
- No need to set this for offline monitoring
- `cover`:
- `0` monitors all servers, use `ignore` to exclude specific servers
- `1` ignores all servers, use `ignore` to monitor specific servers
Example: `[{"type":"offline","duration":10, "cover":0, "ignore":{"5": true}}]`
- `ignore`: Select specific servers to exclude, used with `cover`, content is server ID and boolean value, e.g., `{"1": true, "2": false}`
**Complete examples:**
**Complete Examples:**
>>Add an offline notification
>
> - Name: Offline notification
> - Rules: `[{"Type":"offline","Duration":10}]`
> - Enable: √
Add an offline notification:
- Name: Offline Notification
- Rule: `[{"Type":"offline","Duration":10}]`
- Enabled: √
Add an notification for CPU usage exceeding 50% for 10 seconds **and** memory usage below 20% for 20 seconds:
>>Add an notification when the CPU exceeds 50% for 10s **but** the memory usage is below 20% for 20s
>
> - Name: CPU and RAM
> - Rules: `[{"Type":"cpu","Min":0,"Max":50,"Duration":10},{"Type":"memory","Min":20,"Max":0,"Duration":20}]`
> - Enable: √
- Name: CPU+Memory
- Rule: `[{"Type":"cpu","Min":0,"Max":50,"Duration":10},{"Type":"memory","Min":20,"Max":0,"Duration":20}]`
- Enabled: √
>>Send specific server notifications to specific notification groups
>
>Case:
>You have four servers, 1, 2, 3, 4, and two different notification groups, A and B
>1, 2 The two servers are down for 10 minutes and send a notification to Notification Group A
>3, 4 These two servers are down for ten minutes and then send a notification to Notification Group B
>
>First you need to set up two notification groups, A and B, and then add two alarm rules:
>
>**Rule I:**
> - Name: 1, 2 Off-line, send notification to group A
> - Rules:`[{"type":"offline","duration":600,"cover":1,"ignore":{"1":true,"2":true}}]`
> - Notification group: A
> - Enable: √
>
>**Rule II:**
> - Name: 3, 4 Off-line, send notification to group B
> - Rules:`[{"type":"offline","duration":600,"cover":1,"ignore":{"3":true,"4":true}}]`
> - Notification group: B
> - Enable: √
Send notifications for specific servers to specific notification groups:
**Using these rules flexibly will help you to make full use of the notification function**
Scenario example:
There are 4 servers (1, 2, 3, 4) and two notification groups (A, B).
Notify group A if servers 1 and 2 are offline for 10 minutes.
Notify group B if servers 3 and 4 are offline for 10 minutes.
<br/>
First, set up notification groups A and B, then add two notification rules:
### Special: Any-cycle transfer notification
**Rule 1:**
Can be used as monthly transfer notificatin
- Name: 1, 2 Offline, Send to Notification Group A
- Rule: `[{"type":"offline","duration":600,"cover":1,"ignore":{"1":true,"2":true}}]`
- Notification Group: A
- Enabled: √
- type
- `transfer_in_cycle` Inbound transfer during the cycle
- `transfer_out_cycle` Outbound transfer during the cycle
- `transfer_all_cycle` The sum of inbound and outbound transfer during the cycle
**Rule 2:**
- `cycle_start` Start date of the statistical cycle (can be the start date of your server's billing cycle), the time format is RFC3339, for example, the format in Beijing time zone is `2022-01-11T08:00:00.00+08:00`
- `cycle_interval` Interval time cycle (For example, if the cycle is in days and the value is 7, it means that the statistics are counted every 7 days)
- `cycle_unit` Statistics cycle unit, default `hour`, optional (`hour`, `day`, `week`, `month`, `year`)
- `min/max`, `cover`, `ignore` Please refer to the basic rules to configure
- Name: 3, 4 Offline, Send to Notification Group B
- Rule: `[{"type":"offline","duration":600,"cover":1,"ignore":{"3":true,"4":true}}]`
- Notification Group: B
- Enabled: √
>Example:
>>The servers with ID 3 and 4 (defined in the `ignore`) are counted on the 1st of each month, and a notification is triggered when the monthly outbound transfer reaches 1TB during the cycle.
>
> `[{"type":"transfer_out_cycle","max":1099511627776,"cycle_start":"2022-01-01T00:00:00+08:00","cycle_interval":1,"cycle_unit":"month","cover":1,"ignore":{"3":true,"4":true}}]`
**Flexibly using parameters can make your notification function fully utilized**
## Description of mode of triggering notification
- Always triggered: A notification is triggered each time the status reported by the Agent matches the rules of the notification
- Triggered only once: only one notification is triggered when the state changes, such as changing from normal state to abnormal state or abnormal state back to normal state
### Special: Any Cycle Traffic notification
## Set the task to be executed when notification
If you need to perform a task while sending a notification message, you can set those items
+ `Tasks to be triggered in case of failure` The task to be executed when the notification status matches the change from "normal" to "failure", the task should be set in advance in the tasks page
+ `Tasks to be triggered after fault recovery` The task to be executed when the notification status matches the change from " failure " to " normal ", the task should be set in advance in the tasks page
Can be used for monthly traffic monitoring
- `type`:
- `transfer_in_cycle` inbound traffic during the cycle
- `transfer_out_cycle` outbound traffic during the cycle
- `transfer_all_cycle` total traffic during the cycle
- `cycle_start`: The start date of the statistical cycle (can be the start date of your server billing cycle). The time format is RFC3339, e.g., Beijing time is `2022-01-11T08:00:00.00+08:00`
- `cycle_interval`: The number of statistical cycle units (e.g., if the cycle unit is days, and this value is 7, it means statistics are collected every 7 days)
- `cycle_unit`: Statistical cycle unit, default is `hour`, optional (`hour`, `day`, `week`, `month`, `year`)
- `min/max`, `cover`, `ignore` refer to basic rule configuration
Example:
For servers with IDs 3 and 4 (defined in ignore), if the monthly outbound traffic exceeds 1TB starting from the 1st of each month, send an notification:
```json
[{"type":"transfer_out_cycle","max":1099511627776,"cycle_start":"2022-01-01T00:00:00+08:00","cycle_interval":1,"cycle_unit":"month","cover":1,"ignore":{"3":true,"4":true}}]
```
## Notification Trigger Modes
- **Always Trigger**: A notification is triggered every time the Agent reports a status that matches the notification rule.
- **Single Trigger**: A notification is triggered only once when the status changes, such as from normal to abnormal or from abnormal to normal.
## Set Tasks to Execute on notifications
If you need to execute a task while sending an notification message, you can set this item.
- **Task on Notification**: The task to be executed when the notification status changes from "normal" to "event". The task should be set in the tasks page in advance.
- **Task on Recovery**: The task to be executed when the notification status changes from "event" to "normal". The task should be set in the tasks page in advance.

View File

@ -15,7 +15,7 @@ hero:
link: https://ops.naibahq.com
- theme: alt
text: Get Started →
link: /guide/dashboard
link: en_US/guide/dashboard
features:
- title: One-Click Installation

View File

@ -2,273 +2,309 @@
outline: deep
---
哪吒监控支持对服务器的负载、CPU、内存、硬盘、流量、月流量、进程数、连接数进行监控并在其中某项达到用户设定值时发送告警通知
<br/>
<br/>
## 灵活的通知方式
哪吒监控支持对服务器的负载、CPU、内存、硬盘、流量、月流量、进程数、连接数进行监控并在达到用户设定的阈值时发送告警通知。
## 灵活的通知方式
- 在面板消息中,占位符 `#DATETIME#` 代表事件发生的时间戳。当通知被触发时,面板会自动将 `#DATETIME#` 替换为事件的实际时间。
- `#NEZHA#` 是面板消息占位符,面板触发通知时会自动用实际消息替换占位符
- Body 内容是`JSON` 格式的:**当请求类型为 FORM 时**,值为 `key:value` 的形式,`value` 里面可放置占位符,通知时会自动替换。**当请求类型为 JSON 时** 只会简单进行字符串替换后直接提交到`URL`
- `#NEZHA#` 是面板消息占位符,面板触发通知时会自动用实际消息替换占位符
- Body 内容是 `JSON` 格式的:**当请求类型为 FORM 时**,值为 `key:value` 的形式,`value` 里面可放置占位符,通知时会自动替换。**当请求类型为 JSON 时** 只会简单进行字符串替换后直接提交到 `URL`
- URL 里面也可放置占位符,请求时会进行简单的字符串替换。
**请参考以下的通知方式示例,也可以根据自己的需求灵活设置推送方式**
**请参考以下的通知方式示例,也可以根据自己的需求灵活设置推送方式**
### Bark 示例
### Bark 示例
<details>
<summary>点击展开/收起</summary>
<summary>点击展开/收起</summary>
- 名称Bark
- URL 组成: 第一个部分是 key,之后有三个匹配 /:key/:body or /:key/:title/:body or /:key/:category/:title/:body
- 请求方式: GET
- 请求类型: 默认
- Body: 空
- 名称Bark
- URL 组成: /:key/:body or /:key/:title/:body or /:key/:category/:title/:body
- 请求方式: GET
- 请求类型: 默认
- Body: 空
- 名称Bark
- URL 组成: /push
- 请求方式: POST
- 请求类型: form
- Body: `{"title": "#SERVER.NAME#","device_key":"xxxxxxxxx","body":"#NEZHA#","icon":"https://xxxxxxxx/nz.png"}`
</details>
### Slack 示例 贡献者:[@白歌](https://github.com/cantoblanco)
<details>
<summary>点击展开/收起</summary>
#### URL 参数获取说明
请提前准备好 Slack 的 Workspace 并为这个 Workspace 创建一个 App。如果你还没有创建可以在 [Slack API](https://api.slack.com/apps) 创建一个 App。
创建完成 App 后,需要为这个 App 添加一个 Incoming Webhook。在 App 的设置页面中找到 Incoming Webhooks将 Activate Incoming Webhooks 勾选为 ON在页面下方找到并点击 Add New Webhook to Workspace选择一个 Channel然后点击允许。完成创建后你会得到一个 Webhook URL使用这个 URL 替换下方的示例 URL。
- 名称Slack
- URLhttps://hooks.slack.com/services/xxxxxxxxx/xxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx
- 请求方式: POST
- 请求类型: JSON
- Body: `{"text":"#NEZHA#"}`
- 名称Bark
- URL 组成: /push
- 请求方式: POST
- 请求类型: form
- Body: `{"title": "#SERVER.NAME#","device_key":"xxxxxxxxx","body":"#NEZHA#","icon":"https://xxxxxxxx/nz.png"}`
</details>
### Server 酱示例
<details>
<summary>点击展开/收起</summary>
- 名称Server 酱
- URLhttps://sc.ftqq.com/SCUrandomkeys.send?title=哪吒告警信息&desp=#NEZHA#
- 请求方式: GET
- 请求类型: 默认
- Body: 空
- 名称Server 酱
- URLhttps://sc.ftqq.com/SCUrandomkeys.send?title=哪吒告警信息&desp=#NEZHA#
- 请求方式: GET
- 请求类型: 默认
- Body: 空
**Server 酱进阶**
- 名称Server 酱
- URLhttps://sc.ftqq.com/SCUrandomkeys.send
- 请求方式: POST
- 请求类型: FORM
- Body:
**Server 酱进阶**
- 名称Server 酱
- URLhttps://sc.ftqq.com/SCUrandomkeys.send
- 请求方式: POST
- 请求类型: FORM
- Body:
```json
{
"title": "#SERVER.NAME#",
"desp":"**#NEZHA#\n\n
平均负载: \"#SERVER.LOAD1#\",\"#SERVER.LOAD5#\",\"#SERVER.LOAD15#\"\n\n
## [点击访问面板](https://你的面板域名)\n\n
![logo](https://raw.githubusercontent.com/naiba/nezha/master/resource/static/brand.svg)"
"title": "#SERVER.NAME#",
"desp": "**#NEZHA#\n\n平均负载: \"#SERVER.LOAD1#\",\"#SERVER.LOAD5#\",\"#SERVER.LOAD15#\"\n\n## [点击访问面板](https://你的面板域名)\n\n![logo](https://raw.githubusercontent.com/naiba/nezha/master/resource/static/brand.svg)"
}
```
![展示](https://github.com/iilemon/nezhahq.github.io/blob/main/docs/images/photo_2023-03-16_00-22-47a.jpg?raw=true)
</details>
</details>
### Telegram 示例 贡献者:[@白歌](https://github.com/cantoblanco)
<details>
<summary>点击展开/收起</summary>
#### URL 参数获取说明
请提前在 Telegram 中创建一个机器人,获取到机器人的 token 和你的 Telegram 用户 ID。
机器人的 token 和用户 ID 都是数字和字母的组合,可以在 Telegram 中与 @userinfobot 对话获取自己的用户 ID。与 @BotFather 对话,输入命令 /newbot 创建一个机器人,创建完成后可以获得机器人的 token。
得到的 token 和用户 ID 都是字符串,可以直接拼接到 URL 中,如下所示,将其中的 botXXXXXX 替换为你的机器人 token将 YYYYYY 替换为你的用户 ID。注意你需要先与机器人对话否则机器人无法发送消息给你。
- 名称Telegram
- URLhttps://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&text=#NEZHA#
- 请求方式: GET
- 请求类型: 默认
- Body: 留空
</details>
### wxpusher 示例
**需要提前关注你的应用**
<details>
<summary>点击展开/收起</summary>
- 名称: wxpusher
- URLhttp://wxpusher.zjiecode.com/api/send/message
- 请求方式: POST
- 请求类型: JSON
- Body: `{"appToken":"你的appToken","topicIds":[],"content":"#NEZHA#","contentType":"1","uids":["你的uid"]}`
- 名称: wxpusher
- URLhttp://wxpusher.zjiecode.com/api/send/message
- 请求方式: POST
- 请求类型: JSON
- Body: `{"appToken":"你的appToken","topicIds":[],"content":"#NEZHA#","contentType":"1","uids":["你的uid"]}`
</details>
### Telegram 示例 贡献者:[@haitau](https://github.com/haitau)
### 邮件通知示例 - SendCloud 贡献者:[@白歌](https://github.com/cantoblanco)
<details>
<summary>点击展开/收起</summary>
- 名称telegram 机器人消息通知
- URLhttps://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&text=#NEZHA#
- 请求方式: GET
- 请求类型: 默认
- Body: 空
- URL 参数获取说明botXXXXXX 中的 XXXXXX 是在 telegram 中关注官方 @Botfather ,输入/newbot 创建新的机器人bot会提供的 token在提示 Use this token to access the HTTP API:后面一行)这里 'bot' 三个字母不可少。创建 bot 后,需要先在 telegram 中与 BOT 进行对话(随便发个消息),然后才可用 API 发送消息。YYYYYY 是 telegram 用户的数字 ID。与机器人@userinfobot 对话可获得。
</details>
### 邮件通知示例 - SendCloud 贡献者:[@白歌](https://github.com/cantoblanco)
<details>
<summary>点击展开/收起</summary>
**注意SendCloud 有每日免费发送邮件限额限制,这里仅作示例,你可以选择付费服务或其他类似的免费服务,使用方法类似。**
- 名称:邮件告警
- URLhttps://api.sendcloud.net/apiv2/mail/send?apiUser=<替换APIUSER>apiKey=<替换APIKEY>&from=<自定义发件邮箱>&fromName=Nezha&to=<自定义收件邮箱>&subject=Nezha-Notification&html=#NEZHA#
- 请求方式: POST
- 请求类型: JSON
- Header: 留空
- Body: 留空
URL 参数获取说明:此方式需提前在 [SendCloud](https://www.sendcloud.net/) 注册账号,创建发件邮箱,然后在[这里](https://www.sendcloud.net/sendSetting/apiuser)获取 APIUSER 和 APIKEY替换 URL 中的 <替换APIUSER><替换APIKEY> 为自己的 APIUSER 和 APIKEY替换 URL 中的 <自定义发件邮箱><自定义收件邮箱> 为自己的发件邮箱和收件邮箱。
#### URL 参数获取说明
该示例使用 SendCloud 作为发信服务,需提前在 [SendCloud](https://www.sendcloud.net/) 注册账号,创建发件邮箱,然后在[这里](https://www.sendcloud.net/sendSetting/apiuser)获取 APIUSER 和 APIKEY。
替换示例 URL 中的 `<替换APIUSER>``<替换APIKEY>` 为自己的 APIUSER 和 APIKEY替换 URL 中的 `<自定义发件邮箱>``<自定义收件邮箱>` 为任意的的发件邮箱和收件邮箱。
- 名称:邮件告警
- URLhttps://api.sendcloud.net/apiv2/mail/send?apiUser=<替换APIUSER>&apiKey=<替换APIKEY>&from=<自定义发件邮箱>&fromName=Nezha&to=<自定义收件邮箱>&subject=Nezha-Notification&html=#NEZHA#
- 请求方式: POST
- 请求类型: JSON
- Header: 留空
- Body: 留空
</details>
### 钉钉群机器人配置 示例
<details>
<summary>点击展开/收起</summary>
- 名称: 哪吒探针小跟班
- URLhttps://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxx
- 请求方式: POST
- 请求类型: JSON
- Header: `{"Content-Type": "application/json"}`
- Body: `{"msgtype": "text","text": {"content":"哪吒探针:\n#NEZHA#"}}`
- URL 参数获取说明机器人URL在钉钉群-管理机器人-创建机器人后获取安全方式选择自定义关键词Body中content中需包含该关键词
#### URL 参数获取说明
请提前在钉钉中创建一个机器人,获取到机器人的 token。
机器人 URL 在钉钉群 - 管理机器人 - 创建机器人后获取安全方式选择自定义关键词Body 中 content 值内需包含该关键词。
- 名称: 哪吒探针小跟班
- URLhttps://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxx
- 请求方式: POST
- 请求类型: JSON
- Header: `{"Content-Type": "application/json"}`
- Body: `{"msgtype": "text","text": {"content":"哪吒探针:\n#NEZHA#"}}`
</details>
### 企业微信 群机器人 示例 贡献者:[@ChowRex](https://github.com/ChowRex)
### 企业微信群机器人 示例 贡献者:[@ChowRex](https://github.com/ChowRex)
<details>
<summary>点击展开/收起</summary>
支持的占位符一览
支持的占位符一览
```json
{
"content": "#NEZHA#",
"ServerName": "#SERVER.NAME#",
"ServerIP": "#SERVER.IP#",
"ServerIPV4": "#SERVER.IPV4#",
"ServerIPV6": "#SERVER.IPV6#",
"CPU": "#SERVER.CPU#",
"MEM": "#SERVER.MEM#",
"SWAP": "#SERVER.SWAP#",
"DISK": "#SERVER.DISK#",
"NetInSpeed": "#SERVER.NETINSPEED#",
"NetOutSpeed": "#SERVER.NETOUTSPEED#",
"TransferIn": "#SERVER.TRANSFERIN#",
"TranferOut": "#SERVER.TRANSFEROUT#",
"Load1": "#SERVER.LOAD1#",
"Load5": "#SERVER.LOAD5#",
"Load15": "#SERVER.LOAD15#",
"TCP_CONN_COUNT": "#SERVER.TCPCONNCOUNT", # 无效
"UDP_CONN_COUNT": "#SERVER.UDPCONNCOUNT", # 无效
}
```
```json
{
"content": "#NEZHA#",
"ServerName": "#SERVER.NAME#",
"ServerIP": "#SERVER.IP#",
"ServerIPV4": "#SERVER.IPV4#",
"ServerIPV6": "#SERVER.IPV6#",
"CPU": "#SERVER.CPU#",
"MEM": "#SERVER.MEM#",
"SWAP": "#SERVER.SWAP#",
"DISK": "#SERVER.DISK#",
"NetInSpeed": "#SERVER.NETINSPEED#",
"NetOutSpeed": "#SERVER.NETOUTSPEED#",
"TransferIn": "#SERVER.TRANSFERIN#",
"TranferOut": "#SERVER.TRANSFEROUT#",
"Load1": "#SERVER.LOAD1#",
"Load5": "#SERVER.LOAD5#",
"Load15": "#SERVER.LOAD15#",
"TCP_CONN_COUNT": "#SERVER.TCPCONNCOUNT", # 无效
"UDP_CONN_COUNT": "#SERVER.UDPCONNCOUNT", # 无效
}
```
> [群机器人配置说明 - 文档 - 企业微信开发者中心](https://developer.work.weixin.qq.com/document/path/91770#markdown%E7%B1%BB%E5%9E%8B)
> [群机器人配置说明 - 文档 - 企业微信开发者中心](https://developer.work.weixin.qq.com/document/path/91770#markdown%E7%B1%BB%E5%9E%8B)
- 名称:企业微信群机器人
- URLhttps://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_BOT_KEY
- 请求方式: POST
- 请求类型: JSON
- Body:
```json
{
"msgtype": "markdown",
"markdown": {
"content": "# 哪吒通知消息\n\n\"#NEZHA#\"\n\n> 名称: \"#SERVER.NAME#\"\n> IP: \"#SERVER.IP#\"\n> IPv4: \"#SERVER.IPV4#\"\n> IPv6: \"#SERVER.IPV6#\"\n> CPU: \"#SERVER.CPU#\"\n> 内存: \"#SERVER.MEM#\"\n> 交换分区: \"#SERVER.SWAP#\"\n> 存储: \"#SERVER.DISK#\"\n> 实时上传速度: \"#SERVER.NETINSPEED#\"\n> 实时下载速度: \"#SERVER.NETOUTSPEED#\"\n> 总上传: \"#SERVER.TRANSFERIN#\"\n> 总下载: \"#SERVER.TRANSFEROUT#\"\n> 1分钟内负载: \"#SERVER.LOAD1#\"\n> 5分钟内负载: \"#SERVER.LOAD5#\"\n> 15分钟内负载: \"#SERVER.LOAD15#\"\n> TCP连接数: \"#SERVER.TCPCONNCOUNT\"\n> UDP连接数: \"#SERVER.UDPCONNCOUNT\"\n\n"
}
- 名称:企业微信群机器人
- URLhttps://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_BOT_KEY
- 请求方式: POST
- 请求类型: JSON
- Body:
```json
{
"msgtype": "markdown",
"markdown": {
"content": "# 哪吒通知消息\n\n\"#NEZHA#\"\n\n> 名称: \"#SERVER.NAME#\"\n> IP: \"#SERVER.IP#\"\n> IPv4: \"#SERVER.IPV4#\"\n> IPv6: \"#SERVER.IPV6#\"\n> CPU: \"#SERVER.CPU#\"\n> 内存: \"#SERVER.MEM#\"\n> 交换分区: \"#SERVER.SWAP#\"\n> 存储: \"#SERVER.DISK#\"\n> 实时上传速度: \"#SERVER.NETINSPEED#\"\n> 实时下载速度: \"#SERVER.NETOUTSPEED#\"\n> 总上传: \"#SERVER.TRANSFERIN#\"\n> 总下载: \"#SERVER.TRANSFEROUT#\"\n> 1分钟内负载: \"#SERVER.LOAD1#\"\n> 5分钟内负载: \"#SERVER.LOAD5#\"\n> 15分钟内负载: \"#SERVER.LOAD15#\"\n> TCP连接数: \"#SERVER.TCPCONNCOUNT\"\n> UDP连接数: \"#SERVER.UDPCONNCOUNT\"\n\n"
}
```
根据需求删减相关内容信息即可
![通知效果](https://user-images.githubusercontent.com/30169860/223605620-eac53ee6-09f9-4583-94fa-9b0cdedba81c.png)
}
```
根据需求删减相关内容信息即可。
![通知效果](https://user-images.githubusercontent.com/30169860/223605620-eac53ee6-09f9-4583-94fa-9b0cdedba81c.png)
</details>
### 飞书群机器人配置 示例 贡献者:[@eya46](https://github.com/eya46)
<details>
<summary>点击展开/收起</summary>
- 名称: 哪吒面板Bot
- URLhttps://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxxxxxxxxxx
- 请求方式: POST
- 请求类型: JSON
- Body: `{"content":{"text":"#NEZHA#\n#DATETIME#"},"msg_type":"text"}`
- URL 参数获取说明机器人URL通过飞书群-群机器人-添加机器人-自定义机器人(webhook)创建后获取
</details>
#### URL 参数获取说明
<br/>
<br/>
机器人 URL 通过飞书群 - 群机器人 - 添加机器人 - 自定义机器人(webhook)创建后获取。
- 名称: 哪吒面板 Bot
- URLhttps://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxxxxxxxxxx
- 请求方式: POST
- 请求类型: JSON
- Body: `{"content":{"text":"#NEZHA#\n#DATETIME#"},"msg_type":"text"}`
</details>
## 告警规则说明
### 基本规则
- type可选取一个或多个类型如在一个规则中选择了多个类型需要**同时满足**所有选择的类型才会触发通知(可参考后面的示例)
- `type`:可选取一个或多个类型,如在一个规则中选择了多个类型,需要**同时满足**所有选择的类型才会触发通知(可参考后面的示例)
- `cpu``memory``swap``disk`
- `net_in_speed` 入站网速、`net_out_speed` 出站网速、`net_all_speed` 双向网速、`transfer_in` 入站流量、`transfer_out` 出站流量、`transfer_all` 双向流量
- `offline` 离线监控
- `load1``load5``load15` 负载
- `process_count` 进程数 _目前取线程数占用资源太多暂时不支持_
- `process_count` 进程数(目前取线程数占用资源太多,暂时不支持)
- `tcp_conn_count``udp_conn_count` 连接数
- duration持续数秒数秒内采样记录 30% 以上触发阈值才会告警(防数据插针)
- min 或 max
- 流量、网速类数值 为字节1KB=1024B1MB = 1024\*1024B
- `duration`:持续数秒,数秒内采样记录 30% 以上触发阈值才会告警(防数据插针)
- `min``max`
- 流量、网速类单位为字节1KB=1024B1MB=1024*1024B
- 内存、硬盘、CPU 以占用百分比计数
- 离线监控无需设置此项
- cover
- `0` 监控所有,通过 `ignore` 忽略特定服务器
- `1` 忽略所有,通过 `ignore` 监控特定服务器
- `cover`
- `0` 监控所有服务器,通过 `ignore` 忽略特定服务器
- `1` 忽略所有服务器,通过 `ignore` 监控特定服务器
例如:`[{"type":"offline","duration":10, "cover":0, "ignore":{"5": true}}]`
- ignore: 选择忽略特定服务器,搭配 `cover` 使用,内容为服务器 id 和布尔值,例如:`{"1": true, "2":false}`
- `ignore`:选择忽略特定服务器,搭配 `cover` 使用,内容为服务器 ID 和布尔值,例如:`{"1": true, "2": false}`
**完整示例:**
>>添加一个离线告警
>
> - 名称:离线通知
> - 规则:`[{"Type":"offline","Duration":10}]`
> - 启用:√
添加一个离线告警:
- 名称:离线通知
- 规则:`[{"Type":"offline","Duration":10}]`
- 启用:√
添加一个监控 CPU 持续 10 秒超过 50% **且** 内存持续 20 秒占用低于 20% 的告警:
>>添加一个监控 CPU 持续 10s 超过 50% **且** 内存持续 20s 占用低于 20% 的告警
>
> - 名称CPU+内存
> - 规则:`[{"Type":"cpu","Min":0,"Max":50,"Duration":10},{"Type":"memory","Min":20,"Max":0,"Duration":20}]`
> - 启用:√
- 名称CPU+内存
- 规则:`[{"Type":"cpu","Min":0,"Max":50,"Duration":10},{"Type":"memory","Min":20,"Max":0,"Duration":20}]`
- 启用:√
将特定的服务器通知发送到特定的通知分组:
>>将特定的服务器通知发送到特定的通知分组
>
>示例场景:
>你有 1、2、3、4 四台服务器和 A、B 两个不同的通知组
>1、2 这两台服务器掉线十分钟后给通知组 A 发送通知
>3、4 这两台服务器掉线十分钟后给通知组 B 发送通知
>
>首先你需要先设置好 A、B 两个通知组,然后添加两条告警规则:
>
>**规则一:**
> - 名称1、2 离线,发送给通知组 A
> - 规则:`[{"type":"offline","duration":600,"cover":1,"ignore":{"1":true,"2":true}}]`
> - 通知方式组: A
> - 启用:√
>
>**规则二:**
> - 名称3、4 离线,发送给通知组 B
> - 规则:`[{"type":"offline","duration":600,"cover":1,"ignore":{"3":true,"4":true}}]`
> - 通知方式组: B
> - 启用:√
示例场景:
有 1、2、3、4 四台服务器和 A、B 两个不同的通知组。
1、2 这两台服务器掉线十分钟后给通知组 A 发送通知。
3、4 这两台服务器掉线十分钟后给通知组 B 发送通知。
首先你需要先设置好 A、B 两个通知组,然后添加两条告警规则:
**规则一:**
- 名称1、2 离线,发送给通知组 A
- 规则:`[{"type":"offline","duration":600,"cover":1,"ignore":{"1":true,"2":true}}]`
- 通知方式组A
- 启用:√
**规则二:**
- 名称3、4 离线,发送给通知组 B
- 规则:`[{"type":"offline","duration":600,"cover":1,"ignore":{"3":true,"4":true}}]`
- 通知方式组B
- 启用:√
**灵活使用参数可以让你的告警功能被充分使用**
<br/>
### 特殊:任意周期流量告警
可以用作月流量告警
可以用作月流量监控
- type:
- `type`
- `transfer_in_cycle` 周期内的入站流量
- `transfer_out_cycle` 周期内的出站流量
- `transfer_all_cycle` 周期内双向流量和
- cycle_start 统计周期开始日期可以是你机器计费周期的开始日期时间格式为RFC3339例如北京时间为`2022-01-11T08:00:00.00+08:00`
- cycle_interval每隔多少个周期单位(例如,周期单位为天,该值为 7则代表每隔 7 天统计一次)
- cycle_unit 统计周期单位,默认`hour`,可选(`hour`, `day`, `week`, `month`, `year`)
- min/max、cover、ignore 参考基本规则配置
- `transfer_all_cycle` 周期内双向流量
- `cycle_start`:统计周期开始日期(可以是你机器计费周期的开始日期),时间格式为 RFC3339例如北京时间为 `2022-01-11T08:00:00.00+08:00`
- `cycle_interval`:统计周期单位的数量(例如,周期单位为天,该值为 7则代表每隔 7 天统计一次)
- `cycle_unit`:统计周期单位,默认 `hour`,可选(`hour`, `day`, `week`, `month`, `year`
- `min/max``cover``ignore` 参考基本规则配置
>示例:
>> ID 为 3 和 4 的服务器ignore 里面定义),以每月 1 号为统计周期,周期内统计的出站月流量达到 1TB 时告警
>
>`[{"type":"transfer_out_cycle","max":1099511627776,"cycle_start":"2022-01-01T00:00:00+08:00","cycle_interval":1,"cycle_unit":"month","cover":1,"ignore":{"3":true,"4":true}}]`
示例:
## 通知触发模式
- 始终触发:每当 Agent 上报的状态符合告警的规则时,都会触发一次通知
- 单次触发:仅状态改变时触发一次通知,如从正常状态改变为异常状态,或异常状态恢复为正常状态
ID 为 3 和 4 的服务器ignore 里面定义),以每月 1 号为统计周期,周期内统计的出站月流量达到 1TB 时告警:
## 设置告警时执行任务
如果你需要在发出告警消息的同时执行某项任务,可以设置此项目
+ `告警时触发任务` 当告警状态符合从“正常”变更为“事件”时,所要执行的任务,任务应提前在任务页设置
+ `恢复时触发任务` 当告警状态符合从“事件”恢复为“正常”时,所要执行的任务,任务应提前在任务页设置
```json
[{"type":"transfer_out_cycle","max":1099511627776,"cycle_start":"2022-01-01T00:00:00+08:00","cycle_interval":1,"cycle_unit":"month","cover":1,"ignore":{"3":true,"4":true}}]
```
## 通知触发模式
- **始终触发**:每当 Agent 上报的状态符合告警的规则时,都会触发一次通知。
- **单次触发**:仅状态改变时触发一次通知,如从正常状态改变为异常状态,或异常状态恢复为正常状态。
## 设置告警时执行任务
如果需要在发出告警消息的同时执行某项任务,可以设置此项目。
- **告警时触发任务**:当告警状态符合从“正常”变更为“事件”时,所要执行的任务,任务应提前在任务页设置。
- **恢复时触发任务**:当告警状态符合从“事件”恢复为“正常”时,所要执行的任务,任务应提前在任务页设置。