41 lines
37 KiB
JavaScript
41 lines
37 KiB
JavaScript
import{_ as i,c as s,o as t,a4 as a}from"./chunks/framework.BmdFiWrL.js";const E=JSON.parse('{"title":"Notification Configuration","description":"","frontmatter":{"outline":"deep"},"headers":[],"relativePath":"en_US/guide/notifications.md","filePath":"en_US/guide/notifications.md","lastUpdated":1723164446000}'),e={name:"en_US/guide/notifications.md"},n=a(`<h1 id="notification-configuration" tabindex="-1">Notification Configuration <a class="header-anchor" href="#notification-configuration" aria-label="Permalink to "Notification Configuration""></a></h1><p>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.</p><h2 id="flexible-notification-methods" tabindex="-1">Flexible Notification Methods <a class="header-anchor" href="#flexible-notification-methods" aria-label="Permalink to "Flexible Notification Methods""></a></h2><ul><li>In Dashboard messages, the placeholder <code>#DATETIME#</code> represents the timestamp of the event. When the notification is triggered, the Dashboard automatically replaces <code>#DATETIME#</code> with the actual event time.</li><li><code>#NEZHA#</code> is a placeholder for Dashboard messages, and the Dashboard automatically replaces the placeholder with the actual message when the notification is triggered.</li><li>The body content is in <code>JSON</code> format: <strong>When the request type is FORM</strong>, the value is in <code>key:value</code> form, and placeholders can be placed inside <code>value</code>. The placeholders will be automatically replaced during notification. <strong>When the request type is JSON</strong>, only simple string replacement is performed before being submitted to the <code>URL</code>.</li><li>Placeholders can also be placed inside the URL, and simple string replacement will be performed during the request.</li></ul><p><strong>Refer to the following notification method examples, and you can also flexibly set the push method according to your needs.</strong></p><h3 id="bark-example" tabindex="-1">Bark Example <a class="header-anchor" href="#bark-example" aria-label="Permalink to "Bark Example""></a></h3><details><summary>Click to expand/collapse</summary><ul><li><p>Name: Bark</p></li><li><p>URL structure: /:key/:body or /:key/:title/:body or /:key/:category/:title/:body</p></li><li><p>Request Method: GET</p></li><li><p>Request Type: Default</p></li><li><p>Body: Empty</p></li><li><p>Name: Bark</p></li><li><p>URL structure: /push</p></li><li><p>Request Method: POST</p></li><li><p>Request Type: form</p></li><li><p>Body: <code>{"title": "#SERVER.NAME#","device_key":"xxxxxxxxx","body":"#NEZHA#","icon":"https://xxxxxxxx/nz.png"}</code></p></li></ul></details><h3 id="slack-example-contributor-白歌" tabindex="-1">Slack Example Contributor: <a href="https://github.com/cantoblanco" target="_blank" rel="noreferrer">@白歌</a> <a class="header-anchor" href="#slack-example-contributor-白歌" aria-label="Permalink to "Slack Example Contributor: [@白歌](https://github.com/cantoblanco)""></a></h3><details><summary>Click to expand/collapse</summary><h4 id="url-parameter-acquisition-instructions" tabindex="-1">URL Parameter Acquisition Instructions <a class="header-anchor" href="#url-parameter-acquisition-instructions" aria-label="Permalink to "URL Parameter Acquisition Instructions""></a></h4><p>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 <a href="https://api.slack.com/apps" target="_blank" rel="noreferrer">Slack API</a>.</p><p>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.</p><ul><li>Name: Slack</li><li>URL: <a href="https://hooks.slack.com/services/xxxxxxxxx/xxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx" target="_blank" rel="noreferrer">https://hooks.slack.com/services/xxxxxxxxx/xxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx</a></li><li>Request Method: POST</li><li>Request Type: JSON</li><li>Body: <code>{"text":"#NEZHA#"}</code></li></ul></details><h3 id="telegram-example-contributor-白歌" tabindex="-1">Telegram Example Contributor: <a href="https://github.com/cantoblanco" target="_blank" rel="noreferrer">@白歌</a> <a class="header-anchor" href="#telegram-example-contributor-白歌" aria-label="Permalink to "Telegram Example Contributor: [@白歌](https://github.com/cantoblanco)""></a></h3><details><summary>Click to expand/collapse</summary><h4 id="url-parameter-acquisition-instructions-1" tabindex="-1">URL Parameter Acquisition Instructions <a class="header-anchor" href="#url-parameter-acquisition-instructions-1" aria-label="Permalink to "URL Parameter Acquisition Instructions""></a></h4><p>Create a bot in Telegram and get the bot's token and your Telegram user ID.</p><p>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.</p><p>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.</p><ul><li>Name: Telegram</li><li>URL: <a href="https://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&text=#NEZHA#" target="_blank" rel="noreferrer">https://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&text=#NEZHA#</a></li><li>Request Method: GET</li><li>Request Type: Default</li><li>Body: Empty</li></ul></details><h3 id="email-notification-example-outlook-contributor-白歌" tabindex="-1">Email Notification Example - Outlook Contributor: <a href="https://github.com/cantoblanco" target="_blank" rel="noreferrer">@白歌</a> <a class="header-anchor" href="#email-notification-example-outlook-contributor-白歌" aria-label="Permalink to "Email Notification Example - Outlook Contributor: [@白歌](https://github.com/cantoblanco)""></a></h3><details><summary>Click to expand/collapse</summary><p><strong>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.</strong></p><h4 id="url-parameter-acquisition-instructions-2" tabindex="-1">URL Parameter Acquisition Instructions <a class="header-anchor" href="#url-parameter-acquisition-instructions-2" aria-label="Permalink to "URL Parameter Acquisition Instructions""></a></h4><p>This example uses SendCloud as the email service. You need to register an account on <a href="https://www.sendcloud.net/" target="_blank" rel="noreferrer">SendCloud</a>, create a sender email, and then obtain the APIUSER and APIKEY <a href="https://www.sendcloud.net/sendSetting/apiuser" target="_blank" rel="noreferrer">here</a>.</p><p>Replace <code><replaceAPIUSER></code> and <code><replaceAPIKEY></code> in the example URL below with your APIUSER and APIKEY, and replace <code><customSenderEmail></code> and <code><customRecipientEmail></code> with any sender and recipient email addresses.</p><ul><li>Name: MS Mail Notification</li><li>URL:<a href="https://graph.microsoft.com/v1.0/me/microsoft.graph.sendMail" target="_blank" rel="noreferrer">https://graph.microsoft.com/v1.0/me/microsoft.graph.sendMail</a></li><li>Request method: POST</li><li>Request type: JSON</li><li>Header: <code>{"Content-type":"application/json", "Authorization":"Bearer {Token}"}</code></li><li>Body:<div class="language-json vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">{</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "message"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: {</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "subject"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"Server Status Notification"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "body"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: {</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "contentType"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"Text"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "content"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#NEZHA#"</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> },</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "toRecipients"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: [</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "emailAddress"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: {</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "address"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"ADDRESS FOR RECEVING EMAILS"</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ]</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div></li></ul></details><h3 id="dingtalk-group-bot-configuration-example" tabindex="-1">DingTalk Group Bot Configuration Example <a class="header-anchor" href="#dingtalk-group-bot-configuration-example" aria-label="Permalink to "DingTalk Group Bot Configuration Example""></a></h3><details><summary>Click to expand/collapse</summary><h4 id="url-parameter-acquisition-instructions-3" tabindex="-1">URL Parameter Acquisition Instructions <a class="header-anchor" href="#url-parameter-acquisition-instructions-3" aria-label="Permalink to "URL Parameter Acquisition Instructions""></a></h4><p>Create a bot in DingTalk in advance and get the bot's token.</p><p>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.</p><ul><li>Name: Nezha Assistant</li><li>URL: <a href="https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxx" target="_blank" rel="noreferrer">https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxx</a></li><li>Request Method: POST</li><li>Request Type: JSON</li><li>Header: <code>{"Content-Type": "application/json"}</code></li><li>Body: <code>{"msgtype": "text","text": {"content":"Nezha Probe:\\n#NEZHA#"}}</code></li></ul></details><h3 id="wechat-work-group-bot-example-contributor-chowrex" tabindex="-1">WeChat Work Group Bot Example Contributor: <a href="https://github.com/ChowRex" target="_blank" rel="noreferrer">@ChowRex</a> <a class="header-anchor" href="#wechat-work-group-bot-example-contributor-chowrex" aria-label="Permalink to "WeChat Work Group Bot Example Contributor: [@ChowRex](https://github.com/ChowRex)""></a></h3><details><summary>Click to expand/collapse</summary><p>Supported placeholders list</p><div class="language-json vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">{</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "content"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#NEZHA#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "ServerName"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.NAME#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "ServerIP"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.IP#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "ServerIPV4"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.IPV4#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "ServerIPV6"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.IPV6#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "CPU"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.CPU#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "MEM"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.MEM#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "SWAP"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.SWAP#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "DISK"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.DISK#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "NetInSpeed"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.NETINSPEED#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "NetOutSpeed"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.NETOUTSPEED#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "TransferIn"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.TRANSFERIN#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "TranferOut"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.TRANSFEROUT#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "Load1"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.LOAD1#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "Load5"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.LOAD5#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "Load15"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.LOAD15#"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "TCP_CONN_COUNT"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.TCPCONNCOUNT"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#B31D28;--shiki-dark:#FDAEB7;--shiki-light-font-style:italic;--shiki-dark-font-style:italic;">#</span><span style="--shiki-light:#B31D28;--shiki-dark:#FDAEB7;--shiki-light-font-style:italic;--shiki-dark-font-style:italic;"> invalid</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "UDP_CONN_COUNT"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"#SERVER.UDPCONNCOUNT"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#B31D28;--shiki-dark:#FDAEB7;--shiki-light-font-style:italic;--shiki-dark-font-style:italic;">#</span><span style="--shiki-light:#B31D28;--shiki-dark:#FDAEB7;--shiki-light-font-style:italic;--shiki-dark-font-style:italic;"> invalid</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><blockquote><p>This document is <strong>NOT</strong> available in English.</p><p><a href="https://developer.work.weixin.qq.com/document/path/91770#markdown%E7%B1%BB%E5%9E%8B" target="_blank" rel="noreferrer">Group Bot Configuration Instructions - Document - WeChat Work Developer Center</a></p></blockquote><ul><li>Name: WeChat Work Group Bot</li><li>URL: <a href="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_BOT_KEY" target="_blank" rel="noreferrer">https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_BOT_KEY</a></li><li>Request Method: POST</li><li>Request Type: JSON</li><li>Body:<div class="language-json vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">{</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "msgtype"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"markdown"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "markdown"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: {</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "content"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"# Nezha Notification</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\n\\n\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#NEZHA#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> Name: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.NAME#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> IP: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.IP#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> IPv4: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.IPV4#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">IPv6: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.IPV6#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> CPU: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.CPU#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> Memory: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.MEM#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> Swap: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.SWAP#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> Disk: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.DISK#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> Upload Speed: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.NETINSPEED#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> Download Speed: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.NETOUTSPEED#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> Total Upload: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.TRANSFERIN#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> Total Download: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.TRANSFEROUT#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> Load1: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.LOAD1#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> Load5: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.LOAD5#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> Load15: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.LOAD15#</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> TCP Connection Count: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.TCPCONNCOUNT</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">> UDP Connection Count: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">#SERVER.UDPCONNCOUNT</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">\\"\\n\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div></li></ul><p>You can remove or add relevant information as needed.</p></details><h2 id="notification-rule-explanation" tabindex="-1">Notification Rule Explanation <a class="header-anchor" href="#notification-rule-explanation" aria-label="Permalink to "Notification Rule Explanation""></a></h2><h3 id="basic-rules" tabindex="-1">Basic Rules <a class="header-anchor" href="#basic-rules" aria-label="Permalink to "Basic Rules""></a></h3><ul><li><code>type</code>: You can choose one or more types. If multiple types are selected in one rule, <strong>all selected types must be satisfied</strong> to trigger a notification (refer to the examples below) <ul><li><code>cpu</code>, <code>gpu</code>, <code>memory</code>, <code>swap</code>, <code>disk</code></li><li><code>net_in_speed</code> inbound network speed, <code>net_out_speed</code> outbound network speed, <code>net_all_speed</code> total network speed, <code>transfer_in</code> inbound traffic, <code>transfer_out</code> outbound traffic, <code>transfer_all</code> total traffic</li><li><code>offline</code> offline monitoring</li><li><code>load1</code>, <code>load5</code>, <code>load15</code> load</li><li><code>process_count</code> process count (currently resource-intensive due to thread count, not supported temporarily)</li><li><code>tcp_conn_count</code>, <code>udp_conn_count</code> connection count</li><li><code>temperature_max</code> maximum temperature</li></ul></li><li><code>duration</code>: Duration in seconds. An notification is triggered if 30% or more of the samples exceed the threshold within this duration (to prevent data spikes).</li><li><code>min</code> or <code>max</code>: <ul><li>For traffic and network speed, the unit is bytes (1KB = 1024B, 1MB = 1024 * 1024B)</li><li>For memory, disk, and CPU, the unit is percentage</li><li>No need to set this for offline monitoring</li></ul></li><li><code>cover</code>: <ul><li><code>0</code> monitors all servers, use <code>ignore</code> to exclude specific servers</li><li><code>1</code> ignores all servers, use <code>ignore</code> to monitor specific servers<br> Example: <code>[{"type":"offline","duration":10, "cover":0, "ignore":{"5": true}}]</code></li></ul></li><li><code>ignore</code>: Select specific servers to exclude, used with <code>cover</code>, content is server ID and boolean value, e.g., <code>{"1": true, "2": false}</code></li></ul><p><strong>Complete Examples:</strong></p><p>Add an offline notification:</p><ul><li>Name: Offline Notification</li><li>Rule: <code>[{"Type":"offline","Duration":10}]</code></li><li>Enabled: √</li></ul><p>Add an notification for CPU usage exceeding 50% for 10 seconds <strong>and</strong> memory usage below 20% for 20 seconds:</p><ul><li>Name: CPU+Memory</li><li>Rule: <code>[{"Type":"cpu","Min":0,"Max":50,"Duration":10},{"Type":"memory","Min":20,"Max":0,"Duration":20}]</code></li><li>Enabled: √</li></ul><p>Send notifications for specific servers to specific notification groups:</p><p>Scenario example:<br> There are 4 servers (1, 2, 3, 4) and two notification groups (A, B).<br> Notify group A if servers 1 and 2 are offline for 10 minutes.<br> Notify group B if servers 3 and 4 are offline for 10 minutes.</p><p>First, set up notification groups A and B, then add two notification rules:</p><p><strong>Rule 1:</strong></p><ul><li>Name: 1, 2 Offline, Send to Notification Group A</li><li>Rule: <code>[{"type":"offline","duration":600,"cover":1,"ignore":{"1":true,"2":true}}]</code></li><li>Notification Group: A</li><li>Enabled: √</li></ul><p><strong>Rule 2:</strong></p><ul><li>Name: 3, 4 Offline, Send to Notification Group B</li><li>Rule: <code>[{"type":"offline","duration":600,"cover":1,"ignore":{"3":true,"4":true}}]</code></li><li>Notification Group: B</li><li>Enabled: √</li></ul><p><strong>Flexibly using parameters can make your notification function fully utilized</strong></p><h3 id="special-any-cycle-traffic-notification" tabindex="-1">Special: Any Cycle Traffic notification <a class="header-anchor" href="#special-any-cycle-traffic-notification" aria-label="Permalink to "Special: Any Cycle Traffic notification""></a></h3><p>Can be used for monthly traffic monitoring</p><ul><li><code>type</code>: <ul><li><code>transfer_in_cycle</code> inbound traffic during the cycle</li><li><code>transfer_out_cycle</code> outbound traffic during the cycle</li><li><code>transfer_all_cycle</code> total traffic during the cycle</li></ul></li><li><code>cycle_start</code>: 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 <code>2022-01-11T08:00:00.00+08:00</code></li><li><code>cycle_interval</code>: 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)</li><li><code>cycle_unit</code>: Statistical cycle unit, default is <code>hour</code>, optional (<code>hour</code>, <code>day</code>, <code>week</code>, <code>month</code>, <code>year</code>)</li><li><code>min/max</code>, <code>cover</code>, <code>ignore</code> refer to basic rule configuration</li></ul><p>Example:</p><p>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:</p><div class="language-json vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[{</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"type"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"transfer_out_cycle"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"max"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1099511627776</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"cycle_start"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"2022-01-01T00:00:00+08:00"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"cycle_interval"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"cycle_unit"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"month"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"cover"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"ignore"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:{</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"3"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">"4"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}}]</span></span></code></pre></div><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>If you still have trouble editing rules, you can try the rule generators below to simplify the process. Note that Nezha Monitoring does not guarantee the functionality of these generated rules.</p><ul><li><a href="https://nz.sina.us.kg/" target="_blank" rel="noreferrer">Nezha Rule Generator</a>: for common cases</li><li><a href="https://wiziscool.github.io/Nezha-Traffic-Alarm-Generator/" target="_blank" rel="noreferrer">Nezha-Traffic-Alarm-Generator</a>: for editing cycle traffic rules only and may be more convenient to use. Chinese only.</li></ul></div><h2 id="notification-trigger-modes" tabindex="-1">Notification Trigger Modes <a class="header-anchor" href="#notification-trigger-modes" aria-label="Permalink to "Notification Trigger Modes""></a></h2><ul><li><strong>Always Trigger</strong>: A notification is triggered every time the Agent reports a status that matches the notification rule.</li><li><strong>Single Trigger</strong>: A notification is triggered only once when the status changes, such as from normal to abnormal or from abnormal to normal.</li></ul><h2 id="set-tasks-to-execute-on-notifications" tabindex="-1">Set Tasks to Execute on notifications <a class="header-anchor" href="#set-tasks-to-execute-on-notifications" aria-label="Permalink to "Set Tasks to Execute on notifications""></a></h2><p>If you need to execute a task while sending an notification message, you can set this item.</p><ul><li><strong>Task on Notification</strong>: 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.</li><li><strong>Task on Recovery</strong>: 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.</li></ul>`,45),o=[n];function l(h,r,p,k,d,u){return t(),s("div",null,o)}const g=i(e,[["render",l]]);export{E as __pageData,g as default};
|