Documentation ¶
Index ¶
- Constants
- Variables
- func ValidateLabels(cfg LabelValidationConfig, userID string, ls []client.LabelAdapter) error
- func ValidateSample(cfg SampleValidationConfig, userID string, metricName string, s client.Sample) error
- type LabelValidationConfig
- type Limits
- type Overrides
- func (o *Overrides) AcceptHASamples(userID string) bool
- func (o *Overrides) CardinalityLimit(userID string) int
- func (o *Overrides) CreationGracePeriod(userID string) time.Duration
- func (o *Overrides) EnforceMetricName(userID string) bool
- func (o *Overrides) HAClusterLabel(userID string) string
- func (o *Overrides) HAReplicaLabel(userID string) string
- func (o *Overrides) IngestionBurstSize(userID string) int
- func (o *Overrides) IngestionRate(userID string) float64
- func (o *Overrides) MaxChunksPerQuery(userID string) int
- func (o *Overrides) MaxLabelNameLength(userID string) int
- func (o *Overrides) MaxLabelNamesPerSeries(userID string) int
- func (o *Overrides) MaxLabelValueLength(userID string) int
- func (o *Overrides) MaxQueryLength(userID string) time.Duration
- func (o *Overrides) MaxQueryParallelism(userID string) int
- func (o *Overrides) MaxSamplesPerQuery(userID string) int
- func (o *Overrides) MaxSeriesPerMetric(userID string) int
- func (o *Overrides) MaxSeriesPerQuery(userID string) int
- func (o *Overrides) MaxSeriesPerUser(userID string) int
- func (o *Overrides) MinChunkLength(userID string) int
- func (o *Overrides) RejectOldSamples(userID string) bool
- func (o *Overrides) RejectOldSamplesMaxAge(userID string) time.Duration
- func (o *Overrides) Stop()
- type OverridesLoader
- type OverridesManager
- type OverridesManagerConfig
- type SampleValidationConfig
Constants ¶
const ( // ErrQueryTooLong is used in chunk store and query frontend. ErrQueryTooLong = "invalid query, length > limit (%s > %s)" // RateLimited is one of the values for the reason to discard samples. // Declared here to avoid duplication in ingester and distributor. RateLimited = "rate_limited" )
Variables ¶
var DiscardedSamples = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "cortex_discarded_samples_total", Help: "The total number of samples that were discarded.", }, []string{discardReasonLabel, "user"}, )
DiscardedSamples is a metric of the number of discarded samples, by reason.
Functions ¶
func ValidateLabels ¶
func ValidateLabels(cfg LabelValidationConfig, userID string, ls []client.LabelAdapter) error
ValidateLabels returns an err if the labels are invalid.
func ValidateSample ¶
func ValidateSample(cfg SampleValidationConfig, userID string, metricName string, s client.Sample) error
ValidateSample returns an err if the sample is invalid.
Types ¶
type LabelValidationConfig ¶
type LabelValidationConfig interface { EnforceMetricName(userID string) bool MaxLabelNamesPerSeries(userID string) int MaxLabelNameLength(userID string) int MaxLabelValueLength(userID string) int }
LabelValidationConfig helps with getting required config to validate labels.
type Limits ¶
type Limits struct { // Distributor enforced limits. IngestionRate float64 `yaml:"ingestion_rate"` IngestionBurstSize int `yaml:"ingestion_burst_size"` AcceptHASamples bool `yaml:"accept_ha_samples"` HAClusterLabel string `yaml:"ha_cluster_label"` HAReplicaLabel string `yaml:"ha_replica_label"` MaxLabelNameLength int `yaml:"max_label_name_length"` MaxLabelValueLength int `yaml:"max_label_value_length"` MaxLabelNamesPerSeries int `yaml:"max_label_names_per_series"` RejectOldSamples bool `yaml:"reject_old_samples"` RejectOldSamplesMaxAge time.Duration `yaml:"reject_old_samples_max_age"` CreationGracePeriod time.Duration `yaml:"creation_grace_period"` EnforceMetricName bool `yaml:"enforce_metric_name"` // Ingester enforced limits. MaxSeriesPerQuery int `yaml:"max_series_per_query"` MaxSamplesPerQuery int `yaml:"max_samples_per_query"` MaxSeriesPerUser int `yaml:"max_series_per_user"` MaxSeriesPerMetric int `yaml:"max_series_per_metric"` MinChunkLength int `yaml:"min_chunk_length"` // Querier enforced limits. MaxChunksPerQuery int `yaml:"max_chunks_per_query"` MaxQueryLength time.Duration `yaml:"max_query_length"` MaxQueryParallelism int `yaml:"max_query_parallelism"` CardinalityLimit int `yaml:"cardinality_limit"` // Config for overrides, convenient if it goes here. PerTenantOverrideConfig string `yaml:"per_tenant_override_config"` PerTenantOverridePeriod time.Duration `yaml:"per_tenant_override_period"` }
Limits describe all the limits for users; can be used to describe global default limits via flags, or per-user limits via yaml config.
func (*Limits) RegisterFlags ¶
RegisterFlags adds the flags required to config this to the given FlagSet
func (*Limits) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface.
type Overrides ¶
type Overrides struct {
// contains filtered or unexported fields
}
Overrides periodically fetch a set of per-user overrides, and provides convenience functions for fetching the correct value.
func NewOverrides ¶
NewOverrides makes a new Overrides. We store the supplied limits in a global variable to ensure per-tenant limits are defaulted to those values. As such, the last call to NewOverrides will become the new global defaults.
func (*Overrides) AcceptHASamples ¶
AcceptHASamples returns whether the distributor should track and accept samples from HA replicas for this user.
func (*Overrides) CardinalityLimit ¶
CardinalityLimit returns the maximum number of timeseries allowed in a query.
func (*Overrides) CreationGracePeriod ¶
CreationGracePeriod is misnamed, and actually returns how far into the future we should accept samples.
func (*Overrides) EnforceMetricName ¶
EnforceMetricName whether to enforce the presence of a metric name.
func (*Overrides) HAClusterLabel ¶
HAClusterLabel returns the cluster label to look for when deciding whether to accept a sample from a Prometheus HA replica.
func (*Overrides) HAReplicaLabel ¶
HAReplicaLabel returns the replica label to look for when deciding whether to accept a sample from a Prometheus HA replica.
func (*Overrides) IngestionBurstSize ¶
IngestionBurstSize returns the burst size for ingestion rate.
func (*Overrides) IngestionRate ¶
IngestionRate returns the limit on ingester rate (samples per second).
func (*Overrides) MaxChunksPerQuery ¶
MaxChunksPerQuery returns the maximum number of chunks allowed per query.
func (*Overrides) MaxLabelNameLength ¶
MaxLabelNameLength returns maximum length a label name can be.
func (*Overrides) MaxLabelNamesPerSeries ¶
MaxLabelNamesPerSeries returns maximum number of label/value pairs timeseries.
func (*Overrides) MaxLabelValueLength ¶
MaxLabelValueLength returns maximum length a label value can be. This also is the maximum length of a metric name.
func (*Overrides) MaxQueryLength ¶
MaxQueryLength returns the limit of the length (in time) of a query.
func (*Overrides) MaxQueryParallelism ¶
MaxQueryParallelism returns the limit to the number of sub-queries the frontend will process in parallel.
func (*Overrides) MaxSamplesPerQuery ¶
MaxSamplesPerQuery returns the maximum number of samples in a query (from the ingester).
func (*Overrides) MaxSeriesPerMetric ¶
MaxSeriesPerMetric returns the maximum number of series allowed per metric.
func (*Overrides) MaxSeriesPerQuery ¶
MaxSeriesPerQuery returns the maximum number of series a query is allowed to hit.
func (*Overrides) MaxSeriesPerUser ¶
MaxSeriesPerUser returns the maximum number of series a user is allowed to store.
func (*Overrides) MinChunkLength ¶
MinChunkLength returns the minimum size of chunk that will be saved by ingesters
func (*Overrides) RejectOldSamples ¶
RejectOldSamples returns true when we should reject samples older than certain age.
func (*Overrides) RejectOldSamplesMaxAge ¶
RejectOldSamplesMaxAge returns the age at which samples should be rejected.
type OverridesLoader ¶
OverridesLoader loads the overrides
type OverridesManager ¶
type OverridesManager struct {
// contains filtered or unexported fields
}
OverridesManager manages default and per user limits i.e overrides. It can periodically keep reloading overrides based on config.
func NewOverridesManager ¶
func NewOverridesManager(cfg OverridesManagerConfig) (*OverridesManager, error)
NewOverridesManager creates an instance of OverridesManager and starts reload overrides loop based on config
func (*OverridesManager) GetLimits ¶
func (om *OverridesManager) GetLimits(userID string) interface{}
GetLimits returns Limits for a specific userID if its set otherwise the default Limits
type OverridesManagerConfig ¶
type OverridesManagerConfig struct { OverridesReloadPeriod time.Duration OverridesLoadPath string OverridesLoader OverridesLoader Defaults interface{} }
OverridesManagerConfig holds the config for an OverridesManager instance. It holds config related to loading per-tentant overrides and the default limits