Skip to content

Commit 21eb075

Browse files
authored
add alert name in error log (#5456)
* add alert name in error log Signed-off-by: Yijie Qin <[email protected]> * add changelog Signed-off-by: Yijie Qin <[email protected]> * address comment Signed-off-by: Yijie Qin <[email protected]> --------- Signed-off-by: Yijie Qin <[email protected]>
1 parent b3cab52 commit 21eb075

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
* [ENHANCEMENT] Distributor/Ingester: Add experimental `-distributor.sign_write_requests` flag to sign the write requests. #5430
4141
* [ENHANCEMENT] Store Gateway/Querier/Compactor: Handling CMK Access Denied errors. #5420 #5442 #5446
4242
* [ENHANCEMENT] Store Gateway: Implementing multi level index cache. #5451
43+
* [ENHANCEMENT] Alertmanager: Add the alert name in error log when it get throttled. #5456
4344
* [BUGFIX] Ruler: Validate if rule group can be safely converted back to rule group yaml from protobuf message #5265
4445
* [BUGFIX] Querier: Convert gRPC `ResourceExhausted` status code from store gateway to 422 limit error. #5286
4546
* [BUGFIX] Alertmanager: Route web-ui requests to the alertmanager distributor when sharding is enabled. #5293

pkg/alertmanager/alertmanager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ func (g *dispatcherLimits) MaxNumberOfAggregationGroups() int {
604604
}
605605

606606
var (
607-
errTooManyAlerts = "too many alerts, limit: %d"
607+
errTooManyAlerts = "too many alerts, limit: %d, alert name: %s"
608608
errAlertsTooBig = "alerts too big, total size limit: %d bytes"
609609
)
610610

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

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

676676
if existing {

pkg/alertmanager/alertmanager_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ route:
114114

115115
var (
116116
alert1 = model.Alert{
117-
Labels: model.LabelSet{"alert": "first"},
117+
Labels: model.LabelSet{"alert": "first", "alertname": "alert1"},
118118
Annotations: model.LabelSet{"job": "test"},
119119
StartsAt: time.Now(),
120120
EndsAt: time.Now(),
@@ -123,7 +123,7 @@ var (
123123
alert1Size = alertSize(alert1)
124124

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

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

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

0 commit comments

Comments
 (0)