mirror of
https://github.com/prymitive/karma
synced 2026-05-13 03:56:59 +00:00
Use alert status, inhibitedBy & silencedBy fields instead of silenced & inhibited
This commit is contained in:
@@ -23,6 +23,23 @@ type Silence struct {
|
||||
JiraURL string `json:"jiraURL"`
|
||||
}
|
||||
|
||||
// AlertStateUnprocessed means that Alertmanager notify didn't yet process it
|
||||
// and AM doesn't know if alert is active or suppressed
|
||||
const AlertStateUnprocessed = "unprocessed"
|
||||
|
||||
// AlertStateActive is the state in which we know that the alert should fire
|
||||
const AlertStateActive = "active"
|
||||
|
||||
// AlertStateSuppressed means that we know that alert is silenced or inhibited
|
||||
const AlertStateSuppressed = "suppressed"
|
||||
|
||||
// AlertStateList exports all alert states so other packages can get this list
|
||||
var AlertStateList = []string{
|
||||
AlertStateUnprocessed,
|
||||
AlertStateActive,
|
||||
AlertStateSuppressed,
|
||||
}
|
||||
|
||||
// Alert is vanilla alert + some additional attributes
|
||||
// unsee extends an alert object with:
|
||||
// * Links map, it's generated from annotations if annotation value is an url
|
||||
@@ -35,16 +52,29 @@ type Alert struct {
|
||||
StartsAt time.Time `json:"startsAt"`
|
||||
EndsAt time.Time `json:"endsAt"`
|
||||
GeneratorURL string `json:"generatorURL"`
|
||||
Status string `json:"Status"`
|
||||
Status string `json:"status"`
|
||||
SilencedBy []string `json:"silencedBy"`
|
||||
InhibitedBy []string `json:"inhibitedBy"`
|
||||
Inhibited bool `json:"inhibited"`
|
||||
Silenced string `json:"silenced"`
|
||||
// unsee fields
|
||||
Links map[string]string `json:"links"`
|
||||
Fingerprint string `json:"-"`
|
||||
}
|
||||
|
||||
// IsSilenced will return true if alert should be considered silenced
|
||||
func (a Alert) IsSilenced() bool {
|
||||
return (a.Status == AlertStateSuppressed && len(a.SilencedBy) > 0)
|
||||
}
|
||||
|
||||
// IsInhibited will return true if alert should be considered silenced
|
||||
func (a Alert) IsInhibited() bool {
|
||||
return (a.Status == AlertStateSuppressed && len(a.InhibitedBy) > 0)
|
||||
}
|
||||
|
||||
// IsActive will return true if alert is not suppressed in any way
|
||||
func (a Alert) IsActive() bool {
|
||||
return (a.Status == AlertStateActive)
|
||||
}
|
||||
|
||||
// AlertList is flat list of UnseeAlert objects
|
||||
type AlertList []Alert
|
||||
|
||||
|
||||
Reference in New Issue
Block a user