nezhahq.github.io/en_US/guide/notifications.html

22 lines
20 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Flexible notification methods | Nezha Monitoring</title>
<meta name="description" content="Nezha Monitoring is a lightweight O&M tool">
<link rel="stylesheet" href="/assets/style.0b9f658b.css">
<link rel="modulepreload" href="/assets/chunks/AlgoliaSearchBox.6e4b23ab.js">
<link rel="modulepreload" href="/assets/app.457c27ae.js">
<link rel="modulepreload" href="/assets/en_US_guide_notifications.md.135dd487.lean.js">
<meta name="twitter:title" content="Flexible notification methods | Nezha Monitoring">
<meta property="og:title" content="Flexible notification methods | Nezha Monitoring">
</head>
<body>
<div id="app"><!--[--><div class="theme"><header class="nav-bar" data-v-675d8756><div class="sidebar-button" data-v-675d8756><svg class="icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z" class></path></svg></div><a class="nav-bar-title" href="/en_US/" aria-label="Nezha Monitoring, back to home" data-v-675d8756 data-v-cc01ef16><!----> Nezha Monitoring</a><div class="flex-grow" data-v-675d8756></div><div class="nav" data-v-675d8756><nav class="nav-links" data-v-675d8756 data-v-eab3edfe><!--[--><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item active" href="/en_US/" data-v-b8818f8c>User Guide <!----></a></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item" href="/en_US/case/index" data-v-b8818f8c>Community Projects <!----></a></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item" href="/en_US/developer/index" data-v-b8818f8c>Development Manual <!----></a></div></div><!--]--><div class="item" data-v-eab3edfe><div class="nav-dropdown-link" data-v-eab3edfe data-v-56bf3a3f><button class="button" data-v-56bf3a3f><span class="button-text" data-v-56bf3a3f>Languages</span><span class="right button-arrow" data-v-56bf3a3f></span></button><ul class="dialog" data-v-56bf3a3f><!--[--><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item" href="/guide/notifications.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>简体中文</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item active" href="/en_US/guide/notifications.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>English</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><!--]--></ul></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item isExternal" href="https://github.com/nezhahq/nezhahq.github.io" target="_blank" rel="noopener noreferrer" data-v-b8818f8c>GitHub <svg class="icon outbound" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15" data-v-b8818f8c><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div></div></nav></div><!--[--><!--[--><div class="algolia-search-box" id="docsearch"></div><!--]--><!--]--></header><aside class="sidebar" data-v-83e92a68><nav class="nav-links nav" data-v-83e92a68 data-v-eab3edfe><!--[--><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item active" href="/en_US/" data-v-b8818f8c>User Guide <!----></a></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item" href="/en_US/case/index" data-v-b8818f8c>Community Projects <!----></a></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item" href="/en_US/developer/index" data-v-b8818f8c>Development Manual <!----></a></div></div><!--]--><div class="item" data-v-eab3edfe><div class="nav-dropdown-link" data-v-eab3edfe data-v-56bf3a3f><button class="button" data-v-56bf3a3f><span class="button-text" data-v-56bf3a3f>Languages</span><span class="right button-arrow" data-v-56bf3a3f></span></button><ul class="dialog" data-v-56bf3a3f><!--[--><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item" href="/guide/notifications.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>简体中文</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item active" href="/en_US/guide/notifications.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>English</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><!--]--></ul></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item isExternal" href="https://github.com/nezhahq/nezhahq.github.io" target="_blank" rel="noopener noreferrer" data-v-b8818f8c>GitHub <svg class="icon outbound" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15" data-v-b8818f8c><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div></div></nav><!--[--><!--]--><ul class="sidebar-links" data-v-83e92a68><!--[--><li class="sidebar-link"><p class="sidebar-link-item">Installation Manual</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/dashboard">Install Dashboard</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/agent">Install Agent</a><!----></li></ul></li><li class="sidebar-link"><p class="sidebar-link-item">Admin Panel</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/servers">Servers</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/services">Services</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/tasks">Tasks</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item active" href="/en_US/guide/notifications">Notifications</a><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="#flexible-notification-methods">Flexible notification methods</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="#description-of-notification-rules">Description of notification rules</a><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="#basic-rules">Basic Rules</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="#special-any-cycle-transfer-notification">Special: Any-cycle transfer notification</a><!----></li></ul></li></ul></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/settings">Settings</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/api">API</a><!----></li></ul></li><li class="sidebar-link"><p class="sidebar-link-item">FAQ</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q2">Let the Agent start/on-line, and the self-test process of the problem</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q3">Reverse Proxy gRPC Port (support Cloudflare CDN)</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q4">Real-time channel disconnection/online terminal connection failure</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q5">How do I migrate my data to the new server and restore my backups?</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q6">How to set up a monthly reset of data statistics?</a><!----></li></ul></li><li class="sidebar-link"><p class="sidebar-link-item">Troubleshooting Guide</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/dashboardq">Dashboard</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/agentq">Agent</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/loginq">Login</a><!----></li></ul></li><!--]--></ul><!--[--><!--]--></aside><div class="sidebar-mask"></div><main class="page" data-v-7eddb2c4><div class="container" data-v-7eddb2c4><!--[--><!--]--><div style="position:relative;" class="content" data-v-7eddb2c4><div><p>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><br></p><h2 id="flexible-notification-methods" tabindex="-1">Flexible notification methods <a class="header-anchor" href="#flexible-notification-methods" aria-hidden="true">#</a></h2><p><code>#NEZHA#</code> is the panel message placeholder, the panel will automatically replace the placeholder with the actual message when it triggers the notification</p><p>The content of Body is in <code>JSON</code> format<strong>When the request type is FORM</strong>the value is in the form of <code>key:value</code><code>value</code> can contain placeholders that will be automatically replaced when notified. <strong>When the request type is JSON</strong> It will only do string substitution and submit to the <code>URL</code> directly.</p><p>Placeholders can also be placed inside the URL, and it will perform a simple string substitution when requested.</p><p>Refer to the example below, it is very flexible.</p><ul><li><p>Telegram Example, contributed by <a href="https://github.com/haitau" target="_blank" rel="noopener noreferrer">@haitau</a></p><ul><li>NameTelegram Robot message notification</li><li>URL<a href="https://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&amp;text=#NEZHA#" target="_blank" rel="noopener noreferrer">https://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&amp;text=#NEZHA#</a></li><li>Request method: GET</li><li>Request type: default</li><li>Body: null</li><li>URL Parameter acquisition instructionsThe 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 <em>Use this token to access the HTTP API</em>). The &#39;bot&#39; 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&#39;s ID, you can get it by talking to the bot @userinfobot.</li></ul></li></ul><br><br><h2 id="description-of-notification-rules" tabindex="-1">Description of notification rules <a class="header-anchor" href="#description-of-notification-rules" aria-hidden="true">#</a></h2><h3 id="basic-rules" tabindex="-1">Basic Rules <a class="header-anchor" href="#basic-rules" aria-hidden="true">#</a></h3><ul><li>Type: one or more types can be selected, such as in a rule to select more than one type, you need to <strong>meet all the selected types at the same time</strong> to trigger the notification (see the example later) <ul><li><code>cpu</code><code>memory</code><code>swap</code><code>disk</code></li><li><code>net_in_speed</code> Inbound speed, <code>net_out_speed</code> Outbound speed, <code>net_all_speed</code> Inbound + Outbound speed, <code>transfer_in</code> Inbound Transfer, <code>transfer_out</code> Outbound Transfer, <code>transfer_all</code> Total Transfer</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> Number of processes <em>Currently, counting the number of processes takes up too many resources and is not supported at the moment</em></li><li><code>tcp_conn_count</code><code>udp_conn_count</code> Number of connections</li></ul></li><li>durationLasting for a few seconds, the notification will only be triggered when the sampling record reaches 30% or more within a few seconds</li><li>min/max <ul><li>Transfer, network speed, and other values of the same type. Unit is byte (1KB=1024B1MB = 1024*1024B)</li><li>Memory, hard disk, CPU. units are usage percentages</li><li>No setup required for offline monitoring</li></ul></li><li>cover <code>[{&quot;type&quot;:&quot;offline&quot;,&quot;duration&quot;:10, &quot;cover&quot;:0, &quot;ignore&quot;:{&quot;5&quot;: true}}]</code><ul><li><code>0</code> Cover all, use <code>ignore</code> to ignore specific servers</li><li><code>1</code> Ignore all, use <code>ignore</code> to monitoring specific servers<br> For example: <code>[{&quot;type&quot;:&quot;offline&quot;,&quot;duration&quot;:10, &quot;cover&quot;:0, &quot;ignore&quot;:{&quot;5&quot;: true}}]</code></li></ul></li><li>ignore: Select to ignore specific servers, use with <code>cover</code> with server id and boolean, e.g.: <code>{&quot;1&quot;: true, &quot;2&quot;:false}</code></li></ul><p><strong>Complete examples:</strong></p><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>Add an offline notification</p><ul><li>Name: Offline notification</li><li>Rules: <code>[{&quot;Type&quot;:&quot;offline&quot;,&quot;Duration&quot;:10}]</code></li><li>Enable: √</li></ul></div><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>Add an notification when the CPU exceeds 50% for 10s <strong>but</strong> the memory usage is below 20% for 20s</p><ul><li>Name CPU and RAM</li><li>Rules: <code>[{&quot;Type&quot;:&quot;cpu&quot;,&quot;Min&quot;:0,&quot;Max&quot;:50,&quot;Duration&quot;:10},{&quot;Type&quot;:&quot;memory&quot;,&quot;Min&quot;:20,&quot;Max&quot;:0,&quot;Duration&quot;:20}]</code></li><li>Enable: √</li></ul></div><br><h3 id="special-any-cycle-transfer-notification" tabindex="-1">Special: Any-cycle transfer notification <a class="header-anchor" href="#special-any-cycle-transfer-notification" aria-hidden="true">#</a></h3><p>Can be used as monthly transfer notificatin</p><ul><li><p>type</p><ul><li><code>transfer_in_cycle</code> Inbound transfer during the cycle</li><li><code>transfer_out_cycle</code> Outbound transfer during the cycle</li><li><code>transfer_all_cycle</code> The sum of inbound and outbound transfer during the cycle</li></ul></li><li><p><code>cycle_start</code> Start date of the statistical cycle (can be the start date of your server&#39;s billing cycle), the time format is RFC3339, for example, the format in Beijing time zone is <code>2022-01-11T08:00:00.00+08:00</code></p></li><li><p><code>cycle_interval</code> 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)</p></li><li><p><code>cycle_unit</code> Statistics cycle unit, default <code>hour</code>, optional (<code>hour</code>, <code>day</code>, <code>week</code>, <code>month</code>, <code>year</code>)</p></li><li><p><code>min/max</code>, <code>cover</code>, <code>ignore</code> Please refer to the basic rules to configure</p></li></ul><p>Example: The servers with ID 3 and 4 (defined in the <code>ignore</code>) are counted on the 1st of each month, and a notification is triggered when the monthly outbound transfer reaches 1TB during the cycle. <code>[{&quot;type&quot;:&quot;transfer_out_cycle&quot;,&quot;max&quot;:1099511627776,&quot;cycle_start&quot;:&quot;2022-01-01T00:00:00+08:00&quot;,&quot;cycle_interval&quot;:1,&quot;cycle_unit&quot;:&quot;month&quot;,&quot;cover&quot;:1,&quot;ignore&quot;:{&quot;3&quot;:true,&quot;4&quot;:true}}]</code><img src="https://s4.ax1x.com/2022/01/13/7QKaUx.md.png" alt=""></p></div></div><footer class="page-footer" data-v-7eddb2c4 data-v-07c132fc><div class="edit" data-v-07c132fc><div class="edit-link" data-v-07c132fc data-v-1ed99556><a class="link" href="https://github.com/nezhahq/nezhahq.github.io/edit/main/docs/en_US/guide/notifications.md" target="_blank" rel="noopener noreferrer" data-v-1ed99556>Edit this page on GitHub <svg class="icon outbound icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15" data-v-1ed99556><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div></div><div class="updated" data-v-07c132fc><p class="last-updated" data-v-07c132fc data-v-abce3432><span class="prefix" data-v-abce3432>Last Updated:</span><span class="datetime" data-v-abce3432></span></p></div></footer><div class="next-and-prev-link" data-v-7eddb2c4 data-v-38ede35f><div class="container" data-v-38ede35f><div class="prev" data-v-38ede35f><a class="link" href="/en_US/guide/tasks" data-v-38ede35f><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon icon-prev" data-v-38ede35f><path d="M19,11H7.4l5.3-5.3c0.4-0.4,0.4-1,0-1.4s-1-0.4-1.4,0l-7,7c-0.1,0.1-0.2,0.2-0.2,0.3c-0.1,0.2-0.1,0.5,0,0.8c0.1,0.1,0.1,0.2,0.2,0.3l7,7c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3c0.4-0.4,0.4-1,0-1.4L7.4,13H19c0.6,0,1-0.4,1-1S19.6,11,19,11z"></path></svg><span class="text" data-v-38ede35f>Tasks</span></a></div><div class="next" data-v-38ede35f><a class="link" href="/en_US/guide/settings" data-v-38ede35f><span class="text" data-v-38ede35f>Settings</span><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon icon-next" data-v-38ede35f><path d="M19.9,12.4c0.1-0.2,0.1-0.5,0-0.8c-0.1-0.1-0.1-0.2-0.2-0.3l-7-7c-0.4-0.4-1-0.4-1.4,0s-0.4,1,0,1.4l5.3,5.3H5c-0.6,0-1,0.4-1,1s0.4,1,1,1h11.6l-5.3,5.3c-0.4,0.4-0.4,1,0,1.4c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3l7-7C19.8,12.6,19.9,12.5,19.9,12.4z"></path></svg></a></div></div></div><!--[--><!--]--></div></main></div><!----><!--]--></div>
<script>__VP_HASH_MAP__ = JSON.parse("{\"case_case1.md\":\"aae6ce67\",\"case_case2.md\":\"21bc3d83\",\"case_index.md\":\"04195f4a\",\"developer_index.md\":\"11476340\",\"developer_l10n.md\":\"b0849891\",\"developer_theme.md\":\"7cd8ff5c\",\"en_us_case_case1.md\":\"112b48b6\",\"en_us_case_case2.md\":\"d7b9a616\",\"en_us_case_index.md\":\"41ebc23f\",\"en_us_developer_index.md\":\"3825874c\",\"en_us_developer_l10n.md\":\"8afe4c3a\",\"en_us_developer_theme.md\":\"abd732be\",\"en_us_guide_agent.md\":\"85b101e2\",\"en_us_guide_agentq.md\":\"ddff8420\",\"en_us_guide_api.md\":\"7775e30d\",\"en_us_guide_dashboard.md\":\"3fde53b5\",\"en_us_guide_dashboardq.md\":\"bc04f866\",\"en_us_guide_loginq.md\":\"3165c755\",\"en_us_guide_notifications.md\":\"135dd487\",\"en_us_guide_q2.md\":\"0ea280ac\",\"en_us_guide_q3.md\":\"23865207\",\"en_us_guide_q4.md\":\"601451a7\",\"en_us_guide_q5.md\":\"3d4c7115\",\"en_us_guide_q6.md\":\"1f71b9b2\",\"en_us_guide_servers.md\":\"740d0da3\",\"en_us_guide_services.md\":\"c67f0406\",\"en_us_guide_settings.md\":\"1a09e853\",\"en_us_guide_tasks.md\":\"1713f225\",\"en_us_index.md\":\"0159db53\",\"guide_agent.md\":\"0593529f\",\"guide_agentq.md\":\"f8c39e31\",\"guide_api.md\":\"1d9345cd\",\"guide_dashboard.md\":\"0627dae6\",\"guide_dashboardq.md\":\"707e7e2d\",\"guide_loginq.md\":\"c6342366\",\"guide_notifications.md\":\"f006b054\",\"guide_q1.md\":\"30c1b64e\",\"guide_q2.md\":\"3152c173\",\"guide_q3.md\":\"1b71e3fa\",\"guide_q4.md\":\"0b506117\",\"guide_q5.md\":\"c3b7cdb5\",\"guide_q6.md\":\"4d681011\",\"guide_servers.md\":\"410f9c13\",\"guide_services.md\":\"957570cc\",\"guide_settings.md\":\"f50de3a6\",\"guide_tasks.md\":\"9b69c453\",\"index.md\":\"cebe7fc1\"}")</script>
<script type="module" async src="/assets/app.457c27ae.js"></script>
</body>
</html>