master
md 146 lines 5.26 KB
Rendered Raw
1 <!--startmeta
2 custom_edit_url: "https://github.com/netdata/netdata/edit/master/src/health/notifications/ntfy/README.md"
3 meta_yaml: "https://github.com/netdata/netdata/edit/master/src/health/notifications/ntfy/metadata.yaml"
4 sidebar_label: "ntfy"
5 learn_status: "Published"
6 learn_rel_path: "Alerts & Notifications/Notifications/Agent Dispatched Notifications"
7 keywords: ['ntfy']
8 message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE NOTIFICATION'S metadata.yaml FILE"
9 endmeta-->
10
11 # ntfy
12
13
14 <img src="https://netdata.cloud/img/ntfy.svg" width="150"/>
15
16
17 [ntfy](https://ntfy.sh/) (pronounce: notify) is a simple HTTP-based [pub-sub](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern) notification service. It allows you to send notifications to your phone or desktop via scripts from any computer, entirely without signup, cost or setup. It's also [open source](https://github.com/binwiederhier/ntfy) if you want to run your own server.
18 You can send alerts to an ntfy server using Netdata's Agent alert notification feature, which supports dozens of endpoints, user roles, and more.
19
20
21 <img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" />
22
23 ## Setup
24
25
26 ### Prerequisites
27
28 ####
29
30 - (Optional) A [self-hosted ntfy server](https://docs.ntfy.sh/faq/#can-i-self-host-it), in case you don't want to use https://ntfy.sh
31 - A new [topic](https://ntfy.sh/#subscribe) for the notifications to be published to
32 - Access to the terminal where Netdata Agent is running
33
34
35
36 ### Configuration
37
38 #### Options
39
40 The following options can be defined for this notification
41
42 <details open><summary>Config Options</summary>
43
44
45
46 | Option | Description | Default | Required |
47 |:-----|:------------|:--------|:---------:|
48 | SEND_NTFY | Set `SEND_NTFY` to YES | YES | yes |
49 | [DEFAULT_RECIPIENT_NTFY](#option-default-recipient-ntfy) | URL formed by the server-topic combination you want the alert notifications to be sent to. Unless hosting your own server, the server should always be set to https://ntfy.sh. | | yes |
50 | [NTFY_USERNAME](#option-ntfy-username) | The username for netdata to use to authenticate with an ntfy server. | | no |
51 | [NTFY_PASSWORD](#option-ntfy-password) | The password for netdata to use to authenticate with an ntfy server. | | no |
52 | [NTFY_ACCESS_TOKEN](#option-ntfy-access-token) | The access token for netdata to use to authenticate with an ntfy server. | | no |
53
54 <a id="option-default-recipient-ntfy"></a>
55 ##### DEFAULT_RECIPIENT_NTFY
56
57 You can define multiple recipient URLs like this: `https://SERVER1/TOPIC1` `https://SERVER2/TOPIC2`
58
59 All roles will default to this variable if left unconfigured.
60
61 You can then have different servers and/or topics per role, by editing DEFAULT_RECIPIENT_NTFY with the server-topic combination you want, in the following entries at the bottom of the same file:
62 ```text
63 role_recipients_ntfy[sysadmin]="https://SERVER1/TOPIC1"
64 role_recipients_ntfy[domainadmin]="https://SERVER2/TOPIC2"
65 role_recipients_ntfy[dba]="https://SERVER3/TOPIC3"
66 role_recipients_ntfy[webmaster]="https://SERVER4/TOPIC4"
67 role_recipients_ntfy[proxyadmin]="https://SERVER5/TOPIC5"
68 role_recipients_ntfy[sitemgr]="https://SERVER6/TOPIC6"
69 ```
70
71
72 <a id="option-ntfy-username"></a>
73 ##### NTFY_USERNAME
74
75 Only useful on self-hosted ntfy instances. See [users and roles](https://docs.ntfy.sh/config/#users-and-roles) for details.
76 Ensure that your user has proper read/write access to the provided topic in `DEFAULT_RECIPIENT_NTFY`
77
78
79 <a id="option-ntfy-password"></a>
80 ##### NTFY_PASSWORD
81
82 Only useful on self-hosted ntfy instances. See [users and roles](https://docs.ntfy.sh/config/#users-and-roles) for details.
83 Ensure that your user has proper read/write access to the provided topic in `DEFAULT_RECIPIENT_NTFY`
84
85
86 <a id="option-ntfy-access-token"></a>
87 ##### NTFY_ACCESS_TOKEN
88
89 This can be used in place of `NTFY_USERNAME` and `NTFY_PASSWORD` to authenticate with a self-hosted ntfy instance. See [access tokens](https://docs.ntfy.sh/config/?h=access+to#access-tokens) for details.
90 Ensure that the token user has proper read/write access to the provided topic in `DEFAULT_RECIPIENT_NTFY`
91
92
93
94 </details>
95
96
97
98 #### via File
99
100 The configuration file name for this integration is `health_alarm_notify.conf`.
101
102
103 You can edit the configuration file using the [`edit-config`](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration/README.md#edit-configuration-files) script from the
104 Netdata [config directory](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration/README.md#locate-your-config-directory).
105
106 ```bash
107 cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata
108 sudo ./edit-config health_alarm_notify.conf
109 ```
110
111 ##### Examples
112
113 ###### Basic Configuration
114
115
116
117 ```yaml
118 SEND_NTFY="YES"
119 DEFAULT_RECIPIENT_NTFY="https://ntfy.sh/netdata-X7seHg7d3Tw9zGOk https://ntfy.sh/netdata-oIPm4IK1IlUtlA30"
120
121 ```
122
123
124 ## Troubleshooting
125
126 ### Test Notification
127
128 You can run the following command by hand, to test alerts configuration:
129
130 ```bash
131 # become user netdata
132 sudo su -s /bin/bash netdata
133
134 # enable debugging info on the console
135 export NETDATA_ALARM_NOTIFY_DEBUG=1
136
137 # send test alarms to sysadmin
138 /usr/libexec/netdata/plugins.d/alarm-notify.sh test
139
140 # send test alarms to any role
141 /usr/libexec/netdata/plugins.d/alarm-notify.sh test "ROLE"
142 ```
143
144 Note that this will test _all_ alert mechanisms for the selected role.
145
146