Support global Telegram bot token#4823
Conversation
23c962d to
2028abb
Compare
d035f2f to
ca180e4
Compare
SoloJacobs
left a comment
There was a problem hiding this comment.
Overall a nice PR, thank you 👍 I do have some small things I would do differently:
- 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
- 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.
- 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_fileHere 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.
2f32700 to
c145dfb
Compare
|
@SoloJacobs Thank you for your time and review. Done. |
SoloJacobs
left a comment
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
|
@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>
7039092 to
0ac3dfb
Compare
Done. |
* [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>
This PR adds global configuration support for Telegram bot tokens in Alertmanager. Until now,
telegram_bot_tokenandtelegram_bot_token_filecould only be set per receiver, which could lead to redundant configuration when multiple receivers used the same bot.