import{_ as i,c as n,o as a,a as o,b as e,d as t}from"./app.31af427a.js";const y='{"title":"Flexible notification methods","description":"","frontmatter":{},"headers":[{"level":2,"title":"Flexible notification methods","slug":"flexible-notification-methods"},{"level":2,"title":"Description of notification rules","slug":"description-of-notification-rules"},{"level":3,"title":"Basic Rules","slug":"basic-rules"},{"level":3,"title":"Special: Any-cycle transfer notification","slug":"special-any-cycle-transfer-notification"},{"level":2,"title":"Description of mode of triggering notification","slug":"description-of-mode-of-triggering-notification"},{"level":2,"title":"Set the task to be executed when notification","slug":"set-the-task-to-be-executed-when-notification"}],"relativePath":"en_US/guide/notifications.md","lastUpdated":1666600441000}',l={},r=o('

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.


Flexible notification methods

#NEZHA# is the panel message placeholder, the panel will automatically replace the placeholder with the actual message when it triggers the notification

The content of Body is in JSON format\uFF1AWhen the request type is FORM\uFF0Cthe value is in the form of key:value\uFF0Cvalue 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.

Placeholders can also be placed inside the URL, and it will perform a simple string substitution when requested.

Refer to the example below, it is very flexible.

',6),c=e("ul",null,[e("li",null,[e("p",null,"Bark Example -Name: Bark -URL composition: 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"),e("p",null,"-Name: Bark -URL composition:/push -Request method: post -Request type: form"),e("ul",null,[e("li",{"title:#SERVER.NAME#,device_key:xxxxxxxxx,body:#NEZHA#,icon:https:xxxxxxxxnz.png":""},"Body:")])]),e("li",null,[e("p",null,[t("Telegram Example, contributed by "),e("a",{href:"https://github.com/haitau",target:"_blank",rel:"noopener noreferrer"},"@haitau")]),e("ul",null,[e("li",null,"Name\uFF1ATelegram Robot message notification"),e("li",null,[t("URL\uFF1A"),e("a",{href:"https://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&text=#NEZHA#",target:"_blank",rel:"noopener noreferrer"},"https://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&text=#NEZHA#")]),e("li",null,"Request method: GET"),e("li",null,"Request type: default"),e("li",null,"Body: null"),e("li",null,[t("Notes for this method\uFF1AThe 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 "),e("em",null,"Use this token to access the HTTP API"),t("). 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.")])])]),e("li",null,[e("p",null,[t("Email notification example - Outlook, contributed by "),e("a",{href:"https://github.com/MIKU-N",target:"_blank",rel:"noopener noreferrer"},"@MIKU_N ")]),e("ul",null,[e("li",null,"Name: MS Mail Notification"),e("li",null,[t("URL\uFF1A"),e("a",{href:"https://graph.microsoft.com/v1.0/me/microsoft.graph.sendMail",target:"_blank",rel:"noopener noreferrer"},"https://graph.microsoft.com/v1.0/me/microsoft.graph.sendMail")]),e("li",null,"Request method: POST"),e("li",null,"Request type: JSON"),e("li",null,[t("Header: "),e("code",null,'{"Content-type":"application/json", "Authorization":"Bearer {Token}"}')]),e("li",null,"Body:")])])],-1),s=o(`
{
  "message": {
      "subject": "Server Status Notification",
      "body": {
          "contentType": "Text",
          "content": "#NEZHA#"
      },
      "toRecipients": [
          {
              "emailAddress": {
                  "address": "ADDRESS FOR RECEVING EMAILS"
              }
          }
      ]
  }
}


Description of notification rules

Basic Rules

Complete examples:

Add an offline notification

Add an notification when the CPU exceeds 50% for 10s but the memory usage is below 20% for 20s

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:

Rule II:

Using these rules flexibly will help you to make full use of the notification function


Special: Any-cycle transfer notification

Can be used as monthly transfer notificatin

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}}]

Description of mode of triggering 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

`,22),u=[r,c,s];function d(h,f,p,q,m,g){return a(),n("div",null,u)}var _=i(l,[["render",d]]);export{y as __pageData,_ as default};