client

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: Apache-2.0 Imports: 23 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 {
	MemberlistClient() MemberlistClient
	ControlClient() ControlClient
	StatusClient() StatusClient
	ConfigClient() ConfigClient
	AlertClient() AlertClient
	QueryClient() QueryClient
	SilenceClient() SilenceClient
	ProxyClient() ProxyClient
	Clone() AlertingClient
}

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 {
	*ClientOptions
	// 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(
	opts ...ClientOption,
) (*Client, error)

func (*Client) AlertClient

func (c *Client) AlertClient() AlertClient

func (*Client) Clone added in v0.12.0

func (c *Client) Clone() AlertingClient

func (*Client) ConfigClient

func (c *Client) ConfigClient() ConfigClient

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) 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) ProxyURL added in v0.12.0

func (c *Client) ProxyURL() *url.URL

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 ClientOption added in v0.12.0

type ClientOption func(*ClientOptions)

func WithAlertManagerAddress added in v0.12.0

func WithAlertManagerAddress(addr string) ClientOption

func WithProxyAddress added in v0.12.0

func WithProxyAddress(addr string) ClientOption

func WithProxyHttpClient added in v0.12.0

func WithProxyHttpClient(client http.Client) ClientOption

func WithQuerierAddress added in v0.12.0

func WithQuerierAddress(addr string) ClientOption

func WithTLSConfig added in v0.12.0

func WithTLSConfig(config *tls.Config) ClientOption

type ClientOptions added in v0.12.0

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

func DefaultOptions added in v0.12.0

func DefaultOptions() *ClientOptions

func (*ClientOptions) Apply added in v0.12.0

func (o *ClientOptions) Apply(opts ...ClientOption)

func (*ClientOptions) Validate added in v0.12.0

func (o *ClientOptions) Validate(
	proxyScheme string,
	queryScheme string,
) error

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 {
	ProxyURL() *url.URL
}

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
}

type TLSClientConfig added in v0.12.0

type TLSClientConfig struct {
	// Path to the server CA certificate.
	ServerCA string
	// Path to the client CA certificate (not needed in all cases).
	ClientCA string
	// Path to the certificate used for client-cert auth.
	ClientCert string
	// Path to the private key used for client-cert auth.
	ClientKey string
}

func (*TLSClientConfig) Init added in v0.12.0

func (t *TLSClientConfig) Init() (*tls.Config, error)

Jump to

Keyboard shortcuts

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