client

package
v0.11.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtMostOne

func AtMostOne[Resp any](ctx context.Context, client *http.Client, reqs []*http.Request) (*Resp, error)

func ToOpenApiTime

func ToOpenApiTime(t time.Time) strfmt.DateTime

Types

type AlertClient

type AlertClient interface {
	ListAlerts(ctx context.Context) (alertmanagerv2.AlertGroups, error)
	GetAlert(ctx context.Context, labels []*labels.Matcher) (alertmanagerv2.GettableAlerts, error)
	PostAlarm(ctx context.Context, obj AlertObject) error
	PostNotification(ctx context.Context, obj AlertObject) error
	ResolveAlert(ctx context.Context, obj AlertObject) error
}

type AlertObject

type AlertObject struct {
	Id          string
	Labels      map[string]string
	Annotations map[string]string
}

func (*AlertObject) Validate

func (a *AlertObject) Validate() error

type AlertingClient

type AlertingClient interface {
	ConfigureHttp(mutateFn func(*http.Client))
	MemberlistClient() MemberlistClient
	ControlClient() ControlClient
	StatusClient() StatusClient
	ConfigClient() ConfigClient
	AlertClient() AlertClient
	QueryClient() QueryClient
	SilenceClient() SilenceClient
	ProxyClient() ProxyClient
}

A typical HA setup of prometheus operator assumes that alert sources (in particular Prometheus), triggers api calls to all known peers and alert status & deduplication will be handled by its memberlisted nflog.

In our alerting client abstraction

type AlertingPeer

type AlertingPeer struct {
	ApiAddress      string
	EmbeddedAddress string
}

type Client

type Client struct {
	*http.Client
	// contains filtered or unexported fields
}

A typical HA setup of prometheus operator assumes that alert sources (in particular Prometheus), triggers api calls to all known peers and alert status & deduplication will be handled by its memberlisted nflog.

func NewClient

func NewClient(
	httpClient *http.Client,
	alertmanagerAddress string,
	querierAddress string,
) *Client

func (*Client) AlertClient

func (c *Client) AlertClient() AlertClient

func (*Client) ConfigClient

func (c *Client) ConfigClient() ConfigClient

func (*Client) ConfigureHttp

func (c *Client) ConfigureHttp(mutateFn func(*http.Client))

func (*Client) ControlClient

func (c *Client) ControlClient() ControlClient

func (*Client) DeleteSilence

func (c *Client) DeleteSilence(ctx context.Context, silenceId string) error

func (*Client) GetAlert

func (c *Client) GetAlert(ctx context.Context, matchLabels []*labels.Matcher) (alertmanagerv2.GettableAlerts, error)

func (*Client) GetReceiver

func (c *Client) GetReceiver(ctx context.Context, id string) (alertmanagerv2.Receiver, error)

func (*Client) GetSilence

func (c *Client) GetSilence(ctx context.Context, matchers labels.Matchers) (alertmanagerv2.GettableSilences, error)

func (*Client) Handle

func (c *Client) Handle(ctx context.Context, req *http.Request) (*http.Response, error)

func (*Client) ListAlarmMessages

func (*Client) ListAlerts

func (c *Client) ListAlerts(ctx context.Context) (alertmanagerv2.AlertGroups, error)

func (*Client) ListNotificationMessages

func (c *Client) ListNotificationMessages(
	ctx context.Context,
	listReq *alertingv1.ListNotificationRequest,
) (*alertingv1.ListMessageResponse, error)

func (*Client) ListReceivers

func (c *Client) ListReceivers(ctx context.Context) (recvs []alertmanagerv2.Receiver, err error)

func (*Client) ListSilences

func (c *Client) ListSilences(ctx context.Context) (alertmanagerv2.GettableSilences, error)

func (*Client) MemberPeers

func (c *Client) MemberPeers() []AlertingPeer

func (*Client) MemberlistClient

func (c *Client) MemberlistClient() MemberlistClient

func (*Client) PostAlarm

func (c *Client) PostAlarm(
	ctx context.Context,
	alarm AlertObject,
) error

func (*Client) PostNotification

func (c *Client) PostNotification(
	ctx context.Context,
	notification AlertObject,
) error

func (*Client) PostSilence

func (c *Client) PostSilence(ctx context.Context, alertingObjectId string, dur time.Duration, incomingSilenceId *string) (silenceId string, err error)

func (*Client) ProxyClient

func (c *Client) ProxyClient() ProxyClient

func (*Client) QueryClient

func (c *Client) QueryClient() QueryClient

func (*Client) Ready

func (c *Client) Ready(ctx context.Context) error

func (*Client) Reload

func (c *Client) Reload(ctx context.Context) error

func (*Client) ResolveAlert

func (c *Client) ResolveAlert(ctx context.Context, alertObject AlertObject) error

func (*Client) SetKnownPeers

func (c *Client) SetKnownPeers(peers []AlertingPeer)

func (*Client) SilenceClient

func (c *Client) SilenceClient() SilenceClient

func (*Client) Status

func (*Client) StatusClient

func (c *Client) StatusClient() StatusClient

type ConfigClient

type ConfigClient interface {
	GetReceiver(ctx context.Context, id string) (alertmanagerv2.Receiver, error)
	ListReceivers(ctx context.Context) ([]alertmanagerv2.Receiver, error)
}

type ControlClient

type ControlClient interface {
	Reload(ctx context.Context) error
}

type MemberlistClient

type MemberlistClient interface {
	MemberPeers() []AlertingPeer
	// Service Discovery for alerting api clients is delegated
	// to an external mechanism, such as cluster drivers
	SetKnownPeers(peers []AlertingPeer)
}

type ProxyClient

type ProxyClient interface {
	Handle(ctx context.Context, req *http.Request) (*http.Response, error)
}

type SilenceClient

type SilenceClient interface {
	ListSilences(ctx context.Context) (alertmanagerv2.GettableSilences, error)
	PostSilence(
		ctx context.Context,
		alarmId string,
		dur time.Duration,
		incomingSilenceId *string,
	) (silenceId string, err error)
	DeleteSilence(
		ctx context.Context,
		silenceId string,
	) error
}

type StatusClient

type StatusClient interface {
	Status(ctx context.Context) ([]alertmanagerv2.AlertmanagerStatus, error)
	Ready(ctx context.Context) error
}

Jump to

Keyboard shortcuts

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