Skip to content

Commit c145cd6

Browse files
committed
HttpMonitors: fix bug where we accidentally used disabled monitors also
1 parent 9bd180c commit c145cd6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

cmd/alertmanager/httpmonitorscanner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func httpMonitorScanAndAlertFailures(ctx context.Context, app *amstate.App) erro
2424

2525
failures := scanMonitors(
2626
ctx,
27-
app.State.HttpMonitors(),
27+
amstate.EnabledHttpMonitors(app.State.HttpMonitors()),
2828
newRetryScanner(newScanner()),
2929
logex.Prefix("httpscanner", app.Logger))
3030

pkg/amstate/utils.go

+12
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ func FindHttpMonitorWithId(id string, monitors []HttpMonitor) *HttpMonitor {
4747
return nil
4848
}
4949

50+
func EnabledHttpMonitors(monitors []HttpMonitor) []HttpMonitor {
51+
enabled := []HttpMonitor{}
52+
53+
for _, monitor := range monitors {
54+
if monitor.Enabled {
55+
enabled = append(enabled, monitor)
56+
}
57+
}
58+
59+
return enabled
60+
}
61+
5062
func FindDeadMansSwitchWithSubject(subject string, dmss []DeadMansSwitch) *DeadMansSwitch {
5163
for _, dms := range dmss {
5264
if dms.Subject == subject {

0 commit comments

Comments
 (0)