Support templating in webhook url fields#4798
Conversation
Signed-off-by: Walther Lee <walthere.lee@gmail.com>
SoloJacobs
left a comment
There was a problem hiding this comment.
From what I understand:
- We don't expose
MarshallYAML, so the new implementation is backwards compatible. I.e, all old configurations are accepted by the newUnmarshallYAMLimplementation. Here are two configurations, which are only accepted by the new implementation.
- name: 'empty-url'
webhook_configs:
- url: ''
url_file: 'url.txt'
- name: 'not-a-url'
webhook_configs:
- url: 'ssh://ab'For the not-a-url config the new behaviour is rather unfortunate. Did you consider validating URLs, which don't have a template?
- Could we maybe get some tests for the new templating in
notify/webhook/webhook.go? - There are also some other configurations, which could be handled in a similar manor I think:
SlackConfigMSTeamsConfigMSTeamsV2ConfigMattermostConfigDiscordConfig
I guess that is out-off-scope for this PR, though.
|
Sure, I can add the change for those too and some tests. Thanks Solomon |
Signed-off-by: Walther Lee <walthere.lee@gmail.com>
Signed-off-by: Walther Lee <walthere.lee@gmail.com>
|
The change from I added tests for templated urls in webhook but won't change the other URL fields from other configs in this PR to keep it small. I'll send a second one with just the switch to |
Signed-off-by: Walther Lee <walthere.lee@gmail.com>
SoloJacobs
left a comment
There was a problem hiding this comment.
Alright, very extensive tests, nice 👍 I also like the new SecretTemplURL, LGTM.
Signed-off-by: Walther Lee <walthere.lee@gmail.com>
* [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>
It's an old thread, but there's been some discussion here about supporting templating in webhook url fields: #684
The issue was closed in 2017 because the alertmanager didn't support templating for any http/url fields, but there're some examples where it does support it now, for example SlackAction.URL and PushoverConfig.URL, so I think we can re-evaluate adding support for this.
There's some good use cases described by others in the thread since it was closed.
This change adds templating to the fields. Existing tests already check that secret URL is still not exposed.