Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add alert name in error log #5456

Merged
merged 3 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
* [BUGFIX] Store Gateway: Fix bug in store gateway ring comparison logic. #5426
* [BUGFIX] Ring: Fix bug in consistency of Get func in a scaling zone-aware ring. #5429
* [BUGFIX] Query Frontend: Fix bug of failing to cancel downstream request context in query frontend v2 mode (query scheduler enabled). #5447
* [ENHANCEMENT] Alertmanager: Add the alert name in error log when it get throttled. #5456
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's have this enhancement close to other enhancements.


## 1.15.1 2023-04-26

Expand Down
4 changes: 2 additions & 2 deletions pkg/alertmanager/alertmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ func (g *dispatcherLimits) MaxNumberOfAggregationGroups() int {
}

var (
errTooManyAlerts = "too many alerts, limit: %d"
errTooManyAlerts = "too many alerts, limit: %d, alert name: %s"
errAlertsTooBig = "alerts too big, total size limit: %d bytes"
)

Expand Down Expand Up @@ -670,7 +670,7 @@ func (a *alertsLimiter) PreStore(alert *types.Alert, existing bool) error {

if !existing && countLimit > 0 && (a.count+1) > countLimit {
a.failureCounter.Inc()
return fmt.Errorf(errTooManyAlerts, countLimit)
return fmt.Errorf(errTooManyAlerts, countLimit, alert.Name())
}

if existing {
Expand Down
6 changes: 3 additions & 3 deletions pkg/alertmanager/alertmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ route:

var (
alert1 = model.Alert{
Labels: model.LabelSet{"alert": "first"},
Labels: model.LabelSet{"alert": "first", "alertname": "alert1"},
Annotations: model.LabelSet{"job": "test"},
StartsAt: time.Now(),
EndsAt: time.Now(),
Expand All @@ -123,7 +123,7 @@ var (
alert1Size = alertSize(alert1)

alert2 = model.Alert{
Labels: model.LabelSet{"alert": "second"},
Labels: model.LabelSet{"alert": "second", "alertname": "alert2"},
Annotations: model.LabelSet{"job": "test", "cluster": "prod"},
StartsAt: time.Now(),
EndsAt: time.Now(),
Expand Down Expand Up @@ -161,7 +161,7 @@ func TestAlertsLimiterWithCountLimit(t *testing.T) {

ops := []callbackOp{
{alert: &types.Alert{Alert: alert1}, existing: false, expectedCount: 1, expectedTotalSize: alert1Size},
{alert: &types.Alert{Alert: alert2}, existing: false, expectedInsertError: fmt.Errorf(errTooManyAlerts, 1), expectedCount: 1, expectedTotalSize: alert1Size},
{alert: &types.Alert{Alert: alert2}, existing: false, expectedInsertError: fmt.Errorf(errTooManyAlerts, 1, alert2.Name()), expectedCount: 1, expectedTotalSize: alert1Size},
{alert: &types.Alert{Alert: alert1}, delete: true, expectedCount: 0, expectedTotalSize: 0},

{alert: &types.Alert{Alert: alert2}, existing: false, expectedCount: 1, expectedTotalSize: alert2Size},
Expand Down