prometheus / prometheus/alertmanager
Aggregation Groups result in too many go routines
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 8.6k
- Forks
- 2.5k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 61
Description
Aggregation groups run in dedicated go routines, this means that alertmanager can create thousands of routines, depending on the number of unique alerts it receives and grouping config: https://github.com/prometheus/alertmanager/blob/f6b942cf9b3a503d59192eada300d2ad97cba82f/dispatch/dispatch.go#L350
These routines are usually waiting in a select statement for the next ticker which seems very wasteful: https://github.com/prometheus/alertmanager/blob/f6b942cf9b3a503d59192eada300d2ad97cba82f/dispatch/dispatch.go#L440-L442
Some graphs from our deployment:
A better approach could be creating one go routine per receiver instead as aggregation groups share receivers. This should reduce the number of go routines significantly.
Aggregation groups can depend on receiver based trigger to flush notifications.
Aggregation groups also support a global limit: https://github.com/prometheus/alertmanager/blob/f6b942cf9b3a503d59192eada300d2ad97cba82f/dispatch/dispatch.go#L333-L338
but this is currently not used(nil limiter): https://github.com/prometheus/alertmanager/blob/f6b942cf9b3a503d59192eada300d2ad97cba82f/cmd/alertmanager/main.go#L495
I think to protect alertmanager under load, we should implement a per receiver limiter.
If alerts sent to a receiver are not acted upon it can be assumed that alert manager can limit the number of aggregation groups created for that receiver.
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 in dispatch/dispatch.go at the aggregation-group goroutine and global limiter sections linked in the issue, then inspect cmd/alertmanager/main.go around line 495 where the limiter is nil. Determine how receiver-based triggering and limiting should fit the existing dispatch flow. Done means reducing per-group goroutines and wiring a per-receiver limiter to protect Alertmanager under load.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100