Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertEndpointIdsToRoutingNode(endpointList *alertingv1.AlertEndpointList, req *alertingv1.AttachedEndpoints, ...) (*alertingv1.RoutingNode, error)
- func NewApiPipline(ctx context.Context, apis []*AlertManagerAPI, chainRetrier *backoffv2.Policy) error
- func NewExpectConfigEqual(expectedConfig string) func(*http.Response) error
- func NewExpectStatusCodes(expectedCodes []int) func(*http.Response) error
- func NewExpectStatusOk() func(*http.Response) error
- func ReconcileInvalidState(newConfig *routing.RoutingTree, incoming error) error
- func ReconcileInvalidStateLoop(timeout time.Duration, newConfig *routing.RoutingTree, lg *zap.SugaredLogger) error
- func ValidateIncomingConfig(fileContent string, lg *zap.SugaredLogger) error
- type Alert
- type AlertGroup
- type AlertManagerAPI
- func NewAlertManagerDeleteSilenceClient(ctx context.Context, endpoint, silenceId string, opts ...AlertManagerApiOption) *AlertManagerAPI
- func NewAlertManagerGetAlertsClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
- func NewAlertManagerGetSilenceClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
- func NewAlertManagerPostAlertClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
- func NewAlertManagerPostSilenceClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
- func NewAlertManagerReadyClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
- func NewAlertManagerReceiversClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
- func NewAlertManagerReloadClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
- func NewAlertManagerStatusClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
- type AlertManagerApiOption
- func WithDefaultRetrier() AlertManagerApiOption
- func WithExpectClosure(expectClosure func(*http.Response) error) AlertManagerApiOption
- func WithHttpClient(client *http.Client) AlertManagerApiOption
- func WithLogger(logger *zap.SugaredLogger) AlertManagerApiOption
- func WithPostAlertBody(conditionId string, annotations map[string]string) AlertManagerApiOption
- func WithPostSilenceBody(conditionId string, duration time.Duration, silenceId *string) AlertManagerApiOption
- func WithRequestBody(body io.Reader) AlertManagerApiOption
- func WithRetrier(retrier backoffv2.Policy) AlertManagerApiOption
- func WithURLValues(values url.Values) AlertManagerApiOption
- type AlertManagerApiOptions
- type AlertStatus
- type GettableAlert
- type LabelSet
- type Matcher
- type PostSilencesResponse
- type PostableAlert
- type PostableSilence
- type Receiver
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")
Functions ¶
func ConvertEndpointIdsToRoutingNode ¶ added in v0.6.1
func ConvertEndpointIdsToRoutingNode( endpointList *alertingv1.AlertEndpointList, req *alertingv1.AttachedEndpoints, conditionId string, ) (*alertingv1.RoutingNode, error)
func NewApiPipline ¶ added in v0.6.1
func NewApiPipline(ctx context.Context, apis []*AlertManagerAPI, chainRetrier *backoffv2.Policy) error
Apis to be called in succession, if failed restart the entire pipeline
func NewExpectConfigEqual ¶ added in v0.6.1
func NewExpectStatusCodes ¶ added in v0.6.1
func NewExpectStatusOk ¶ added in v0.6.1
func ReconcileInvalidState ¶
func ReconcileInvalidState(newConfig *routing.RoutingTree, incoming error) error
ReconcileInvalidState : tries to fix detected errors in Alertmanager
func ReconcileInvalidStateLoop ¶
func ReconcileInvalidStateLoop(timeout time.Duration, newConfig *routing.RoutingTree, 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 Alert ¶ added in v0.6.1
type Alert struct { // generator URL // Format: uri GeneratorURL strfmt.URI `json:"generatorURL,omitempty"` // labels // Required: true Labels LabelSet `json:"labels"` }
Alert alert
swagger:model alert
type AlertGroup ¶ added in v0.6.1
type AlertGroup struct { Labels map[string]string `json:"labels"` Receiver Receiver `json:"receiver"` Alerts []GettableAlert `json:"alerts"` }
AlertGroup struct for AlertGroup
type AlertManagerAPI ¶
type AlertManagerAPI struct { *AlertManagerApiOptions Endpoint string Api string Route string Verb string // contains filtered or unexported fields }
func NewAlertManagerDeleteSilenceClient ¶ added in v0.6.1
func NewAlertManagerDeleteSilenceClient(ctx context.Context, endpoint, silenceId string, opts ...AlertManagerApiOption) *AlertManagerAPI
func NewAlertManagerGetAlertsClient ¶ added in v0.6.1
func NewAlertManagerGetAlertsClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
func NewAlertManagerGetSilenceClient ¶ added in v0.6.1
func NewAlertManagerGetSilenceClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
func NewAlertManagerPostAlertClient ¶ added in v0.6.1
func NewAlertManagerPostAlertClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
func NewAlertManagerPostSilenceClient ¶ added in v0.6.1
func NewAlertManagerPostSilenceClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
func NewAlertManagerReadyClient ¶ added in v0.6.1
func NewAlertManagerReadyClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
func NewAlertManagerReceiversClient ¶ added in v0.6.1
func NewAlertManagerReceiversClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
func NewAlertManagerReloadClient ¶ added in v0.6.1
func NewAlertManagerReloadClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *AlertManagerAPI
func NewAlertManagerStatusClient ¶ added in v0.6.1
func NewAlertManagerStatusClient(ctx context.Context, endpoint string, opts ...AlertManagerApiOption) *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) DoRequest ¶ added in v0.6.1
func (a *AlertManagerAPI) DoRequest() error
func (*AlertManagerAPI) WithAPIV1 ¶ added in v0.6.1
func (a *AlertManagerAPI) WithAPIV1() *AlertManagerAPI
WithAPIV1 ## Reference https://prometheus.io/docs/alerting/latest/clients/
func (*AlertManagerAPI) WithAPIV2 ¶ added in v0.6.1
func (a *AlertManagerAPI) WithAPIV2() *AlertManagerAPI
WithAPIV2 ## OpenAPI reference https://github.com/prometheus/alertmanager/blob/main/api/v2/openapi.yaml
type AlertManagerApiOption ¶ added in v0.6.1
type AlertManagerApiOption func(*AlertManagerApiOptions)
func WithDefaultRetrier ¶ added in v0.6.1
func WithDefaultRetrier() AlertManagerApiOption
func WithExpectClosure ¶ added in v0.6.1
func WithExpectClosure(expectClosure func(*http.Response) error) AlertManagerApiOption
func WithHttpClient ¶ added in v0.6.1
func WithHttpClient(client *http.Client) AlertManagerApiOption
func WithLogger ¶ added in v0.6.1
func WithLogger(logger *zap.SugaredLogger) AlertManagerApiOption
func WithPostAlertBody ¶ added in v0.6.1
func WithPostAlertBody(conditionId string, annotations map[string]string) AlertManagerApiOption
func WithPostSilenceBody ¶ added in v0.6.1
func WithPostSilenceBody(conditionId string, duration time.Duration, silenceId *string) AlertManagerApiOption
providing a silence id here indicates we are updating an existing silence
func WithRequestBody ¶ added in v0.6.1
func WithRequestBody(body io.Reader) AlertManagerApiOption
func WithRetrier ¶ added in v0.6.1
func WithRetrier(retrier backoffv2.Policy) AlertManagerApiOption
func WithURLValues ¶ added in v0.6.1
func WithURLValues(values url.Values) AlertManagerApiOption
type AlertManagerApiOptions ¶ added in v0.6.1
type AlertManagerApiOptions struct {
// contains filtered or unexported fields
}
func NewDefaultAlertManagerOptions ¶ added in v0.6.1
func NewDefaultAlertManagerOptions() *AlertManagerApiOptions
type AlertStatus ¶ added in v0.6.1
type GettableAlert ¶ added in v0.6.1
type GettableAlert struct { // annotations // Required: true Annotations LabelSet `json:"annotations"` // ends at // Required: true // Format: date-time EndsAt *strfmt.DateTime `json:"endsAt"` // fingerprint // Required: true Fingerprint *string `json:"fingerprint"` // receivers // Required: true Receivers []*Receiver `json:"receivers"` // starts at // Required: true // Format: date-time StartsAt *strfmt.DateTime `json:"startsAt"` // status // Required: true Status *AlertStatus `json:"status"` // updated at // Required: true // Format: date-time UpdatedAt *strfmt.DateTime `json:"updatedAt"` Alert }
GettableAlert gettable alert
swagger:model gettableAlert
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)