prometheus / prometheus/alertmanager
Notifications are not resilient to bad templates
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 8.6k
- Forks
- 2.5k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 61
Description
What did you do?
Mis-configured a notification such that a template string was invalid and could not be rendered.
What did you expect to see?
- I expected
amtool check-configto detect template errors in notifier configuration, and/or - I expected notifiers to make a best-effort to attempt to notify despite configuration bugs, since failing to notify is a very bad outcome. A notification with incomplete data would be much more useful than no notification.
What did you see instead? Under which circumstances?
Validation with amtool didn't show any errors, and notifications were dropped.
Environment
We're running alertmanager 0.25, but I believe this issue affects all versions.
Logs look like this:
alertmanager ts=2023-08-25T20:43:03.251Z caller=dispatch.go:352 level=error component=dispatcher msg="Notify for alerts failed" num_alerts=1 err="opsgenie-receiver/opsgenie[0]: notify retry canceled due to unrecoverable error after 1 attempts: templating error: template: :1: bad character U+002D '-'"
I would be happy to write a pr to either cause amtool to check for invalid templates or to enable notifiers to send partial notifications on template errors—for example, dropping fields that fail to render. Or if there's a better approach, let me know!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the invalid-template case with amtool check-config and the notifier path described in the issue; the log points to dispatch.go:352. Read the surrounding notification and template-validation flow, then clarify whether done means detecting invalid templates, preserving partial notifications, or another agreed behavior before implementing tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100