Skip to content

feat(alertmanager): add apiURLFile to the Slack config of AlertmanagerConfig - #9006

Open
A-RYAN-1 wants to merge 2 commits into
prometheus-operator:mainfrom
A-RYAN-1:feat/slack-apiurlfile
Open

A-RYAN-1 wants to merge 2 commits into
prometheus-operator:mainfrom
A-RYAN-1:feat/slack-apiurlfile

Conversation

@A-RYAN-1

Copy link
Copy Markdown
Contributor

Description

Adds apiURLFile to the Slack receiver of AlertmanagerConfig (v1alpha1 and v1beta1). Until now the webhook URL could only come from a secret key reference, so users who get it from a file on disk, for example a Vault sidecar as described in the issue, could not use AlertmanagerConfig for Slack.

The field follows the existing Telegram botTokenFile and Pushover userKeyFile fields and is passed to the generated configuration as api_url_file. It is mutually exclusive with apiURL (validation error), it requires Alertmanager >= 0.22.0, and it is rejected when the Alertmanager filesystem mode denies file references in AlertmanagerConfig objects. Alertmanager's own handling of api_url_file (precedence, version drop) already existed in sanitize.

Closes: #5077

Type of change

  • FEATURE (non-breaking change which adds functionality)

Verification

New tests: a golden config for apiURLFile, the filesystem guard (allowed with AllowAll, denied with DenyAll), the validation of apiURL together with apiURLFile, and the v1alpha1 to v1beta1 conversion. Generated files come from make generate.

Changelog entry

Add `apiURLFile` to the Slack configuration of the AlertmanagerConfig CRD.

Open points

The field has MinLength=1, which the Telegram and Pushover file fields do not have, so that an empty string cannot silently fall back to the global Slack URL. Happy to drop it to match them.

…rConfig

The Slack receiver of AlertmanagerConfig only accepted the webhook URL
as a secret key reference. Users who get the URL from a file on disk,
for example written by a Vault sidecar, could not use it.

Add apiURLFile to SlackConfig in v1alpha1 and v1beta1 and pass it to
the generated configuration as api_url_file. It follows the existing
Telegram botTokenFile and Pushover userKeyFile fields:

* it is mutually exclusive with apiURL, which the validation enforces
* it requires Alertmanager >= 0.22.0
* it is rejected when the Alertmanager filesystem mode denies
  AlertmanagerConfig objects from referencing files

Fixes prometheus-operator#5077

Signed-off-by: Aryan Deshmukh <[email protected]>
@A-RYAN-1
A-RYAN-1 requested a review from a team as a code owner November 18, 2026 17:57

@simonpasquier simonpasquier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we add CEL validation too pls?

…he Slack config

Reject a SlackConfig that sets both apiURL and apiURLFile at the API
server, in v1alpha1 and v1beta1, as the operator already does in its Go
validation.

Signed-off-by: Aryan Deshmukh <[email protected]>
@A-RYAN-1

Copy link
Copy Markdown
Contributor Author

Added CEL validation for apiURL and apiURLFile to both versions, CRDs regenerated (44b9450).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AlertmanagerConfig does not support apiURLFile for Slack

2 participants