alertsilence

package
v0.79.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package alertsilence defines AlertSilence object definitions.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertPolicySource

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

AlertPolicySource represents AlertPolicy attached to the SLO.

type AlertSilence

type AlertSilence struct {
	APIVersion manifest.Version `json:"apiVersion"`
	Kind       manifest.Kind    `json:"kind"`
	Metadata   Metadata         `json:"metadata"`
	Spec       Spec             `json:"spec"`
	Status     *Status          `json:"status,omitempty"`

	Organization   string `json:"organization,omitempty"`
	ManifestSource string `json:"manifestSrc,omitempty"`
}

AlertSilence represents alerts silencing configuration for given SLO and AlertPolicy.

Example
package main

import (
	"context"
	"log"
	"time"

	"github.com/nobl9/nobl9-go/internal/examples"
	"github.com/nobl9/nobl9-go/manifest"
	"github.com/nobl9/nobl9-go/manifest/v1alpha/alertsilence"
)

func main() {
	startTime := time.Date(2023, 5, 1, 17, 10, 5, 0, time.UTC)
	// Create the object:
	myAlertSilence := alertsilence.New(
		alertsilence.Metadata{
			Name:    "my-alert-silence",
			Project: "default",
		},
		alertsilence.Spec{
			Description: "Example alert silence",
			SLO:         "my-slo",
			AlertPolicy: alertsilence.AlertPolicySource{
				Name:    "my-alert-policy",
				Project: "default",
			},
			Period: alertsilence.Period{
				Duration:  "10m",
				StartTime: &startTime,
			},
		},
	)
	// Verify the object:
	if err := myAlertSilence.Validate(); err != nil {
		log.Fatalf("alert silence validation failed, err: %v", err)
	}
	// Apply the object:
	client := examples.GetOfflineEchoClient()
	if err := client.Objects().V1().Apply(context.Background(), []manifest.Object{myAlertSilence}); err != nil {
		log.Fatalf("failed to apply alert silence, err: %v", err)
	}
}
Output:

apiVersion: n9/v1alpha
kind: AlertSilence
metadata:
  name: my-alert-silence
  project: default
spec:
  description: Example alert silence
  slo: my-slo
  alertPolicy:
    name: my-alert-policy
    project: default
  period:
    startTime: 2023-05-01T17:10:05Z
    duration: 10m

func New

func New(metadata Metadata, spec Spec) AlertSilence

New creates a new AlertSilence based on provided Metadata nad Spec.

func (AlertSilence) GetKind

func (a AlertSilence) GetKind() manifest.Kind

func (AlertSilence) GetManifestSource

func (a AlertSilence) GetManifestSource() string

func (AlertSilence) GetName

func (a AlertSilence) GetName() string

func (AlertSilence) GetOrganization

func (a AlertSilence) GetOrganization() string

func (AlertSilence) GetProject

func (a AlertSilence) GetProject() string

func (AlertSilence) GetVersion

func (a AlertSilence) GetVersion() manifest.Version

func (AlertSilence) SetManifestSource

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

func (AlertSilence) SetOrganization

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

func (AlertSilence) SetProject

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

func (AlertSilence) Validate

func (a AlertSilence) Validate() error

type Metadata

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

Metadata defines only basic metadata fields - name and project which uniquely identifies object on project level.

type Period

type Period struct {
	StartTime *time.Time `json:"startTime,omitempty"`
	EndTime   *time.Time `json:"endTime,omitempty"`
	Duration  string     `json:"duration,omitempty"`
}

Period represents time range configuration for AlertSilence.

func (Period) GetParsedDuration

func (p Period) GetParsedDuration() (time.Duration, error)

type Spec

type Spec struct {
	Description string            `json:"description"`
	SLO         string            `json:"slo"`
	AlertPolicy AlertPolicySource `json:"alertPolicy"`
	Period      Period            `json:"period"`
}

Spec represents content of AlertSilence's Spec.

type Status

type Status struct {
	From      string `json:"from"`
	To        string `json:"to"`
	CreatedAt string `json:"createdAt"`
	UpdatedAt string `json:"updatedAt"`
}

Status represents content of Status optional for AlertSilence object.

Jump to

Keyboard shortcuts

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