e2emimir

package
v0.0.0-...-f8e07d0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: AGPL-3.0 Imports: 41 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func FormatTime

func FormatTime(t time.Time) string

FormatTime converts a time to a string acceptable by the Prometheus API.

func GetDefaultEnvVariables

func GetDefaultEnvVariables() map[string]string

func GetDefaultImage

func GetDefaultImage() string

GetDefaultImage returns the Docker image to use to run Mimir.

func GetMimirtoolImage

func GetMimirtoolImage() string

func NoopFlagMapper

func NoopFlagMapper(flags map[string]string) map[string]string

NoopFlagMapper is a flag mapper that does not alter the provided flags.

Types

type ActiveSeriesOption

type ActiveSeriesOption func(*activeSeriesRequestConfig)

func WithEnableCompression

func WithEnableCompression() ActiveSeriesOption

func WithQueryShards

func WithQueryShards(n int) ActiveSeriesOption

func WithRequestMethod

func WithRequestMethod(m string) ActiveSeriesOption

type AlertGroup

type AlertGroup struct {
	Labels model.LabelSet `json:"labels"`
	Alerts []model.Alert  `json:"alerts"`
}

type Client

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

Client is a client used to interact with Mimir in integration tests

func NewClient

func NewClient(
	distributorAddress string,
	querierAddress string,
	alertmanagerAddress string,
	rulerAddress string,
	orgID string,
	opts ...ClientOption,
) (*Client, error)

NewClient makes a new Mimir client

func (*Client) ActiveNativeHistogramMetrics

func (c *Client) ActiveNativeHistogramMetrics(selector string, options ...ActiveSeriesOption) (*cardinality.ActiveNativeHistogramMetricsResponse, error)

func (*Client) ActiveSeries

func (c *Client) ActiveSeries(selector string, options ...ActiveSeriesOption) (*api.ActiveSeriesResponse, error)

func (*Client) CloseIdleConnections

func (c *Client) CloseIdleConnections()

func (*Client) CreateSilence

func (c *Client) CreateSilence(ctx context.Context, silence types.Silence) (string, error)

CreateSilence creates a new silence and returns the unique identifier of the silence.

func (*Client) DeleteAlertmanagerConfig

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

DeleteAlertmanagerConfig gets the status of an alertmanager instance

func (*Client) DeleteGrafanaAlertmanagerConfig

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

func (*Client) DeleteGrafanaAlertmanagerState

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

func (*Client) DeleteRuleGroup

func (c *Client) DeleteRuleGroup(namespace string, groupName string) error

DeleteRuleGroup deletes a rule group.

func (*Client) DeleteRuleNamespace

func (c *Client) DeleteRuleNamespace(namespace string) error

DeleteRuleNamespace deletes all the rule groups (and the namespace itself).

func (*Client) DeleteSilence

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

func (*Client) DoGet

func (c *Client) DoGet(url string) (*http.Response, error)

DoGet performs a HTTP GET request towards the supplied URL. The request contains the X-Scope-OrgID header and the timeout configured by the client object.

func (*Client) DoGetBody

func (c *Client) DoGetBody(url string) (*http.Response, []byte, error)

DoGetBody performs a HTTP GET request towards the supplied URL and returns the full response body. The request contains the X-Scope-OrgID header and the timeout configured by the client object.

func (*Client) DoPost

func (c *Client) DoPost(url string, body io.Reader) (*http.Response, error)

DoPost performs a HTTP POST request towards the supplied URL and using the given request body. The request contains the X-Scope-OrgID header and the timeout configured by the client object.

func (*Client) DoPostBody

func (c *Client) DoPostBody(url string, body io.Reader) (*http.Response, []byte, error)

DoPostBody performs a HTTP POST request towards the supplied URL and returns the full response body. The request contains the X-Scope-OrgID header and the timeout configured by the client object.

func (*Client) GetAlertGroups

func (c *Client) GetAlertGroups(ctx context.Context) ([]AlertGroup, error)

func (*Client) GetAlertmanager

func (c *Client) GetAlertmanager(ctx context.Context, path string) (string, error)

GetAlertmanager performs a GET request on a per-tenant alertmanager endpoint.

func (*Client) GetAlertmanagerConfig

func (c *Client) GetAlertmanagerConfig(ctx context.Context) (*alertConfig.Config, error)

GetAlertmanagerConfig gets the status of an alertmanager instance

func (*Client) GetAlertmanagerStatusPage

func (c *Client) GetAlertmanagerStatusPage(ctx context.Context) ([]byte, error)

GetAlertmanagerStatusPage gets the status page of alertmanager.

func (*Client) GetAlerts

func (c *Client) GetAlerts(ctx context.Context) ([]model.Alert, error)

func (*Client) GetGrafanaAlertmanagerConfig

func (c *Client) GetGrafanaAlertmanagerConfig(ctx context.Context) (*alertmanager.UserGrafanaConfig, error)

func (*Client) GetGrafanaAlertmanagerState

func (c *Client) GetGrafanaAlertmanagerState(ctx context.Context) (*alertmanager.UserGrafanaState, error)

func (*Client) GetPrometheusMetadata

func (c *Client) GetPrometheusMetadata() (*http.Response, error)

GetPrometheusMetadata fetches the metadata from the Prometheus endpoint /api/v1/metadata.

func (*Client) GetPrometheusRules

func (c *Client) GetPrometheusRules(maxGroups int, token string) ([]*promv1.RuleGroup, string, error)

GetPrometheusRules fetches the rules from the Prometheus endpoint /api/v1/rules.

func (*Client) GetReceivers

func (c *Client) GetReceivers(ctx context.Context) ([]string, error)

func (*Client) GetReceiversExperimental

func (c *Client) GetReceiversExperimental(ctx context.Context) ([]alertingmodels.Receiver, error)

func (*Client) GetRuleGroup

func (c *Client) GetRuleGroup(namespace string, groupName string) (*http.Response, error)

GetRuleGroup gets a rule group.

func (*Client) GetRuleGroups

func (c *Client) GetRuleGroups() (*http.Response, map[string][]rulefmt.RuleGroup, error)

GetRuleGroups gets the configured rule groups from the ruler.

func (*Client) GetSilence

func (c *Client) GetSilence(ctx context.Context, id string) (types.Silence, error)

func (*Client) GetSilences

func (c *Client) GetSilences(ctx context.Context) ([]types.Silence, error)

func (*Client) LabelNames

func (c *Client) LabelNames(start, end time.Time, matches []string, opts ...promv1.Option) ([]string, error)

LabelNames gets label names

func (*Client) LabelNamesAndValues

func (c *Client) LabelNamesAndValues(selector string, limit int) (*api.LabelNamesCardinalityResponse, error)

LabelNamesAndValues returns distinct label values per label name.

func (*Client) LabelValues

func (c *Client) LabelValues(label string, start, end time.Time, matches []string, opts ...promv1.Option) (model.LabelValues, error)

LabelValues gets label values

func (*Client) LabelValuesCardinality

func (c *Client) LabelValuesCardinality(labelNames []string, selector string, limit int) (*api.LabelValuesCardinalityResponse, error)

LabelValuesCardinality returns all values and series total count for each label name.

func (*Client) PostAlertmanager

func (c *Client) PostAlertmanager(ctx context.Context, path string) error

PostAlertmanager performs a POST request on a per-tenant alertmanager endpoint.

func (*Client) Push

func (c *Client) Push(timeseries []prompb.TimeSeries) (*http.Response, error)

Push the input timeseries to the remote endpoint

func (*Client) PushOTLP

func (c *Client) PushOTLP(timeseries []prompb.TimeSeries, metadata []mimirpb.MetricMetadata) (*http.Response, error)

PushOTLP the input timeseries to the remote endpoint in OTLP format

func (*Client) QuerierAddress

func (c *Client) QuerierAddress() string

QuerierAddress returns the address of the querier

func (*Client) Query

func (c *Client) Query(query string, ts time.Time) (model.Value, error)

Query runs an instant query.

func (*Client) QueryExemplars

func (c *Client) QueryExemplars(query string, start, end time.Time) ([]promv1.ExemplarQueryResult, error)

QueryExemplars runs an exemplar query.

func (*Client) QueryRange

func (c *Client) QueryRange(query string, start, end time.Time, step time.Duration) (model.Value, error)

Query runs a query range.

func (*Client) QueryRangeRaw

func (c *Client) QueryRangeRaw(query string, start, end time.Time, step time.Duration) (*http.Response, []byte, error)

QueryRangeRaw runs a ranged query directly against the querier API.

func (*Client) QueryRaw

func (c *Client) QueryRaw(query string) (*http.Response, []byte, error)

QueryRaw runs a query directly against the querier API.

func (*Client) QueryRawAt

func (c *Client) QueryRawAt(query string, ts time.Time) (*http.Response, []byte, error)

func (*Client) RemoteRead

func (c *Client) RemoteRead(query *prompb.Query) (_ *http.Response, _ *prompb.QueryResult, plaintextResponse []byte, _ error)

RemoteRead runs a remote read query against the querier. RemoteRead uses samples streaming. See RemoteReadChunks as well for chunks streaming. RemoteRead returns the HTTP response with consumed body, the remote read protobuf response and an error. In case the response is not a protobuf, the plaintext body content is returned instead of the protobuf message.

func (*Client) RemoteReadChunks

func (c *Client) RemoteReadChunks(query *prompb.Query) (_ *http.Response, _ []prompb.ChunkedReadResponse, plaintextResponse []byte, _ error)

RemoteReadChunks runs a remote read query against the querier. RemoteReadChunks uses chunks streaming. See RemoteRead as well for samples streaming. RemoteReadChunks returns the HTTP response with consumed body, the remote read protobuf response and an error. In case the response is not a protobuf, the plaintext body content is returned instead of the protobuf message.

func (*Client) SendAlertToAlermanager

func (c *Client) SendAlertToAlermanager(ctx context.Context, alert *model.Alert) error

SendAlertToAlermanager sends alerts to the Alertmanager API

func (*Client) Series

func (c *Client) Series(matches []string, start, end time.Time, opts ...promv1.Option) ([]model.LabelSet, error)

Series finds series by label matchers.

func (*Client) SetAlertmanagerConfig

func (c *Client) SetAlertmanagerConfig(ctx context.Context, amConfig string, templates map[string]string) error

SetAlertmanagerConfig gets the status of an alertmanager instance

func (*Client) SetGrafanaAlertmanagerConfig

func (c *Client) SetGrafanaAlertmanagerConfig(ctx context.Context, createdAtTimestamp int64, cfg, hash, externalURL string, isDefault, isPromoted bool, staticHeaders map[string]string) error

func (*Client) SetGrafanaAlertmanagerState

func (c *Client) SetGrafanaAlertmanagerState(ctx context.Context, state string) error

func (*Client) SetRuleGroup

func (c *Client) SetRuleGroup(rulegroup rulefmt.RuleGroup, namespace string) error

SetRuleGroup configures the provided rulegroup to the ruler.

func (*Client) SetTimeout

func (c *Client) SetTimeout(t time.Duration)

type ClientOption

type ClientOption func(*clientConfig)

func WithAddHeader

func WithAddHeader(key, value string) ClientOption

func WithTripperware

func WithTripperware(wrap querymiddleware.Tripperware) ClientOption

type CompositeMimirService

type CompositeMimirService struct {
	*e2e.CompositeHTTPService
}

CompositeMimirService abstract an higher-level service composed, under the hood, by 2+ MimirService.

func NewCompositeMimirService

func NewCompositeMimirService(services ...*MimirService) *CompositeMimirService

type FlagMapper

type FlagMapper func(flags map[string]string) map[string]string

FlagMapper is the type of function that maps flags, just to reduce some verbosity.

func ChainFlagMappers

func ChainFlagMappers(mappers ...FlagMapper) FlagMapper

ChainFlagMappers chains multiple flag mappers, each flag mapper gets a copy of the flags so it can safely modify the values. ChainFlagMappers(a, b)(flags) == b(copy(a(copy(flags)

func RemoveFlagMapper

func RemoveFlagMapper(toRemove []string) FlagMapper

RemoveFlagMapper builds a flag mapper that remove flags.

func RenameFlagMapper

func RenameFlagMapper(fromTo map[string]string) FlagMapper

RenameFlagMapper builds a flag mapper that renames flags.

func SetFlagMapper

func SetFlagMapper(set map[string]string) FlagMapper

SetFlagMapper builds a flag mapper that sets the provided flags.

func (*FlagMapper) UnmarshalJSON

func (fm *FlagMapper) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a single json object into a single FlagMapper, or an array into a ChainMapper.

type MimirService

type MimirService struct {
	*e2e.HTTPService
	// contains filtered or unexported fields
}

MimirService represents a Mimir service with at least an HTTP and GRPC port exposed.

func NewAlertmanager

func NewAlertmanager(name string, flags map[string]string, options ...Option) *MimirService

func NewAlertmanagerWithTLS

func NewAlertmanagerWithTLS(name string, flags map[string]string, options ...Option) *MimirService

func NewBackendInstance

func NewBackendInstance(name string, flags map[string]string, options ...Option) *MimirService

func NewCompactor

func NewCompactor(name string, consulAddress string, flags map[string]string, options ...Option) *MimirService

func NewDistributor

func NewDistributor(name string, consulAddress string, flags map[string]string, options ...Option) *MimirService

func NewIngester

func NewIngester(name string, consulAddress string, flags map[string]string, options ...Option) *MimirService

func NewMimirService

func NewMimirService(
	name string,
	image string,
	command *e2e.Command,
	readiness e2e.ReadinessProbe,
	envVars map[string]string,
	httpPort int,
	grpcPort int,
	otherPorts ...int,
) *MimirService

func NewOverridesExporter

func NewOverridesExporter(name string, consulAddress string, flags map[string]string, options ...Option) *MimirService

func NewQuerier

func NewQuerier(name string, consulAddress string, flags map[string]string, options ...Option) *MimirService

func NewQueryFrontend

func NewQueryFrontend(name string, consulAddress string, flags map[string]string, options ...Option) *MimirService

NewQueryFrontend returns a new query-frontend instance. The consulAddress is required to be a valid consul address when Mimir is configured with ingest storage enabled, otherwise it's ignored.

func NewQueryScheduler

func NewQueryScheduler(name string, flags map[string]string, options ...Option) *MimirService

func NewReadInstance

func NewReadInstance(name string, flags map[string]string, options ...Option) *MimirService

func NewRuler

func NewRuler(name string, consulAddress string, flags map[string]string, options ...Option) *MimirService

func NewSingleBinary

func NewSingleBinary(name string, flags map[string]string, options ...Option) *MimirService

func NewStoreGateway

func NewStoreGateway(name string, consulAddress string, flags map[string]string, options ...Option) *MimirService

func NewWriteInstance

func NewWriteInstance(name string, flags map[string]string, options ...Option) *MimirService

func (*MimirService) NetworkGRPCEndpoint

func (s *MimirService) NetworkGRPCEndpoint() string

type Option

type Option func(*Options)

Option modifies options.

func WithConfigFile

func WithConfigFile(configFile string) Option

WithConfigFile returns an option that sets the config file flag if the provided string is not empty.

func WithFlagMapper

func WithFlagMapper(mapFlags FlagMapper) Option

WithFlagMapper creates an option that sets a FlagMapper. Multiple flag mappers can be set, each one maps the output of the previous one. Flag mappers added using this option act on a copy of the flags, so they don't alter the input.

func WithImage

func WithImage(image string) Option

WithImage creates an option that overrides the image of the service.

func WithNoopOption

func WithNoopOption() Option

WithNoopOption returns an option that doesn't change anything.

func WithOtherPorts

func WithOtherPorts(ports ...int) Option

WithOtherPorts creates an option that adds other ports to the service.

func WithPorts

func WithPorts(http, grpc int) Option

WithPorts creats an option that overrides the HTTP and gRPC ports.

type Options

type Options struct {
	Image       string
	MapFlags    FlagMapper
	OtherPorts  []int
	HTTPPort    int
	GRPCPort    int
	Environment map[string]string
}

Options holds a set of options for running services, they can be altered passing Option funcs.

type S3Client

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

func NewS3Client

func NewS3Client(cfg s3.Config) (*S3Client, error)

func NewS3ClientForMinio

func NewS3ClientForMinio(minio *e2e.HTTPService, bucketName string) (*S3Client, error)

func (*S3Client) Delete

func (c *S3Client) Delete(prefix string) error

Delete recursively deletes every object within the input prefix.

func (*S3Client) DeleteBlock

func (c *S3Client) DeleteBlock(userID, blockID string) error

DeleteBlock deletes a single block.

func (*S3Client) DeleteBlocks

func (c *S3Client) DeleteBlocks(userID string) error

DeleteBlocks deletes all blocks for a tenant.

type ServerStatus

type ServerStatus struct {
	Config struct {
		Original string `json:"original"`
	} `json:"config"`
}

ServerStatus represents a Alertmanager status response TODO: Upgrade to Alertmanager v0.20.0+ and utilize vendored structs

Jump to

Keyboard shortcuts

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