client

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alertmanager

type Alertmanager struct {
	*amclient.AlertmanagerAPI
	// contains filtered or unexported fields
}

func NewAlertmanager

func NewAlertmanager(cfg *AlertmanagerConfig, metrics *metrics.RemoteAlertmanager) (*Alertmanager, error)

func (*Alertmanager) GetAuthedClient

func (am *Alertmanager) GetAuthedClient() client.Requester

GetAuthedClient returns a client.Requester that includes a configured MimirAuthRoundTripper. Requests using this client are fully authenticated.

func (*Alertmanager) IsReadyWithBackoff

func (am *Alertmanager) IsReadyWithBackoff(ctx context.Context) (bool, error)

IsReadyWithBackoff executes a readiness check against the `/-/ready` Alertmanager endpoint. If it takes more than 10s to get a response back - we abort the check.

type AlertmanagerConfig

type AlertmanagerConfig struct {
	TenantID string
	Password string
	URL      *url.URL
	Logger   log.Logger
}

type Config

type Config struct {
	URL      *url.URL
	TenantID string
	Password string

	Logger        log.Logger
	PromoteConfig bool
}

type Mimir

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

func New

func New(cfg *Config, metrics *metrics.RemoteAlertmanager) (*Mimir, error)

func (*Mimir) CreateGrafanaAlertmanagerConfig

func (mc *Mimir) CreateGrafanaAlertmanagerConfig(ctx context.Context, cfg *apimodels.PostableUserConfig, hash string, createdAt int64, isDefault bool) error

func (*Mimir) CreateGrafanaAlertmanagerState

func (mc *Mimir) CreateGrafanaAlertmanagerState(ctx context.Context, state string) error

func (*Mimir) DeleteGrafanaAlertmanagerConfig

func (mc *Mimir) DeleteGrafanaAlertmanagerConfig(ctx context.Context) error

func (*Mimir) DeleteGrafanaAlertmanagerState

func (mc *Mimir) DeleteGrafanaAlertmanagerState(ctx context.Context) error

func (*Mimir) GetGrafanaAlertmanagerConfig

func (mc *Mimir) GetGrafanaAlertmanagerConfig(ctx context.Context) (*UserGrafanaConfig, error)

func (*Mimir) GetGrafanaAlertmanagerState

func (mc *Mimir) GetGrafanaAlertmanagerState(ctx context.Context) (*UserGrafanaState, error)

func (*Mimir) ShouldPromoteConfig

func (mc *Mimir) ShouldPromoteConfig() bool

type MimirAuthRoundTripper

type MimirAuthRoundTripper struct {
	TenantID string
	Password string
	Next     http.RoundTripper
}

func (*MimirAuthRoundTripper) RoundTrip

func (r *MimirAuthRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper interface It adds an `X-Scope-OrgID` header with the TenantID if only provided with a tenantID or sets HTTP Basic Authentication if both a tenantID and a password are provided.

type MimirClient

type MimirClient interface {
	GetGrafanaAlertmanagerState(ctx context.Context) (*UserGrafanaState, error)
	CreateGrafanaAlertmanagerState(ctx context.Context, state string) error
	DeleteGrafanaAlertmanagerState(ctx context.Context) error

	GetGrafanaAlertmanagerConfig(ctx context.Context) (*UserGrafanaConfig, error)
	CreateGrafanaAlertmanagerConfig(ctx context.Context, configuration *apimodels.PostableUserConfig, hash string, createdAt int64, isDefault bool) error
	DeleteGrafanaAlertmanagerConfig(ctx context.Context) error

	ShouldPromoteConfig() bool
}

MimirClient contains all the methods to query the migration critical endpoints of Mimir instance, it's an interface to allow multiple implementations.

type UserGrafanaConfig

type UserGrafanaConfig struct {
	GrafanaAlertmanagerConfig *apimodels.PostableUserConfig `json:"configuration"`
	Hash                      string                        `json:"configuration_hash"`
	CreatedAt                 int64                         `json:"created"`
	Default                   bool                          `json:"default"`
	Promoted                  bool                          `json:"promoted"`
}

type UserGrafanaState

type UserGrafanaState struct {
	State string `json:"state"`
}

Jump to

Keyboard shortcuts

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