improve(health/notifications/telegram): add option to set API url (#21376)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Ilya Mashchenko committed
Dec 1, 2025 at 21:35 UTC
fc53ff76275b94be76a66fee6a18159c49c9be16
3 files changed
+11
-2
src/health/notifications/alarm-notify.sh.in
+2
-1
@@ -531,6 +531,7 @@ if [[ ! $curl_options =~ .*\--connect-timeout ]]; then
531
fi
532
533
OPSGENIE_API_URL=${OPSGENIE_API_URL:-"https://api.opsgenie.com"}
534
+TELEGRAM_API_URL=${TELEGRAM_API_URL:-"https://api.telegram.org"}
535
536
# If we didn't autodetect the character set for e-mail and it wasn't
537
# set by the user, we need to set it to a reasonable default. UTF-8
@@ -1610,7 +1611,7 @@ send_telegram() {
1611
IFS=":" read -r chatID threadID <<< "${chatid}"
1612
1613
# https://core.telegram.org/bots/api#sendmessage
1613
- api_url="https://api.telegram.org/bot${bottoken}/sendMessage?chat_id=${chatID}"
1614
+ api_url="${TELEGRAM_API_URL}/bot${bottoken}/sendMessage?chat_id=${chatID}"
1615
if [ -n "${threadID}" ]; then
1616
api_url+="&message_thread_id=${threadID}"
1617
fi
src/health/notifications/health_alarm_notify.conf
+5
-1
@@ -419,7 +419,11 @@ DEFAULT_RECIPIENT_KAVENEGAR=""
419
# enable/disable sending telegram messages
420
SEND_TELEGRAM="YES"
421
422
-# Contact the bot @BotFather to create a new bot and receive a bot token.
422
+# API URL for the Telegram Bot API.
423
+# Set this only when using a local Bot API Server.
424
+# Leave it empty when using the official Telegram API.
425
+TELEGRAM_API_URL=""
426
+ # Contact the bot @BotFather to create a new bot and receive a bot token.
427
# Without it, netdata cannot send telegram messages.
428
TELEGRAM_BOT_TOKEN=""
429
src/health/notifications/telegram/metadata.yaml
+4
@@ -34,6 +34,10 @@
34
default_value: 'YES'
35
description: "Set `SEND_TELEGRAM` to YES"
36
required: true
37
+ - name: 'TELEGRAM_API_URL'
38
+ default_value: 'https://api.telegram.org'
39
+ description: "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."
40
+ required: false
41
- name: 'TELEGRAM_BOT_TOKEN'
42
default_value: ''
43
description: "set `TELEGRAM_BOT_TOKEN` to your bot token."