alertpolicy

package
v0.85.1-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2024 License: MPL-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Package alertpolicy defines AlertPolicy object definitions and validation.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultOperatorForMeasurement added in v0.82.0

func GetDefaultOperatorForMeasurement(measurement Measurement) (v1alpha.Operator, error)

GetDefaultOperatorForMeasurement returns the default operator when operator is undefined.

Types

type AlertCondition

type AlertCondition struct {
	Measurement      string      `json:"measurement"`
	Value            interface{} `json:"value"`
	AlertingWindow   string      `json:"alertingWindow,omitempty"`
	LastsForDuration string      `json:"lastsFor,omitempty"`
	Operator         string      `json:"op,omitempty"`
}

AlertCondition represents a condition to meet to trigger an alert.

type AlertMethodRef

type AlertMethodRef struct {
	Metadata AlertMethodRefMetadata `json:"metadata"`
	// contains filtered or unexported fields
}

func (*AlertMethodRef) EmbedAlertMethodRef

func (a *AlertMethodRef) EmbedAlertMethodRef(ref interface{})

EmbedAlertMethodRef sets AlertMethodRef to an arbitrary value. Deprecated: Temporary solution to keep backward compatibility to return AlertMethod details. These objects and their details will be dropped.

func (*AlertMethodRef) MarshalJSON

func (a *AlertMethodRef) MarshalJSON() ([]byte, error)

type AlertMethodRefMetadata

type AlertMethodRefMetadata struct {
	Name    string `json:"name"`
	Project string `json:"project,omitempty"`
}

type AlertPolicy

type AlertPolicy 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"`
}

AlertPolicy represents a set of conditions that can trigger an alert.

Example
Output:

apiVersion: n9/v1alpha
kind: AlertPolicy
metadata:
  name: my-alert-policy
  displayName: My Alert Policy
  project: default
  labels:
    region:
    - eu-central-1
    team:
    - green
    - orange
spec:
  description: Example alert policy
  severity: High
  coolDown: 5m
  conditions:
  - measurement: burnedBudget
    value: 0.8
  alertMethods:
  - metadata:
      name: my-alert-method
      project: my-project

func New

func New(metadata Metadata, spec Spec) AlertPolicy

func (AlertPolicy) GetKind

func (a AlertPolicy) GetKind() manifest.Kind

func (AlertPolicy) GetManifestSource

func (a AlertPolicy) GetManifestSource() string

func (AlertPolicy) GetName

func (a AlertPolicy) GetName() string

func (AlertPolicy) GetOrganization

func (a AlertPolicy) GetOrganization() string

func (AlertPolicy) GetProject

func (a AlertPolicy) GetProject() string

func (AlertPolicy) GetValidator added in v0.82.0

func (a AlertPolicy) GetValidator() govy.Validator[AlertPolicy]

func (AlertPolicy) GetVersion

func (a AlertPolicy) GetVersion() manifest.Version

func (AlertPolicy) SetManifestSource

func (a AlertPolicy) SetManifestSource(src string) manifest.Object

func (AlertPolicy) SetOrganization

func (a AlertPolicy) SetOrganization(org string) manifest.Object

func (AlertPolicy) SetProject

func (a AlertPolicy) SetProject(project string) manifest.Object

func (AlertPolicy) Validate

func (a AlertPolicy) Validate() error

type Measurement

type Measurement int16

Measurement is allowed measurement types used for comparing values and triggering alerts

const (
	MeasurementBurnedBudget Measurement = iota + 1
	MeasurementAverageBurnRate
	MeasurementTimeToBurnBudget
	MeasurementTimeToBurnEntireBudget
	MeasurementBudgetDrop
)

func ParseMeasurement

func ParseMeasurement(value string) (Measurement, error)

ParseMeasurement parses string to Measurement

func (Measurement) String

func (m Measurement) String() string

type Metadata

type Metadata struct {
	Name        string                      `json:"name"`
	DisplayName string                      `json:"displayName,omitempty"`
	Project     string                      `json:"project,omitempty"`
	Labels      v1alpha.Labels              `json:"labels,omitempty"`
	Annotations v1alpha.MetadataAnnotations `json:"annotations,omitempty"`
}

type Severity

type Severity int16

Severity level describe importance of triggered alert

const (
	SeverityLow Severity = iota + 1
	SeverityMedium
	SeverityHigh
)

func ParseSeverity

func ParseSeverity(value string) (Severity, error)

ParseSeverity parses string to Severity

func (Severity) String

func (m Severity) String() string

type Spec

type Spec struct {
	Description      string           `json:"description"`
	Severity         string           `json:"severity"`
	CoolDownDuration string           `json:"coolDown,omitempty"`
	Conditions       []AlertCondition `json:"conditions"`
	AlertMethods     []AlertMethodRef `json:"alertMethods"`
}

Spec represents content of AlertPolicy's Spec.

func (Spec) GetAlertMethods

func (spec Spec) GetAlertMethods() []AlertMethodRef

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL