From 85337697d2496c3a7ab4e10245a1d91608aa78de Mon Sep 17 00:00:00 2001 From: Andy Lo-A-Foe Date: Fri, 22 Oct 2021 10:26:47 +0200 Subject: [PATCH] Console: add alerts structure Signed-off-by: Andy Lo-A-Foe --- console/metrics/alerts/structs.go | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 console/metrics/alerts/structs.go diff --git a/console/metrics/alerts/structs.go b/console/metrics/alerts/structs.go new file mode 100644 index 00000000..97789ca8 --- /dev/null +++ b/console/metrics/alerts/structs.go @@ -0,0 +1,57 @@ +package alerts + +import ( + "time" +) + +// Payload is the JSON format of HSDP Metrics webhook alerts +type Payload struct { + Receiver string `json:"receiver"` + Status string `json:"status"` + Alerts []Alert `json:"alerts"` + GroupLabels GroupLabel `json:"groupLabels"` + CommonLabels Label `json:"commonLabels"` + CommonAnnotations Annotation `json:"commonAnnotations"` + ExternalURL string `json:"externalURL"` + Version string `json:"version"` + GroupKey string `json:"groupKey"` +} + +// Alert describes an alert +type Alert struct { + Status string `json:"status"` + Labels Label `json:"labels"` + Annotations Annotation `json:"annotations"` + StartsAt time.Time `json:"startsAt"` + EndsAt time.Time `json:"endsAt"` + GeneratorURL string `json:"generatorURL"` +} + +// Annotation describes an alert +type Annotation struct { + Description string `json:"description"` + Summary string `json:"summary"` +} + +// Label describes a label +type Label struct { + AlertName string `json:"alertname"` + Application string `json:"application"` + ApplicationID string `json:"application_id"` + BrokerID string `json:"broker_id"` + Deployment string `json:"deployment"` + Instance string `json:"instance"` + Job string `json:"job"` + Organization string `json:"organization"` + OrganizationID string `json:"organization_id"` + Region string `json:"region"` + Severity string `json:"severity"` + Space string `json:"space"` + SpaceID string `json:"space_id"` +} + +// GroupLabel describes a group label +type GroupLabel struct { + AlertName string `json:"alertname"` + Application string `json:"application"` +}