Documentation ¶
Overview ¶
Package alert defines Alert object definitions.
Index ¶
- type Alert
- func (a Alert) GetKind() manifest.Kind
- func (a Alert) GetManifestSource() string
- func (a Alert) GetName() string
- func (a Alert) GetOrganization() string
- func (a Alert) GetProject() string
- func (a Alert) GetValidator() validation.Validator[Alert]
- func (a Alert) GetVersion() manifest.Version
- func (a Alert) SetManifestSource(src string) manifest.Object
- func (a Alert) SetOrganization(org string) manifest.Object
- func (a Alert) SetProject(project string) manifest.Object
- func (a Alert) Validate() error
- type Condition
- type ConditionStatus
- type Metadata
- type ObjectMetadata
- type Objective
- type Spec
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alert ¶
type Alert struct { APIVersion manifest.Version `json:"apiVersion"` Kind manifest.Kind `json:"kind"` Metadata Metadata `json:"metadata"` Spec Spec `json:"spec"` Organization string `json:"organization,omitempty"` ManifestSource string `json:"manifestSrc,omitempty"` }
Alert represents triggered alert
Example ¶
package main import ( "context" "log" "github.com/nobl9/nobl9-go/internal/examples" "github.com/nobl9/nobl9-go/manifest" "github.com/nobl9/nobl9-go/manifest/v1alpha/alert" ) func main() { alertInstance := alert.New( alert.Metadata{ Name: "my-alert", Project: "default", }, alert.Spec{ AlertPolicy: alert.ObjectMetadata{ Name: "burn-rate-is-4x-immediately", Project: "alerting-test", }, Service: alert.ObjectMetadata{ Name: "triggering-alerts-service", Project: "alerting-test", }, SLO: alert.ObjectMetadata{ Name: "prometheus-rolling-timeslices-threshold", Project: "alerting-test", }, Objective: alert.Objective{ Name: "ok", DisplayName: "ok", Value: 99, }, Severity: "Medium", Status: "Triggered", TriggeredClockTime: "2022-01-16T00:28:05Z", }, ) // Apply the object: client := examples.GetOfflineEchoClient() if err := client.Objects().V1().Apply(context.Background(), []manifest.Object{alertInstance}); err != nil { log.Fatal("failed to apply alert err: %w", err) } }
Output: apiVersion: n9/v1alpha kind: Alert metadata: name: my-alert project: default spec: alertPolicy: name: burn-rate-is-4x-immediately project: alerting-test slo: name: prometheus-rolling-timeslices-threshold project: alerting-test service: name: triggering-alerts-service project: alerting-test objective: value: 99.0 name: ok displayName: ok severity: Medium status: Triggered triggeredMetricTime: "" triggeredClockTime: 2022-01-16T00:28:05Z coolDown: "" conditions: []
func (Alert) GetManifestSource ¶
func (Alert) GetOrganization ¶
func (Alert) GetProject ¶
func (Alert) GetValidator ¶ added in v0.82.0
func (a Alert) GetValidator() validation.Validator[Alert]
func (Alert) GetVersion ¶
type Condition ¶
type Condition struct { Measurement string `json:"measurement"` Value interface{} `json:"value"` AlertingWindow string `json:"alertingWindow,omitempty"` LastsForDuration string `json:"lastsFor,omitempty"` Operator string `json:"op,omitempty"` Status *ConditionStatus `json:"status,omitempty"` }
type ConditionStatus ¶ added in v0.82.0
type ObjectMetadata ¶
type Spec ¶
type Spec struct { AlertPolicy ObjectMetadata `json:"alertPolicy"` SLO ObjectMetadata `json:"slo"` Service ObjectMetadata `json:"service"` Objective Objective `json:"objective"` Severity string `json:"severity"` Status string `json:"status"` TriggeredMetricTime string `json:"triggeredMetricTime"` TriggeredClockTime string `json:"triggeredClockTime"` ResolvedClockTime *string `json:"resolvedClockTime,omitempty"` ResolvedMetricTime *string `json:"resolvedMetricTime,omitempty"` CoolDown string `json:"coolDown"` Conditions []Condition `json:"conditions"` CoolDownStartedAtMetricTime *string `json:"coolDownStartedAtMetricTime,omitempty"` ResolutionReason *string `json:"resolutionReason,omitempty"` }
Spec represents content of Alert's Spec
Click to show internal directories.
Click to hide internal directories.