Skip to content

Commit

Permalink
Merge pull request #7 from argentumcode/feature/dedup-key
Browse files Browse the repository at this point in the history
feat: add dedup key to supress duplicate alerts
  • Loading branch information
nomeaning777 authored Dec 15, 2023
2 parents 12a11c7 + 83e8488 commit 476ddeb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bytes"
"context"
"crypto/sha256"
"fmt"
"log"
"net/http"
Expand Down Expand Up @@ -57,6 +58,7 @@ func main() {
Details: details,
}
event.Payload = payload
event.DedupKey = fmt.Sprintf("%x", sha256.Sum256([]byte(fmt.Sprintf("%s-%s", hostName, unitName))))

var retryErr error
retryWaitDuration := time.Second
Expand All @@ -65,6 +67,7 @@ func main() {
time.Sleep(retryWaitDuration)
retryWaitDuration *= 2
}

if _, err := pagerduty.ManageEventWithContext(context.Background(), event); err != nil {
log.Printf("failed to send to pagerduty: %+v", err)
retryErr = err
Expand Down

0 comments on commit 476ddeb

Please sign in to comment.