Skip to content

feat: full payload templating support for webhook notifier - #5011

Merged
siavashs merged 2 commits into
prometheus:mainfrom
TheMeier:webhook_tojson
Mar 3, 2026
Merged

siavashs merged 2 commits into
prometheus:mainfrom
TheMeier:webhook_tojson

Conversation

@TheMeier

@TheMeier TheMeier commented Feb 12, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request Checklist

Please check all the applicable boxes.

Which user-facing changes does this PR introduce?

[FEATURE] WEBHOOK: Allow to fully customize payload

@TheMeier
TheMeier requested a review from siavashs February 12, 2026 20:08
@TheMeier
TheMeier force-pushed the webhook_tojson branch 8 times, most recently from 9c66a3f to 5af9893 Compare February 19, 2026 19:10
@TheMeier
TheMeier force-pushed the webhook_tojson branch 2 times, most recently from a5b2711 to a6372b4 Compare February 21, 2026 20:07
@TheMeier
TheMeier marked this pull request as ready for review February 21, 2026 20:11
@TheMeier TheMeier changed the title WIP: full payload templating support for webhook notifier feat: full payload templating support for webhook notifier Feb 21, 2026
Signed-off-by: Christoph Maser <christoph.maser+github@gmail.com>
@TheMeier
TheMeier force-pushed the webhook_tojson branch 2 times, most recently from 20eaab2 to 88dbb15 Compare March 1, 2026 19:23
Signed-off-by: Christoph Maser <christoph.maser+github@gmail.com>
Comment thread examples/webhook/teams.tmpl Resolved

@siavashs siavashs 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.

LGTM

@siavashs
siavashs merged commit 47ecc27 into prometheus:main Mar 3, 2026
6 checks passed
@TheMeier TheMeier mentioned this pull request Mar 29, 2026
3 tasks done
SoloJacobs added a commit to SoloJacobs/alertmanager that referenced this pull request Apr 6, 2026
* [CHANGE] `go get github.com/prometheus/alertmanager/ui` will now fail as compiled UI assets are no longer checked into the repository. Downstream builds that rely on these assets being present in the source tree must now build the UI from source. prometheus#5113
* [CHANGE] The '--enable-feature=auto-gomaxprocs' option is deprecated and will be removed in v0.33. This flag currently has no effect and can be safely removed from any startup scripts. prometheus#5090
* [CHANGE] Update internal function signatures across multiple packages. This affects any project that integrates `Alertmanager` code.
* [ENHANCEMENT] Add static asset caching. prometheus#5113
* [ENHANCEMENT] Reduce memory allocations through pre-sizing collections and batch allocation. prometheus#5020
* [ENHANCEMENT] Replace help with documentation in navigation bar. prometheus#4943
* [ENHANCEMENT] docs(ha): Update high availability documentation. prometheus#5136
* [ENHANCEMENT] docs: Add `auth_secret_file` for smtp in document. prometheus#5036
* [ENHANCEMENT] docs: Add description for global `telegram_bot_token`. prometheus#5114
* [ENHANCEMENT] docs: Add note about notifier timeouts. prometheus#5077
* [ENHANCEMENT] docs: Fix `force_implicit_tls` config field name. prometheus#5030
* [ENHANCEMENT] docs: Link community supported integrations. prometheus#4978
* [ENHANCEMENT] docs: Remove duplicate header. prometheus#5034
* [ENHANCEMENT] docs: Update mutual tls reference in high availability documentation. prometheus#5120
* [ENHANCEMENT] tracing: Use noop spans when tracing disabled. prometheus#5118
* [FEATURE] Add silence annotations. prometheus#4965
* [FEATURE] Add silence logging option. prometheus#4163
* [FEATURE] Add support for multiple matcher set silences. prometheus#4957
* [FEATURE] Add the reason for notifying in dedup stage. prometheus#4971
* [FEATURE] mattermost: Flatten attachments into top-level config. prometheus#5009
* [FEATURE] mattermost: Support global webhook url. prometheus#4998
* [FEATURE] slack: Add default color from template. prometheus#5014
* [FEATURE] slack: Allow receiver to edit existing messages. prometheus#5007
* [FEATURE] template: Add dict, map and append functions. prometheus#5093
* [FEATURE] webhook: Add full payload templating support for notifier. prometheus#5011
* [BUGFIX] config: Check for empty cluster tls client config. prometheus#5126
* [BUGFIX] config: Don't crash upon reading empty config for notifier. prometheus#4979
* [BUGFIX] config: Fix ipv6 address handling in hostport.string(). prometheus#5040
* [BUGFIX] mattermost: Omit empty text field in notifications. prometheus#4985
* [BUGFIX] telegram: Send fallback message when notification exceeds character limit. prometheus#5074
* [BUGFIX] ui: Fix escaping for matcher values with quotes. prometheus#4862
* [BUGFIX] ui: Handle special chars in silence regex-matchers. prometheus#4942
* [BUGFIX] ui: Support utf-8 label names in matchers. prometheus#5089

Signed-off-by: Solomon Jacobs <solomonjacobs@protonmail.com>
@SoloJacobs SoloJacobs mentioned this pull request Apr 6, 2026
ultrotter pushed a commit that referenced this pull request Apr 7, 2026
* [CHANGE] `go get github.com/prometheus/alertmanager/ui` will now fail as compiled UI assets are no longer checked into the repository. Downstream builds that rely on these assets being present in the source tree must now build the UI from source. #5113
* [CHANGE] The '--enable-feature=auto-gomaxprocs' option is deprecated and will be removed in v0.33. This flag currently has no effect and can be safely removed from any startup scripts. #5090
* [CHANGE] Update internal function signatures across multiple packages. This affects any project that integrates `Alertmanager` code.
* [ENHANCEMENT] Add static asset caching. #5113
* [ENHANCEMENT] Reduce memory allocations through pre-sizing collections and batch allocation. #5020
* [ENHANCEMENT] Replace help with documentation in navigation bar. #4943
* [ENHANCEMENT] docs(ha): Update high availability documentation. #5136
* [ENHANCEMENT] docs: Add `auth_secret_file` for smtp in document. #5036
* [ENHANCEMENT] docs: Add description for global `telegram_bot_token`. #5114
* [ENHANCEMENT] docs: Add note about notifier timeouts. #5077
* [ENHANCEMENT] docs: Fix `force_implicit_tls` config field name. #5030
* [ENHANCEMENT] docs: Link community supported integrations. #4978
* [ENHANCEMENT] docs: Remove duplicate header. #5034
* [ENHANCEMENT] docs: Update mutual tls reference in high availability documentation. #5120
* [ENHANCEMENT] tracing: Use noop spans when tracing disabled. #5118
* [FEATURE] Add silence annotations. #4965
* [FEATURE] Add silence logging option. #4163
* [FEATURE] Add support for multiple matcher set silences. #4957
* [FEATURE] Add the reason for notifying in dedup stage. #4971
* [FEATURE] mattermost: Flatten attachments into top-level config. #5009
* [FEATURE] mattermost: Support global webhook url. #4998
* [FEATURE] slack: Add default color from template. #5014
* [FEATURE] slack: Allow receiver to edit existing messages. #5007
* [FEATURE] template: Add dict, map and append functions. #5093
* [FEATURE] webhook: Add full payload templating support for notifier. #5011
* [BUGFIX] config: Check for empty cluster tls client config. #5126
* [BUGFIX] config: Don't crash upon reading empty config for notifier. #4979
* [BUGFIX] config: Fix ipv6 address handling in hostport.string(). #5040
* [BUGFIX] mattermost: Omit empty text field in notifications. #4985
* [BUGFIX] telegram: Send fallback message when notification exceeds character limit. #5074
* [BUGFIX] ui: Fix escaping for matcher values with quotes. #4862
* [BUGFIX] ui: Handle special chars in silence regex-matchers. #4942
* [BUGFIX] ui: Support utf-8 label names in matchers. #5089

Signed-off-by: Solomon Jacobs <solomonjacobs@protonmail.com>
akhileshkrishnan added a commit to oodle-ai/alertmanager that referenced this pull request Aug 27, 2026
Backport of
[prometheus#5011](prometheus#5011)
onto our v0.27.0 fork.

## What

Adds an optional `payload` field to `webhook_config`. When set, it
replaces the default webhook message entirely. Every string key and
value in the (arbitrarily nested) payload is rendered as a Go template
against the standard notification data, so the operator controls the
exact JSON body posted to the endpoint.

```yaml
webhook_configs:
  - url: https://example.com/hooks/oodle
    payload:
      text: '{{ .CommonLabels.alertname }} is {{ .Status }}'
      labels: '{{ .CommonLabels | toJson }}'
      card:
        sections:
          - header: '{{ .Status }}'
```

This is what lets a webhook notifier target an endpoint with its own
request format without us adding a dedicated notifier type for it.

## Backported support

Neither piece exists at v0.27.0, so both came from upstream `main`:

- `template.DeepCopyWithTemplate` / `normalizeYAMLValue`, which walk the
payload and render string leaves. A rendered string that parses as
structured YAML/JSON is inlined (so `toJson` output becomes a real
object rather than a quoted string) and then only normalized, never
re-templated — that last part is upstream's fix for
[prometheus#5302](prometheus#5302),
included here so we don't inherit the bug.
- The `toJson` template function.

Adapted for Go 1.21 (no `reflect.TypeAssert`, no range-over-int) and for
the fork's `config.SecretURL` / go-kit logging.

## Tests

`TestWebhookDefaultPayload` pins the unchanged default body;
`TestWebhookCustomPayload` covers nesting, `toJson` inlining, and scalar
templates. `go test ./notify/... ./template/` is clean.

`config`'s `TestEmptyFieldsAndRegex` fails on `master-oodle` before this
change too — unrelated, untouched here.

## Follow-ups

Both `oodle` and `oodle-cortex` vendor this fork and need the pin bumped
to pick this up. `oodle-cortex` is the one that actually sends
notifications in production.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants