forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alerting: Send alerts from state tracker to notifier, logging, and cl…
…eanup task (grafana#32333) * Initial commit for state tracking * basic state transition logic and tests * constructor. test and interface fixup * use new sig for sch.definitionRoutine() * test fixup * make the linter happy * more minor linting cleanup * Alerting: Send alerts from state tracker to notifier * Add evaluation time and test Add evaluation time and test * Add cleanup routine and logging * Pull in compact.go and reconcile differences * pr feedback * pr feedback Pull in compact.go and reconcile differences Co-authored-by: Josue Abreu <josue@grafana.com>
- Loading branch information
1 parent
b9800a2
commit b1cb74c
Showing
8 changed files
with
286 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package schedule | ||
|
||
import ( | ||
"github.com/grafana/grafana/pkg/services/ngalert/notifier" | ||
"github.com/grafana/grafana/pkg/services/ngalert/state" | ||
"github.com/prometheus/alertmanager/api/v2/models" | ||
) | ||
|
||
func FromAlertStateToPostableAlerts(firingStates []state.AlertState) []*notifier.PostableAlert { | ||
alerts := make([]*notifier.PostableAlert, 0, len(firingStates)) | ||
for _, state := range firingStates { | ||
alerts = append(alerts, ¬ifier.PostableAlert{ | ||
PostableAlert: models.PostableAlert{ | ||
Annotations: models.LabelSet{}, //TODO: add annotations to evaluation results, add them to the state struct, and then set them before sending to the notifier | ||
StartsAt: state.StartsAt, | ||
EndsAt: state.EndsAt, | ||
Alert: models.Alert{ | ||
Labels: models.LabelSet(state.Labels), | ||
}, | ||
}, | ||
}) | ||
} | ||
return alerts | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.