master
md 126 lines 4.16 KB
Rendered Raw
1 <!--startmeta
2 custom_edit_url: "https://github.com/netdata/netdata/edit/master/src/health/notifications/telegram/README.md"
3 meta_yaml: "https://github.com/netdata/netdata/edit/master/src/health/notifications/telegram/metadata.yaml"
4 sidebar_label: "Telegram"
5 learn_status: "Published"
6 learn_rel_path: "Alerts & Notifications/Notifications/Agent Dispatched Notifications"
7 keywords: ['Telegram']
8 message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE NOTIFICATION'S metadata.yaml FILE"
9 endmeta-->
10
11 # Telegram
12
13
14 <img src="https://netdata.cloud/img/telegram.svg" width="150"/>
15
16
17 Send notifications to Telegram using Netdata's Agent alert notification feature, which supports dozens of endpoints, user roles, and more.
18
19
20 <img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" />
21
22 ## Setup
23
24
25 ### Prerequisites
26
27 ####
28
29 - A bot token. To get one, contact the [@BotFather](https://t.me/BotFather) bot and send the command `/newbot` and follow the instructions. Invite your bot to a group where you want it to send messages.
30 - The chat ID for every chat you want to send messages to. Invite [@myidbot](https://t.me/myidbot) bot to the group that will receive notifications, and write the command `/getgroupid@myidbot` to get the group chat ID. Group IDs start with a hyphen, supergroup IDs start with `-100`.
31 - Terminal access to the Agent you wish to configure.
32
33
34
35 ### Configuration
36
37 #### Options
38
39 The following options can be defined for this notification
40
41 <details open><summary>Config Options</summary>
42
43
44
45 | Option | Description | Default | Required |
46 |:-----|:------------|:--------|:---------:|
47 | SEND_TELEGRAM | Set `SEND_TELEGRAM` to YES | YES | yes |
48 | TELEGRAM_API_URL | Set `TELEGRAM_API_URL` to the corresponding URL if you have your own Telegram Bot API server (e.g., for privacy or local hosting). Defaults to the official Telegram API. | https://api.telegram.org | no |
49 | TELEGRAM_BOT_TOKEN | set `TELEGRAM_BOT_TOKEN` to your bot token. | | yes |
50 | [DEFAULT_RECIPIENT_TELEGRAM](#option-default-recipient-telegram) | Set the `DEFAULT_RECIPIENT_TELEGRAM` variable in your config file to your Telegram chat ID (find it with @myidbot). Separate multiple chat IDs with spaces. To send alerts to a specific topic within a chat, use `chatID:topicID`. | | yes |
51
52 <a id="option-default-recipient-telegram"></a>
53 ##### DEFAULT_RECIPIENT_TELEGRAM
54
55 All roles will default to this variable if left unconfigured.
56
57 The `DEFAULT_RECIPIENT_CUSTOM` can be edited in the following entries at the bottom of the same file:
58
59 ```text
60 role_recipients_telegram[sysadmin]="-49999333324"
61 role_recipients_telegram[domainadmin]="-49999333389"
62 role_recipients_telegram[dba]="-10099992222"
63 role_recipients_telegram[webmaster]="-10099992222 -49999333389"
64 role_recipients_telegram[proxyadmin]="-49999333344"
65 role_recipients_telegram[sitemgr]="-49999333876"
66 ```
67
68
69
70 </details>
71
72
73
74 #### via File
75
76 The configuration file name for this integration is `health_alarm_notify.conf`.
77
78
79 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
80 Netdata [config directory](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration/README.md#locate-your-config-directory).
81
82 ```bash
83 cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata
84 sudo ./edit-config health_alarm_notify.conf
85 ```
86
87 ##### Examples
88
89 ###### Basic Configuration
90
91
92
93 ```yaml
94 #------------------------------------------------------------------------------
95 # telegram (telegram.org) global notification options
96
97 SEND_TELEGRAM="YES"
98 TELEGRAM_BOT_TOKEN="111122223:7OpFlFFRzRBbrUUmIjj5HF9Ox2pYJZy5"
99 DEFAULT_RECIPIENT_TELEGRAM="-49999333876"
100
101 ```
102
103
104 ## Troubleshooting
105
106 ### Test Notification
107
108 You can run the following command by hand, to test alerts configuration:
109
110 ```bash
111 # become user netdata
112 sudo su -s /bin/bash netdata
113
114 # enable debugging info on the console
115 export NETDATA_ALARM_NOTIFY_DEBUG=1
116
117 # send test alarms to sysadmin
118 /usr/libexec/netdata/plugins.d/alarm-notify.sh test
119
120 # send test alarms to any role
121 /usr/libexec/netdata/plugins.d/alarm-notify.sh test "ROLE"
122 ```
123
124 Note that this will test _all_ alert mechanisms for the selected role.
125
126