backend

package
v0.6.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET    = "GET"
	POST   = "POST"
	DELETE = "DELETE"
)
View Source
const NoSMTPFromSet = "no global SMTP from set"
View Source
const NoSmartHostSet = "no global SMTP smarthost set"

Variables

View Source
var FieldNotFound = regexp.MustCompile("line [0-9]+: field .* not found in type config.plain")
View Source
var RuntimeBinaryPath = "./"

Functions

func DeleteSilence

func DeleteSilence(ctx context.Context, endpoint string, silence *DeletableSilence) (*http.Response, error)

func GetAlerts

func GetAlerts(ctx context.Context, endpoint string) (*http.Request, *http.Response, error)

func IsRateLimited

func IsRateLimited(conditionId string, resp *http.Response, lg *zap.SugaredLogger) (bool, error)

IsRateLimited assumes the http response status code is checked and validated

func OnRetryResponse

func OnRetryResponse(req *http.Request, resp *http.Response) (*http.Response, error)

stop/panic on 400 retry on 404/429 & 500 returns nil when we indicate nothing more should be done

func PostAlert

func PostAlert(ctx context.Context, endpoint string, alerts []*PostableAlert) (*http.Request, *http.Response, error)

func PostSilence

func PostSilence(ctx context.Context, endpoint string, silence *PostableSilence) (*http.Response, error)

func ReconcileInvalidState

func ReconcileInvalidState(newConfig *config.ConfigMapData, incoming error) error

ReconcileInvalidState : tries to fix detected errors in Alertmanager

func ReconcileInvalidStateLoop

func ReconcileInvalidStateLoop(timeout time.Duration, newConfig *config.ConfigMapData, lg *zap.SugaredLogger) error

Types

type AlertManagerAPI

type AlertManagerAPI struct {
	Endpoint string
	Api      string
	Route    string
	Verb     string
}

func (*AlertManagerAPI) Construct

func (a *AlertManagerAPI) Construct() string

func (*AlertManagerAPI) ConstructHTTP

func (a *AlertManagerAPI) ConstructHTTP() string

func (*AlertManagerAPI) ConstructHTTPS

func (a *AlertManagerAPI) ConstructHTTPS() string

func (*AlertManagerAPI) IsHealthy

func (a *AlertManagerAPI) IsHealthy() bool

func (*AlertManagerAPI) IsReady

func (a *AlertManagerAPI) IsReady() bool

func (*AlertManagerAPI) WithHttpV1

func (a *AlertManagerAPI) WithHttpV1() *AlertManagerAPI

WithHttpV1 ## Reference https://prometheus.io/docs/alerting/latest/clients/

func (*AlertManagerAPI) WithHttpV2

func (a *AlertManagerAPI) WithHttpV2() *AlertManagerAPI

WithHttpV2 ## OpenAPI reference https://github.com/prometheus/alertmanager/blob/main/api/v2/openapi.yaml

type DeletableSilence

type DeletableSilence struct {
	SilenceId string
}

DeletableSilence fills in api path `"/silence/{silenceID}"`

func (*DeletableSilence) Must

func (d *DeletableSilence) Must() error

func (*DeletableSilence) WithSilenceId

func (d *DeletableSilence) WithSilenceId(silenceId string)

type K8sEndpointBackend

type K8sEndpointBackend struct {
	Client client.Client
}

K8sEndpointBackend implements alerting.RuntimeEndpointBackend

func (*K8sEndpointBackend) Fetch

func (*K8sEndpointBackend) Port

func (b *K8sEndpointBackend) Port() int

func (*K8sEndpointBackend) Put

func (*K8sEndpointBackend) Reload

type LocalEndpointBackend

type LocalEndpointBackend struct {
	ConfigFilePath string
	// contains filtered or unexported fields
}

LocalEndpointBackend implements alerting.RuntimeEndpointBackend

Only used for test:env and non kubernetes environments

func (*LocalEndpointBackend) Fetch

func (*LocalEndpointBackend) Port

func (b *LocalEndpointBackend) Port() int

func (*LocalEndpointBackend) Put

func (*LocalEndpointBackend) Reload

func (*LocalEndpointBackend) Start

type Matcher

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

type PostSilencesResponse

type PostSilencesResponse struct {
	SilenceID *string `json:"silenceID,omitempty"`
}

func (*PostSilencesResponse) GetSilenceId

func (p *PostSilencesResponse) GetSilenceId() string

type PostableAlert

type PostableAlert struct {
	StartsAt     *time.Time         `json:"startsAt,omitempty"`
	EndsAt       *time.Time         `json:"endsAt,omitempty"`
	Annotations  *map[string]string `json:"annotations,omitempty"`
	Labels       map[string]string  `json:"labels"`
	GeneratorURL *string            `json:"generatorURL,omitempty"`
}

PostableAlert : corresponds to the data AlertManager API needs to trigger alerts

func (*PostableAlert) Must

func (p *PostableAlert) Must() error

func (*PostableAlert) WithCondition

func (p *PostableAlert) WithCondition(conditionId string)

WithCondition In our basic model each receiver is uniquely identified by its name, which in AlertManager can be routed to by the label `alertname`.

func (*PostableAlert) WithRuntimeInfo

func (p *PostableAlert) WithRuntimeInfo(key string, value string)

WithRuntimeInfo adds the runtime information to the alert.

type PostableSilence

type PostableSilence struct {
	Id        *string   `json:"id,omitempty"`
	Matchers  []Matcher `json:"matchers"`
	StartsAt  time.Time `json:"startsAt"`
	EndsAt    time.Time `json:"endsAt"`
	CreatedBy string    `json:"createdBy"`
	Comment   string    `json:"comment"`
}

PostableSilence struct for PostableSilence

func (*PostableSilence) Must

func (p *PostableSilence) Must() error

func (*PostableSilence) WithCondition

func (p *PostableSilence) WithCondition(conditionId string)

WithCondition In our basic model each receiver is uniquely identified by its name, which in AlertManager can be routed to by the label `alertname`.

func (*PostableSilence) WithDuration

func (p *PostableSilence) WithDuration(dur time.Duration)

func (*PostableSilence) WithSilenceId

func (p *PostableSilence) WithSilenceId(silenceId string)

type RuntimeEndpointBackend

type RuntimeEndpointBackend interface {
	Fetch(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, key string) (string, error)
	Put(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, key string, data *config.ConfigMapData) error
	Reload(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, key string) error
	Port() int
}

Jump to

Keyboard shortcuts

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