Skip to content

Commit 54dd4bc

Browse files
committed
chore: Include event data & metadata in alert payload
1 parent 09db5e4 commit 54dd4bc

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

internal/alert/monitor.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ func (m *alertMonitor) HandleAttempt(ctx context.Context, attempt DeliveryAttemp
147147
}
148148

149149
alert := NewConsecutiveFailureAlert(ConsecutiveFailureData{
150+
Event: AlertedEvent{
151+
Topic: attempt.DeliveryEvent.Event.Topic,
152+
Metadata: attempt.DeliveryEvent.Event.Metadata,
153+
Data: attempt.DeliveryEvent.Event.Data,
154+
},
150155
MaxConsecutiveFailures: m.autoDisableFailureCount,
151156
ConsecutiveFailures: count,
152157
WillDisable: m.disabler != nil && level == 100,

internal/alert/notifier.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,20 @@ func NotifierWithBearerToken(token string) NotifierOption {
4242
}
4343
}
4444

45+
type AlertedEvent struct {
46+
Topic string `json:"topic"` // event topic
47+
Metadata map[string]string `json:"metadata"` // event metadata
48+
Data map[string]interface{} `json:"data"` // event payload
49+
}
50+
4551
// ConsecutiveFailureData represents the data needed for a consecutive failure alert
4652
type ConsecutiveFailureData struct {
53+
Event AlertedEvent `json:"event"`
4754
MaxConsecutiveFailures int `json:"max_consecutive_failures"`
4855
ConsecutiveFailures int `json:"consecutive_failures"`
4956
WillDisable bool `json:"will_disable"`
5057
Destination *models.Destination `json:"destination"`
51-
Data map[string]interface{} `json:"data"`
58+
Data map[string]interface{} `json:"data"` // alert data, i.e. error message, etc.
5259
}
5360

5461
// ConsecutiveFailureAlert represents an alert for consecutive failures

0 commit comments

Comments
 (0)