Skip to content

Commit

Permalink
Env SUPPRESS_UNKNOWN_TO_OK (bool) to eliminate non-actionable alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesJJ committed Apr 15, 2021
1 parent 60dfc8f commit 32d92d4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions function/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ import (
"log"
"net/http"
"os"
"strconv"
"time"
)

var (
SuppressableAlertsStateFromTo = map[string]string{
"INSUFFICIENT_DATA": "OK",
}
)

func handleRequest(request events.SNSEvent) error {

var cloudwatchAlarm events.CloudWatchAlarmSNSPayload
Expand All @@ -22,6 +29,18 @@ func handleRequest(request events.SNSEvent) error {
return nil // Non-retryable error
}

if suppress, err := strconv.ParseBool(os.Getenv("SUPPRESS_UNKNOWN_TO_OK")); err == nil && suppress {
if SuppressableAlertsStateFromTo[cloudwatchAlarm.OldStateValue] == cloudwatchAlarm.NewStateValue {
log.Printf(
"Alarm suppressed for %s --> %s \"%s\"",
cloudwatchAlarm.OldStateValue,
cloudwatchAlarm.NewStateValue,
cloudwatchAlarm.AlarmName,
)
return nil
}
}

log.Printf(
"Alarm: %s --> %s \"%s\"",
cloudwatchAlarm.OldStateValue,
Expand Down

0 comments on commit 32d92d4

Please sign in to comment.