Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteSilence(ctx context.Context, endpoint string, silence *DeletableSilence) (*http.Response, error)
- func GetAlerts(ctx context.Context, endpoint string) (*http.Request, *http.Response, error)
- func IsRateLimited(conditionId string, resp *http.Response, lg *zap.SugaredLogger) (bool, error)
- func OnRetryResponse(req *http.Request, resp *http.Response) (*http.Response, error)
- func PostAlert(ctx context.Context, endpoint string, alerts []*PostableAlert) (*http.Request, *http.Response, error)
- func PostSilence(ctx context.Context, endpoint string, silence *PostableSilence) (*http.Response, error)
- func ReconcileInvalidState(newConfig *config.ConfigMapData, incoming error) error
- func ReconcileInvalidStateLoop(timeout time.Duration, newConfig *config.ConfigMapData, lg *zap.SugaredLogger) error
- func ValidateIncomingConfig(fileContent string, lg *zap.SugaredLogger) error
- type AlertManagerAPI
- func (a *AlertManagerAPI) Construct() string
- func (a *AlertManagerAPI) ConstructHTTP() string
- func (a *AlertManagerAPI) ConstructHTTPS() string
- func (a *AlertManagerAPI) IsHealthy() bool
- func (a *AlertManagerAPI) IsReady() bool
- func (a *AlertManagerAPI) WithHttpV1() *AlertManagerAPI
- func (a *AlertManagerAPI) WithHttpV2() *AlertManagerAPI
- type DeletableSilence
- type K8sEndpointBackend
- func (b *K8sEndpointBackend) Fetch(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, ...) (string, error)
- func (b *K8sEndpointBackend) Port() int
- func (b *K8sEndpointBackend) Put(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, ...) error
- func (b *K8sEndpointBackend) Reload(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, ...) error
- type LocalEndpointBackend
- func (b *LocalEndpointBackend) Fetch(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, ...) (string, error)
- func (b *LocalEndpointBackend) Port() int
- func (b *LocalEndpointBackend) Put(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, ...) error
- func (b *LocalEndpointBackend) Reload(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, ...) error
- func (b *LocalEndpointBackend) Start(ctx context.Context, lg *zap.SugaredLogger)
- type Matcher
- type PostSilencesResponse
- type PostableAlert
- type PostableSilence
- type RuntimeEndpointBackend
Constants ¶
const ( GET = "GET" POST = "POST" DELETE = "DELETE" )
const NoSMTPFromSet = "no global SMTP from set"
const NoSmartHostSet = "no global SMTP smarthost set"
Variables ¶
var FieldNotFound = regexp.MustCompile("line [0-9]+: field .* not found in type config.plain")
var RuntimeBinaryPath = "./"
Functions ¶
func DeleteSilence ¶
func IsRateLimited ¶
IsRateLimited assumes the http response status code is checked and validated
func OnRetryResponse ¶
stop/panic on 400 retry on 404/429 & 500 returns nil when we indicate nothing more should be done
func PostSilence ¶
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
func ValidateIncomingConfig ¶
func ValidateIncomingConfig(fileContent string, lg *zap.SugaredLogger) error
ValidateIncomingConfig Adapted from https://github.com/prometheus/alertmanager/blob/c732372d7d3be49198398d34753080459f01749e/cli/check_config.go#L51
Types ¶
type AlertManagerAPI ¶
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 ¶
K8sEndpointBackend implements alerting.RuntimeEndpointBackend
func (*K8sEndpointBackend) Fetch ¶
func (b *K8sEndpointBackend) Fetch(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, key string) (string, error)
func (*K8sEndpointBackend) Port ¶
func (b *K8sEndpointBackend) Port() int
func (*K8sEndpointBackend) Put ¶
func (b *K8sEndpointBackend) Put(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, key string, newData *config.ConfigMapData) error
func (*K8sEndpointBackend) Reload ¶
func (b *K8sEndpointBackend) Reload(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, key string) error
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 (b *LocalEndpointBackend) Fetch(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, key string) (string, error)
func (*LocalEndpointBackend) Port ¶
func (b *LocalEndpointBackend) Port() int
func (*LocalEndpointBackend) Put ¶
func (b *LocalEndpointBackend) Put(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, key string, data *config.ConfigMapData) error
func (*LocalEndpointBackend) Reload ¶
func (b *LocalEndpointBackend) Reload(ctx context.Context, lg *zap.SugaredLogger, options shared.NewAlertingOptions, key string) error
func (*LocalEndpointBackend) Start ¶
func (b *LocalEndpointBackend) Start(ctx context.Context, lg *zap.SugaredLogger)
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 }