Source File
alert.go
Belonging Package
github.com/prometheus/common/model
package model
import (
)
type AlertStatus string
const (
AlertFiring AlertStatus = "firing"
AlertResolved AlertStatus = "resolved"
)
Annotations LabelSet `json:"annotations"`
func ( *Alert) () string {
return string(.Labels[AlertNameLabel])
}
func ( *Alert) () Fingerprint {
return .Labels.Fingerprint()
}
func ( *Alert) () string {
:= fmt.Sprintf("%s[%s]", .Name(), .Fingerprint().String()[:7])
if .Resolved() {
return + "[resolved]"
}
return + "[active]"
}
func ( *Alert) () bool {
return .ResolvedAt(time.Now())
}
func ( *Alert) () AlertStatus {
if .Resolved() {
return AlertResolved
}
return AlertFiring
}
func ( *Alert) () error {
if .StartsAt.IsZero() {
return fmt.Errorf("start time missing")
}
if !.EndsAt.IsZero() && .EndsAt.Before(.StartsAt) {
return fmt.Errorf("start time must be before end time")
}
if := .Labels.Validate(); != nil {
return fmt.Errorf("invalid label set: %s", )
}
if len(.Labels) == 0 {
return fmt.Errorf("at least one label pair required")
}
if := .Annotations.Validate(); != nil {
return fmt.Errorf("invalid annotations: %s", )
}
return nil
}
func ( Alerts) () AlertStatus {
if .HasFiring() {
return AlertFiring
}
return AlertResolved
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |