Skip to content

Commit

Permalink
Merge pull request #265 from wanjunlei/master
Browse files Browse the repository at this point in the history
add alerttime to metric alert
  • Loading branch information
benjaminhuo authored May 13, 2024
2 parents dce639d + e3cd101 commit 9c0e893
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/webhook/v1/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ func (h *HttpHandler) Alert(w http.ResponseWriter, r *http.Request) {
if v := alert.Labels["cluster"]; v == "" {
alert.Labels["cluster"] = cluster
}

if alert.Labels["alerttype"] == "metric" {
alert.Annotations["alerttime"] = time.Now().Local().String()
}

alert.ID = utils.Hash(alert)
if err := h.alerts.Push(alert); err != nil {
_ = level.Error(h.logger).Log("msg", "push alert error", "error", err.Error())
Expand Down

0 comments on commit 9c0e893

Please sign in to comment.