Skip to content

Conversation

@guoard
Copy link
Contributor

@guoard guoard commented Dec 21, 2025

This PR adds global configuration support for Telegram bot tokens in Alertmanager. Until now, telegram_bot_token and telegram_bot_token_file could only be set per receiver, which could lead to redundant configuration when multiple receivers used the same bot.

@guoard guoard force-pushed the global_telegram_bot_token branch 2 times, most recently from 23c962d to 2028abb Compare December 21, 2025 10:15
@guoard guoard force-pushed the global_telegram_bot_token branch from d035f2f to ca180e4 Compare January 8, 2026 16:14
Copy link
Contributor

@SoloJacobs SoloJacobs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall a nice PR, thank you 👍 I do have some small things I would do differently:

  1. Most configurations can be minimized to only have the fields, which are relevant to the test, e.g.,
config/testdata/conf.telegram-no-bot-token.yml
route:
  receiver: team-X-telegram

receivers:
  - name: team-X-telegram
    telegram_configs:
      - chat_id: 123
  1. I am also unsure about the error message, in case the token is missing:
FAILED: no global Telegram BotToken set either inline or in a file

Before it was this:

FAILED: missing bot_token or bot_token_file on telegram_config

I do admit that the victorops integration has the same issue.

  1. I would like to see tested is this case:
global:
  telegram_bot_token_file: '/global_file'
  telegram_bot_token: 'abc123'
route:
  receiver: team-X-telegram
receivers:
  - name: 'team-X-telegram'
    telegram_configs:
      - chat_id: 456
        bot_token_file: /override_file

Here all receivers are valid, and in theory alertmanager could ignore the error. We don't and that is a good thing, but still a good thing to document.

@guoard guoard force-pushed the global_telegram_bot_token branch 2 times, most recently from 2f32700 to c145dfb Compare January 25, 2026 11:08
@guoard
Copy link
Contributor Author

guoard commented Jan 25, 2026

@SoloJacobs Thank you for your time and review.

Done.

@guoard guoard requested a review from SoloJacobs January 25, 2026 12:24
Copy link
Contributor

@SoloJacobs SoloJacobs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! We have to wait for the maintainers to approval, but I see no blockers.

}
if telegram.BotToken == "" && len(telegram.BotTokenFile) == 0 {
if c.Global.TelegramBotToken == "" && len(c.Global.TelegramBotTokenFile) == 0 {
return errors.New("missing bot_token or bot_token_file on telegram_config")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Others mostly us a message like "no global Telegram token set either inline or in a file" , there are already other variations like: "no msteams webhook URL or URLFile provided"

We should come up with a unified wording for these errors, maybe also including the receiver name.

@SoloJacobs
Copy link
Contributor

@guoard There are some merge conflicts. Could you resolve them? I can also do, but would have to pick your commits to a branch of my own.

Signed-off-by: Ali Afsharzadeh <afsharzadeh8@gmail.com>
Signed-off-by: Ali Afsharzadeh <afsharzadeh8@gmail.com>
Signed-off-by: Ali Afsharzadeh <afsharzadeh8@gmail.com>
Signed-off-by: Ali Afsharzadeh <afsharzadeh8@gmail.com>
Signed-off-by: Ali Afsharzadeh <afsharzadeh8@gmail.com>
@guoard guoard force-pushed the global_telegram_bot_token branch from 7039092 to 0ac3dfb Compare January 30, 2026 14:52
@guoard
Copy link
Contributor Author

guoard commented Jan 30, 2026

@guoard There are some merge conflicts. Could you resolve them? I can also do, but would have to pick your commits to a branch of my own.

Done.

@SuperQ SuperQ merged commit 4e48a1c into prometheus:main Jan 30, 2026
7 checks passed
@guoard guoard deleted the global_telegram_bot_token branch January 30, 2026 15:38
SuperQ added a commit that referenced this pull request Feb 2, 2026
* [ENHANCEMENT] docs(opsgenie): Fix description of `api_url` field. #4908
* [ENHANCEMENT] docs(slack): Document missing app configs. #4871
* [ENHANCEMENT] docs: Fix `max-silence-size-bytes`. #4805
* [ENHANCEMENT] docs: Update expr for `AlertmanagerClusterFailedToSendAlerts` to exclude value 0. #4872
* [ENHANCEMENT] docs: Use matchers for inhibit rules examples. #4131
* [ENHANCEMENT] docs: add notification integrations. #4901
* [ENHANCEMENT] docs: update `slack_config` attachments documentation links. #4802
* [ENHANCEMENT] docs: update description of filter query params in openapi doc. #4810
* [ENHANCEMENT] provider: Reduce lock contention. #4809
* [FEATURE] slack: Add support for top-level text field in slack notification. #4867
* [FEATURE] smtp: Add support for authsecret from file. #3087
* [FEATURE] smtp: Customize the ssl/tls port support (#4757). #4818
* [FEATURE] smtp: Enhance email notifier configuration validation. #4826
* [FEATURE] telegram: Add `chat_id_file` configuration parameter. #4909
* [FEATURE] telegram: Support global bot token. #4823
* [FEATURE] webhook: Support templating in url fields. #4798
* [FEATURE] wechat: Add config directive to pass api secret via file. #4734
* [FEATURE] provider: Implement per alert limits. #4819
* [BUGFIX] Allow empty `group_by` to override parent route. #4825
* [BUGFIX] Set `spellcheck=false` attribute on silence filter input. #4811
* [BUGFIX] jira: Fix for handling api v3 with ADF. #4756
* [BUGFIX] jira: Prevent hostname corruption in cloud api url replacement. #4892
---------

Signed-off-by: Solomon Jacobs <solomonjacobs@protonmail.com>
Signed-off-by: Ben Kochie <superq@gmail.com>
Co-authored-by: Ben Kochie <superq@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants