alertmanager

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreatedBy                = "silence-operator"
	ValidUntilAnnotationName = "valid-until"
	DateOnlyLayout           = "2006-01-02"

	// Define state constant
	SilenceStateExpired = "expired"
)

Variables

View Source
var (
	ErrSilenceNotFound = errors.New("silence not found")
)

Functions

func SilenceComment added in v0.15.0

func SilenceComment(silence client.Object) string

func SilenceEndsAt added in v0.15.0

func SilenceEndsAt(silence client.Object) (time.Time, error)

SilenceEndsAt gets the expiry date for a given silence. The expiry date is retrieved from the annotation name configured by ValidUntilAnnotationName. The expected format is defined by DateOnlyLayout. It returns an invalidExpirationDateError in case the date format is invalid.

Types

type Alertmanager added in v0.17.0

type Alertmanager struct {
	// contains filtered or unexported fields
}

func New

func New(config config.Config) (*Alertmanager, error)

func (*Alertmanager) CreateSilence added in v0.17.0

func (am *Alertmanager) CreateSilence(s *Silence) error

func (*Alertmanager) DeleteSilenceByComment added in v0.17.0

func (am *Alertmanager) DeleteSilenceByComment(comment string) error

func (*Alertmanager) DeleteSilenceByID added in v0.17.0

func (am *Alertmanager) DeleteSilenceByID(id string) error

func (*Alertmanager) GetSilenceByComment added in v0.17.0

func (am *Alertmanager) GetSilenceByComment(comment string) (*Silence, error)

func (*Alertmanager) ListSilences added in v0.17.0

func (am *Alertmanager) ListSilences() ([]Silence, error)

func (*Alertmanager) NewRequest added in v0.17.0

func (am *Alertmanager) NewRequest(method, url string, body io.Reader) (*http.Request, error)

NewRequest creates a new http.Request with the given method, url and body. It adds the tenantId as X-Scope-OrgID header to the request if it is set.

func (*Alertmanager) UpdateSilence added in v0.17.0

func (am *Alertmanager) UpdateSilence(s *Silence) error

type Client added in v0.17.0

type Client interface {
	GetSilenceByComment(comment string) (*Silence, error)
	CreateSilence(s *Silence) error
	UpdateSilence(s *Silence) error
	DeleteSilenceByComment(comment string) error
	DeleteSilenceByID(id string) error
	ListSilences() ([]Silence, error)
}

Client defines the contract for alertmanager operations

type Matcher

type Matcher struct {
	IsRegex bool   `json:"isRegex"`
	IsEqual bool   `json:"isEqual"`
	Name    string `json:"name"`
	Value   string `json:"value"`
}

type Silence

type Silence struct {
	Comment   string    `json:"comment"`
	CreatedBy string    `json:"createdBy"`
	EndsAt    time.Time `json:"endsAt"`
	ID        string    `json:"id"`
	Matchers  []Matcher `json:"matchers"`
	StartsAt  time.Time `json:"startsAt"`
	Status    *Status   `json:"status"`
}

TODO Can we use open API Types here instead of defining our own types?

type Status

type Status struct {
	State string `json:"state"`
}

Jump to

Keyboard shortcuts

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