e2ecortex

package
v1.22.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GossipPort = 9094
)

Variables

View Source
var DefaultFilter = RuleFilter{}
View Source
var ErrNotFound = errors.New("not found")

Functions

func FormatTime added in v1.4.0

func FormatTime(t time.Time) string

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

func GetDefaultImage

func GetDefaultImage() string

GetDefaultImage returns the Docker image to use to run Cortex.

Types

type AlertGroup added in v1.9.0

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 Cortex in integration tests

func NewClient

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

NewClient makes a new Cortex client

func NewPromQueryClient added in v1.17.0

func NewPromQueryClient(address string) (*Client, error)

NewPromQueryClient makes a new client but used for Prometheus Query only.

func (*Client) AllUserStats added in v1.20.0

func (c *Client) AllUserStats() ([]ingester.UserIDStats, error)

func (*Client) CreateSilence added in v1.9.0

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

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

func (*Client) DeleteAlertmanagerConfig added in v1.3.0

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

DeleteAlertmanagerConfig gets the status of an alertmanager instance

func (*Client) DeleteRuleGroup added in v1.0.0

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

DeleteRuleGroup deletes a rule group.

func (*Client) DeleteRuleNamespace added in v1.4.0

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

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

func (*Client) DeleteSilence added in v1.9.0

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

func (*Client) GetAlertGroups added in v1.9.0

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

func (*Client) GetAlertmanagerConfig

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

GetAlertmanagerConfig gets the status of an alertmanager instance

func (*Client) GetAlertmanagerStatusPage added in v1.10.0

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

GetAlertmanagerStatusPage gets the status page of alertmanager.

func (*Client) GetAlertsV2 added in v1.10.0

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

func (*Client) GetPrometheusRules added in v1.9.0

func (c *Client) GetPrometheusRules(filter RuleFilter) ([]*ruler.RuleGroup, string, error)

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

func (*Client) GetReceivers added in v1.9.0

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

func (*Client) GetRuleGroup added in v1.9.0

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

GetRuleGroup gets a rule group.

func (*Client) GetRuleGroups added in v1.0.0

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

GetRuleGroups gets the configured rule groups from the ruler.

func (*Client) GetSilenceV2 added in v1.10.0

func (c *Client) GetSilenceV2(ctx context.Context, id string) (open_api_models.GettableSilence, error)

func (*Client) GetSilencesV2 added in v1.10.0

func (c *Client) GetSilencesV2(ctx context.Context) ([]open_api_models.GettableSilence, error)

func (*Client) LabelNames added in v1.1.0

func (c *Client) LabelNames(start, end time.Time, matchers ...string) ([]string, error)

LabelNames gets label names

func (*Client) LabelNamesRaw added in v1.15.1

func (c *Client) LabelNamesRaw(matches []string, startTime, endTime time.Time, headers map[string]string) (*http.Response, []byte, error)

LabelNamesRaw runs a label names request directly against the querier API.

func (*Client) LabelValues added in v1.1.0

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

LabelValues gets label values

func (*Client) LabelValuesRaw added in v1.15.1

func (c *Client) LabelValuesRaw(label string, matches []string, startTime, endTime time.Time, headers map[string]string) (*http.Response, []byte, error)

LabelValuesRaw runs a label values request directly against the querier API.

func (*Client) Metadata added in v1.20.0

func (c *Client) Metadata(name, limit string) (map[string][]promv1.Metadata, error)

Metadata runs a metadata query

func (*Client) OTLP added in v1.17.0

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

Push series to OTLP endpoint

func (*Client) OTLPPushExemplar added in v1.19.0

func (c *Client) OTLPPushExemplar(name, unit string, temporality pmetric.AggregationTemporality, labels ...prompb.Label) (*http.Response, error)

func (*Client) PostRequest added in v1.4.0

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

func (*Client) Push

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

Push the input timeseries to the remote endpoint

func (*Client) PushV2 added in v1.20.0

func (c *Client) PushV2(symbols []string, timeseries []writev2.TimeSeries) (remoteapi.WriteResponseStats, error)

PushV2 the input timeseries to the remote endpoint

func (*Client) Query

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

Query runs an instant query.

func (*Client) QueryExemplars added in v1.19.0

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

QueryExemplars runs an exemplars query

func (*Client) QueryRange added in v1.4.0

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

QueryRange runs a query range.

func (*Client) QueryRangeRaw added in v1.4.0

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

QueryRangeRaw runs a ranged query directly against the querier API.

func (*Client) QueryRaw added in v1.2.0

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

QueryRaw runs a query directly against the querier API.

func (*Client) RemoteRead added in v1.15.0

func (c *Client) RemoteRead(matchers []*labels.Matcher, start, end time.Time, step time.Duration) (*prompb.ReadResponse, error)

RemoteRead runs a remote read query.

func (*Client) SendAlertToAlermanager added in v1.4.0

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

SendAlertToAlermanager sends alerts to the Alertmanager API

func (*Client) Series added in v1.3.0

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

Series finds series by label matchers.

func (*Client) SeriesRaw added in v1.15.1

func (c *Client) SeriesRaw(matches []string, startTime, endTime time.Time, headers map[string]string) (*http.Response, []byte, error)

SeriesRaw runs a series request directly against the querier API.

func (*Client) SetAlertmanagerConfig added in v1.3.0

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

SetAlertmanagerConfig gets the status of an alertmanager instance

func (*Client) SetRuleGroup added in v1.0.0

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

SetRuleGroup configures the provided rulegroup to the ruler.

type CompositeCortexService added in v1.1.0

type CompositeCortexService struct {
	*e2e.CompositeHTTPService
}

CompositeCortexService abstract an higher-level service composed, under the hood, by 2+ CortexService.

func NewCompositeCortexService added in v1.1.0

func NewCompositeCortexService(services ...*CortexService) *CompositeCortexService

type ConfigsClient

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

ConfigsClient drives the configs API (target=configs). It is intentionally separate from Client because the configs service is a distinct deployment with its own URL and an alertmanager_config endpoint that would otherwise collide with the multitenant alertmanager helpers on Client.

func NewConfigsClient

func NewConfigsClient(endpoint, orgID string) *ConfigsClient

NewConfigsClient builds a client for the configs API hosted at endpoint (e.g. "127.0.0.1:1234"). orgID may be empty for endpoints that don't require tenant authentication (e.g. the private/admin routes).

func (*ConfigsClient) GetAlertmanagerConfig

func (c *ConfigsClient) GetAlertmanagerConfig(ctx context.Context) (*userconfig.View, int, error)

GetAlertmanagerConfig fetches the alertmanager config for the client's tenant. Named to avoid colliding with Client.GetAlertmanagerConfig, which targets the multitenant alertmanager service rather than the configs service.

func (*ConfigsClient) GetAllRulesConfigs

func (c *ConfigsClient) GetAllRulesConfigs(ctx context.Context) (map[string]userconfig.View, int, error)

GetAllRulesConfigs hits the admin endpoint that returns every tenant's newest rules config keyed by tenant ID.

func (*ConfigsClient) GetAllRulesConfigsSince

func (c *ConfigsClient) GetAllRulesConfigsSince(ctx context.Context, since userconfig.ID) (map[string]userconfig.View, int, error)

GetAllRulesConfigsSince hits the admin endpoint with a ?since=<id> filter, returning only configs whose version ID is greater than since.

func (*ConfigsClient) GetRulesConfig

func (c *ConfigsClient) GetRulesConfig(ctx context.Context) (*userconfig.View, int, error)

GetRulesConfig fetches the rules config for the client's tenant.

func (*ConfigsClient) PostAlertmanagerConfig

func (c *ConfigsClient) PostAlertmanagerConfig(ctx context.Context, cfg userconfig.Config) (int, []byte, error)

PostAlertmanagerConfig stores a new version of the alertmanager config for the client's tenant. It returns the HTTP status code and response body (see PostRulesConfig).

func (*ConfigsClient) PostRulesConfig

func (c *ConfigsClient) PostRulesConfig(ctx context.Context, cfg userconfig.Config) (int, []byte, error)

PostRulesConfig stores a new version of the rules config for the client's tenant. It returns the HTTP status code and response body so callers can assert on the status and surface the body for debugging on unexpected responses.

type ConfigsView

type ConfigsView struct {
	Configs map[string]userconfig.View `json:"configs"`
}

ConfigsView mirrors api.ConfigsView for unmarshaling the /private endpoint response. Duplicated here so the integration package doesn't pull in pkg/configs/api just for a struct.

type CortexService

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

CortexService represents a Cortex service with at least an HTTP and GRPC port exposed.

func NewAlertmanager

func NewAlertmanager(name string, flags map[string]string, image string) *CortexService

func NewAlertmanagerWithTLS added in v1.8.0

func NewAlertmanagerWithTLS(name string, flags map[string]string, image string) *CortexService

func NewCompactor added in v1.7.0

func NewCompactor(name string, consulAddress string, flags map[string]string, image string) *CortexService

func NewCompactorWithConfigFile added in v1.7.0

func NewCompactorWithConfigFile(name, consulAddress, configFile string, flags map[string]string, image string) *CortexService

func NewConfigs

func NewConfigs(name string, flags map[string]string, image string) *CortexService

func NewCortexService

func NewCortexService(
	name string,
	image string,
	command *e2e.Command,
	readiness e2e.ReadinessProbe,
	httpPort int,
	grpcPort int,
	otherPorts ...int,
) *CortexService

func NewDistributor

func NewDistributor(name string, store RingStore, address string, flags map[string]string, image string) *CortexService

func NewDistributorWithConfigFile

func NewDistributorWithConfigFile(name string, store RingStore, address, configFile string, flags map[string]string, image string) *CortexService

func NewIngester

func NewIngester(name string, store RingStore, address string, flags map[string]string, image string) *CortexService

func NewIngesterWithConfigFile

func NewIngesterWithConfigFile(name string, store RingStore, address, configFile string, flags map[string]string, image string) *CortexService

func NewParquetConverter added in v1.21.0

func NewParquetConverter(name string, store RingStore, address string, flags map[string]string, image string) *CortexService

func NewParquetConverterWithConfigFile added in v1.21.0

func NewParquetConverterWithConfigFile(name string, store RingStore, address, configFile string, flags map[string]string, image string) *CortexService

func NewQuerier

func NewQuerier(name string, store RingStore, address string, flags map[string]string, image string) *CortexService

func NewQuerierWithConfigFile

func NewQuerierWithConfigFile(name string, store RingStore, address, configFile string, flags map[string]string, image string) *CortexService

func NewQueryFrontend

func NewQueryFrontend(name string, flags map[string]string, image string) *CortexService

func NewQueryFrontendWithConfigFile

func NewQueryFrontendWithConfigFile(name, configFile string, flags map[string]string, image string) *CortexService

func NewQueryScheduler added in v1.6.0

func NewQueryScheduler(name string, flags map[string]string, image string) *CortexService

func NewQuerySchedulerWithConfigFile added in v1.6.0

func NewQuerySchedulerWithConfigFile(name, configFile string, flags map[string]string, image string) *CortexService

func NewRuler added in v1.0.0

func NewRuler(name string, consulAddress string, flags map[string]string, image string) *CortexService

func NewSingleBinary

func NewSingleBinary(name string, flags map[string]string, image string, otherPorts ...int) *CortexService

func NewSingleBinaryWithConfigFile added in v1.1.0

func NewSingleBinaryWithConfigFile(name string, configFile string, flags map[string]string, image string, httpPort, grpcPort int, otherPorts ...int) *CortexService

func NewStoreGateway added in v1.1.0

func NewStoreGateway(name string, store RingStore, address string, flags map[string]string, image string) *CortexService

func NewStoreGatewayWithConfigFile added in v1.1.0

func NewStoreGatewayWithConfigFile(name string, store RingStore, address string, configFile string, flags map[string]string, image string) *CortexService

func (*CortexService) GRPCEndpoint

func (s *CortexService) GRPCEndpoint() string

func (*CortexService) NetworkGRPCEndpoint

func (s *CortexService) NetworkGRPCEndpoint() string

type RingStore added in v1.13.0

type RingStore string
const (
	RingStoreConsul RingStore = "consul"
	RingStoreEtcd   RingStore = "etcd"
)

type RuleFilter added in v1.16.0

type RuleFilter struct {
	Namespaces     []string
	RuleGroupNames []string
	RuleNames      []string
	RuleType       string
	ExcludeAlerts  string
	MaxRuleGroup   int
	NextToken      string
}

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.

func (*S3Client) GetBucket added in v1.17.0

func (c *S3Client) GetBucket() objstore.Bucket

type ServerStatus

type ServerStatus struct {
	Data struct {
		ConfigYaml string `json:"configYAML"`
	} `json:"data"`
}

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