Skip to content

feat(notify): distinguish auth and rate-limit failure reasons - #5332

Merged
siavashs merged 1 commit into
prometheus:mainfrom
siavashs:feat/notify/better-reasons
Jul 1, 2026
Merged

siavashs merged 1 commit into
prometheus:mainfrom
siavashs:feat/notify/better-reasons

Conversation

@siavashs

@siavashs siavashs commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Authentication errors (HTTP 401/403) and rate limiting (HTTP 429) previously surfaced as the generic "clientError" reason on the alertmanager_notifications_failed_total metric, making it impossible to tell these apart for PagerDuty and other receivers.

Add two new failure reasons, "authError" (401/403) and "rateLimited" (429), and refine the centralized GetFailureReasonFromStatusCode so all HTTP integrations benefit automatically. Also fix the discord and webex integrations, which previously dropped the failure reason entirely.

Note: this changes the reason label values on
alertmanager_notifications_failed_total; dashboards or alerts matching reason="clientError" for 401/403/429 must be updated.

Pull Request Checklist

Please check all the applicable boxes.

  • Please list all open issue(s) discussed with maintainers related to this change
    • Fixes #
  • Is this a new Receiver integration?
  • Is this a bugfix?
    • I have added tests that can reproduce the bug which pass with this bugfix applied
  • Is this a new feature?
    • I have added tests that test the new feature's functionality
  • Does this change affect performance?
    • I have provided benchmarks comparison that shows performance is improved or is not degraded
      • You can use benchstat to compare benchmarks
    • I have added new benchmarks if required or requested by maintainers
  • Is this a breaking change?
    • My changes do not break the existing cluster messages
    • My changes do not break the existing api
  • I have added/updated the required documentation
  • I have signed-off my commits
  • I will follow best practices for contributing to this project

Which user-facing changes does this PR introduce?

[CHANGE] notify: The `reason` label on `alertmanager_notifications_failed_total` now distinguishes `authError` (HTTP 401/403) and `rateLimited` (HTTP 429) from the generic `clientError`. Dashboards/alerts matching `reason="clientError"` for these codes must be updated.
[ENHANCEMENT] notify: The discord and webex integrations now report a failure `reason` on `alertmanager_notifications_failed_total`.

@siavashs
siavashs requested a review from a team as a code owner June 29, 2026 15:24
@coderabbitai

coderabbitai Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 2998b803-1a44-49cb-b1d0-828d8402c0d3

📥 Commits

Reviewing files that changed from the base of the PR and between e4dca15 and 7443d13.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • notify/discord/discord.go
  • notify/slack/slack_test.go
  • notify/util.go
  • notify/util_test.go
  • notify/webex/webex.go
✅ Files skipped from review due to trivial changes (2)
  • notify/slack/slack_test.go
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • notify/discord/discord.go
  • notify/webex/webex.go
  • notify/util.go

📝 Walkthrough

Walkthrough

Two new failure reasons are added, HTTP 401/403 and 429 are mapped separately, and discord/webex notifier errors now include derived reasons. Tests and changelog entries were updated accordingly.

Changes

Failure reason granularity for notifications

Layer / File(s) Summary
Reason values and status mapping
notify/util.go, notify/util_test.go
Adds AuthErrorReason and RateLimitedReason, extends string/category handling, updates GetFailureReasonFromStatusCode to classify 401/403 and 429 separately, and adds table-driven coverage for the mapping.
Notifier reason wrapping and docs
notify/discord/discord.go, notify/webex/webex.go, notify/slack/slack_test.go, CHANGELOG.md
discord and webex wrap retrier errors with notify.NewErrorWithReason(...), the Slack test expects AuthErrorReason for 4xx, and the changelog records the metric reason changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, specific, and matches the main change in the PR.
Description check ✅ Passed The description follows the template well and includes release notes plus checklist items.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@siavashs
siavashs force-pushed the feat/notify/better-reasons branch 2 times, most recently from e4dca15 to 8e8e66c Compare June 29, 2026 17:13
Authentication errors (HTTP 401/403) and rate limiting (HTTP 429)
previously surfaced as the generic "clientError" reason on the
alertmanager_notifications_failed_total metric, making it impossible to
tell these apart for PagerDuty and other receivers.

Add two new failure reasons, "authError" (401/403) and "rateLimited"
(429), and refine the centralized GetFailureReasonFromStatusCode so all
HTTP integrations benefit automatically. Also fix the discord and webex
integrations, which previously dropped the failure reason entirely.

Note: this changes the `reason` label values on
alertmanager_notifications_failed_total; dashboards or alerts matching
reason="clientError" for 401/403/429 must be updated.

Signed-off-by: Siavash Safi <[email protected]>
@siavashs
siavashs force-pushed the feat/notify/better-reasons branch from 8e8e66c to 7443d13 Compare June 29, 2026 17:14
@siavashs
siavashs merged commit 1dee97b into prometheus:main Jul 1, 2026
7 checks passed
@siavashs
siavashs deleted the feat/notify/better-reasons branch July 1, 2026 10:13
@SoloJacobs SoloJacobs mentioned this pull request Aug 14, 2026
Exikle pushed a commit to Exikle/home-infra that referenced this pull request Nov 16, 2026
….1 ➔ v0.34.0) (#224)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [quay.io/prometheus/alertmanager](https://github.com/prometheus/alertmanager) | minor | `v0.33.1` → `v0.34.0` |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/13) for more information.

---

### Release Notes

<details>
<summary>prometheus/alertmanager (quay.io/prometheus/alertmanager)</summary>

### [`v0.34.0`](https://github.com/prometheus/alertmanager/releases/tag/v0.34.0): 0.34.0 / 2026-08-16

[Compare Source](prometheus/alertmanager@v0.33.1...v0.34.0)

- \[CHANGE] notify: The `reason` label on `alertmanager_notifications_failed_total` now distinguishes `authError` (HTTP 401/403) and `rateLimited` (HTTP 429) from the generic `clientError`. Dashboards/alerts matching `reason="clientError"` for these codes must be updated. [#&#8203;5332](prometheus/alertmanager#5332)
- \[FEATURE] Add optional templatable labels to alert routes. [#&#8203;5328](prometheus/alertmanager#5328)
- \[FEATURE] eventrecorder: Add inhibit rule names to `inhibition_muted_alert` events. [#&#8203;5315](prometheus/alertmanager#5315)
- \[FEATURE] eventrecorder: Add stdout output type. [#&#8203;5311](prometheus/alertmanager#5311)
- \[FEATURE] silences: Add active, expired, and pending boolean filter parameters to GET /api/v2/silences to allow filtering silences by state server-side. [#&#8203;5406](prometheus/alertmanager#5406)
- \[FEATURE] sns: Add aws `external_id` support in sigv4 configuration. [#&#8203;5157](prometheus/alertmanager#5157)
- \[FEATURE] template: Add `toDate` and `mustToDate` functions. [#&#8203;5327](prometheus/alertmanager#5327)
- \[ENHANCEMENT] doc: Add AlertmanagerClusterFailedPeers alertmanager-mixin. [#&#8203;5301](prometheus/alertmanager#5301)
- \[ENHANCEMENT] doc: Add description for Rocketchat parameters in global config. [#&#8203;5181](prometheus/alertmanager#5181)
- \[ENHANCEMENT] doc: Add top level tracing configuration key. [#&#8203;5314](prometheus/alertmanager#5314)
- \[ENHANCEMENT] doc: Fix Alertmanager port in amtool config routes example. [#&#8203;5312](prometheus/alertmanager#5312)
- \[ENHANCEMENT] eventrecorder: Add optional webhook batching. [#&#8203;5392](prometheus/alertmanager#5392)
- \[ENHANCEMENT] notify: The discord and webex integrations now report a failure `reason` on `alertmanager_notifications_failed_total`. [#&#8203;5332](prometheus/alertmanager#5332)
- \[ENHANCEMENT] ui: Improve responsiveness of UI when loading thousands of alerts. [#&#8203;5357](prometheus/alertmanager#5357)
- \[BUGFIX] eventrecorder: Fixed a minor performance regression when the event recorder is enabled. [#&#8203;5307](prometheus/alertmanager#5307)
- \[BUGFIX] msteamsv2: Inherit global `proxy_url` into partial `http_config`. [#&#8203;5379](prometheus/alertmanager#5379)
- \[BUGFIX] webhook: Keep custom `payload` string values verbatim instead of reinterpreting JSON leaves that look like YAML (e.g. values ending with a colon). [#&#8203;5304](prometheus/alertmanager#5304)

</details>

---

### Configuration

📅 **Schedule**: (in timezone America/Toronto)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4zMC40IiwidXBkYXRlZEluVmVyIjoiNDQuMzIuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsicHJpb3JpdHkvbWVkaXVtIiwicmVub3ZhdGUvY29udGFpbmVyIiwidHlwZS9taW5vciJdfQ==-->

Reviewed-on: https://git.dcunha.io/Exikle/frostlink/pulls/224
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.

2 participants