validation

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: Apache-2.0 Imports: 5 Imported by: 42

Documentation

Index

Constants

View Source
const (
	// Local ingestion rate strategy
	LocalIngestionRateStrategy = "local"

	// Global ingestion rate strategy
	GlobalIngestionRateStrategy = "global"
)
View Source
const (

	// RateLimited is one of the values for the reason to discard samples.
	// Declared here to avoid duplication in ingester and distributor.
	RateLimited = "rate_limited"

	// LineTooLong is a reason for discarding too long log lines.
	LineTooLong = "line_too_long"

	// StreamLimit is a reason for discarding lines when we can't create a new stream
	// because the limit of active streams has been reached.
	StreamLimit = "stream_limit"

	// GreaterThanMaxSampleAge is a reason for discarding log lines which are older than the current time - `reject_old_samples_max_age`
	GreaterThanMaxSampleAge = "greater_than_max_sample_age"

	// TooFarInFuture is a reason for discarding log lines which are newer than the current time + `creation_grace_period`
	TooFarInFuture = "too_far_in_future"

	// MaxLabelNamesPerSeries is a reason for discarding a log line which has too many label names
	MaxLabelNamesPerSeries = "max_label_names_per_series"

	// LabelNameTooLong is a reason for discarding a log line which has a label name too long
	LabelNameTooLong = "label_name_too_long"

	// LabelValueTooLong is a reason for discarding a log line which has a lable value too long
	LabelValueTooLong = "label_value_too_long"

	// DuplicateLabelNames is a reason for discarding a log line which has duplicate label names
	DuplicateLabelNames = "duplicate_label_names"
)

Variables

View Source
var DiscardedBytes = prometheus.NewCounterVec(
	prometheus.CounterOpts{
		Namespace: "loki",
		Name:      "discarded_bytes_total",
		Help:      "The total number of bytes that were discarded.",
	},
	[]string{discardReasonLabel, "tenant"},
)

DiscardedBytes is a metric of the total discarded bytes, by reason.

View Source
var DiscardedSamples = prometheus.NewCounterVec(
	prometheus.CounterOpts{
		Namespace: "loki",
		Name:      "discarded_samples_total",
		Help:      "The total number of samples that were discarded.",
	},
	[]string{discardReasonLabel, "tenant"},
)

DiscardedSamples is a metric of the number of discarded samples, by reason.

Functions

func DuplicateLabelNamesErrorMsg added in v1.5.0

func DuplicateLabelNamesErrorMsg(stream, label string) string

DuplicateLabelNamesErrorMsg returns an error string for a stream which has duplicate labels

func GreaterThanMaxSampleAgeErrorMsg added in v1.5.0

func GreaterThanMaxSampleAgeErrorMsg(stream string, timestamp time.Time) string

GreaterThanMaxSampleAgeErrorMsg returns an error string for a line with a timestamp too old

func LabelNameTooLongErrorMsg added in v1.5.0

func LabelNameTooLongErrorMsg(stream, label string) string

LabelNameTooLongErrorMsg returns an error string for a stream with a label name too long

func LabelValueTooLongErrorMsg added in v1.5.0

func LabelValueTooLongErrorMsg(stream, labelValue string) string

LabelValueTooLongErrorMsg returns an error string for a stream with a label value too long

func LineTooLongErrorMsg added in v1.5.0

func LineTooLongErrorMsg(maxLength, entryLength int, stream string) string

LineTooLongErrorMsg returns an error string for a line which is too long

func MaxLabelNamesPerSeriesErrorMsg added in v1.5.0

func MaxLabelNamesPerSeriesErrorMsg(stream string, labelCount, labelLimit int) string

MaxLabelNamesPerSeriesErrorMsg returns an error string for a stream with too many labels

func RateLimitedErrorMsg added in v1.5.0

func RateLimitedErrorMsg(limit, lines, bytes int) string

RateLimitedErrorMsg returns an error string for rate limited requests

func SetDefaultLimitsForYAMLUnmarshalling added in v1.4.0

func SetDefaultLimitsForYAMLUnmarshalling(defaults Limits)

SetDefaultLimitsForYAMLUnmarshalling sets global default limits, used when loading Limits from YAML files. This is used to ensure per-tenant limits are defaulted to those values.

func StreamLimitErrorMsg added in v1.5.0

func StreamLimitErrorMsg() string

StreamLimitErrorMsg returns an error string for requests refused for exceeding active stream limits

func TooFarInFutureErrorMsg added in v1.5.0

func TooFarInFutureErrorMsg(stream string, timestamp time.Time) string

TooFarInFutureErrorMsg returns an error string for a line with a timestamp too far in the future

Types

type Limits

type Limits struct {
	// Distributor enforced limits.
	IngestionRateStrategy  string           `yaml:"ingestion_rate_strategy"`
	IngestionRateMB        float64          `yaml:"ingestion_rate_mb"`
	IngestionBurstSizeMB   float64          `yaml:"ingestion_burst_size_mb"`
	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"`
	MaxLineSize            flagext.ByteSize `yaml:"max_line_size"`

	// Ingester enforced limits.
	MaxLocalStreamsPerUser  int `yaml:"max_streams_per_user"`
	MaxGlobalStreamsPerUser int `yaml:"max_global_streams_per_user"`

	// 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"`
	MaxStreamsMatchersPerQuery int           `yaml:"max_streams_matchers_per_query"`
	MaxConcurrentTailRequests  int           `yaml:"max_concurrent_tail_requests"`
	MaxEntriesLimitPerQuery    int           `yaml:"max_entries_limit_per_query"`
	MaxCacheFreshness          time.Duration `yaml:"max_cache_freshness_per_query"`

	// Query frontend enforced limits. The default is actually parameterized by the queryrange config.
	QuerySplitDuration time.Duration `yaml:"split_queries_by_interval"`

	// 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

func (l *Limits) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

func (*Limits) UnmarshalYAML

func (l *Limits) UnmarshalYAML(unmarshal func(interface{}) error) error

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

func NewOverrides(defaults Limits, tenantLimits TenantLimits) (*Overrides, error)

NewOverrides makes a new Overrides.

func (*Overrides) CardinalityLimit

func (o *Overrides) CardinalityLimit(userID string) int

CardinalityLimit whether to enforce the presence of a metric name.

func (*Overrides) CreationGracePeriod

func (o *Overrides) CreationGracePeriod(userID string) time.Duration

CreationGracePeriod is misnamed, and actually returns how far into the future we should accept samples.

func (*Overrides) EnforceMetricName

func (o *Overrides) EnforceMetricName(userID string) bool

EnforceMetricName whether to enforce the presence of a metric name.

func (*Overrides) IngestionBurstSizeBytes added in v1.3.0

func (o *Overrides) IngestionBurstSizeBytes(userID string) int

IngestionBurstSizeBytes returns the burst size for ingestion rate.

func (*Overrides) IngestionRateBytes added in v1.3.0

func (o *Overrides) IngestionRateBytes(userID string) float64

IngestionRateBytes returns the limit on ingester rate (MBs per second).

func (*Overrides) IngestionRateStrategy added in v1.3.0

func (o *Overrides) IngestionRateStrategy() string

IngestionRateStrategy returns whether the ingestion rate limit should be individually applied to each distributor instance (local) or evenly shared across the cluster (global).

func (*Overrides) MaxCacheFreshness added in v1.6.0

func (o *Overrides) MaxCacheFreshness(userID string) time.Duration

func (*Overrides) MaxChunksPerQuery

func (o *Overrides) MaxChunksPerQuery(userID string) int

MaxChunksPerQuery returns the maximum number of chunks allowed per query.

func (*Overrides) MaxConcurrentTailRequests added in v1.4.0

func (o *Overrides) MaxConcurrentTailRequests(userID string) int

MaxConcurrentTailRequests returns the limit to number of concurrent tail requests.

func (*Overrides) MaxEntriesLimitPerQuery added in v1.5.0

func (o *Overrides) MaxEntriesLimitPerQuery(userID string) int

MaxEntriesLimitPerQuery returns the limit to number of entries the querier should return per query.

func (*Overrides) MaxGlobalStreamsPerUser added in v1.3.0

func (o *Overrides) MaxGlobalStreamsPerUser(userID string) int

MaxGlobalStreamsPerUser returns the maximum number of streams a user is allowed to store across the cluster.

func (*Overrides) MaxLabelNameLength

func (o *Overrides) MaxLabelNameLength(userID string) int

MaxLabelNameLength returns maximum length a label name can be.

func (*Overrides) MaxLabelNamesPerSeries

func (o *Overrides) MaxLabelNamesPerSeries(userID string) int

MaxLabelNamesPerSeries returns maximum number of label/value pairs timeseries.

func (*Overrides) MaxLabelValueLength

func (o *Overrides) MaxLabelValueLength(userID string) int

MaxLabelValueLength returns maximum length a label value can be. This also is the maximum length of a metric name.

func (*Overrides) MaxLineSize added in v1.4.0

func (o *Overrides) MaxLineSize(userID string) int

MaxLineSize returns the maximum size in bytes the distributor should allow.

func (*Overrides) MaxLocalStreamsPerUser added in v1.3.0

func (o *Overrides) MaxLocalStreamsPerUser(userID string) int

MaxLocalStreamsPerUser returns the maximum number of streams a user is allowed to store in a single ingester.

func (*Overrides) MaxQueryLength

func (o *Overrides) MaxQueryLength(userID string) time.Duration

MaxQueryLength returns the limit of the length (in time) of a query.

func (*Overrides) MaxQueryParallelism

func (o *Overrides) MaxQueryParallelism(userID string) int

MaxQueryParallelism returns the limit to the number of sub-queries the frontend will process in parallel.

func (*Overrides) MaxStreamsMatchersPerQuery

func (o *Overrides) MaxStreamsMatchersPerQuery(userID string) int

MaxStreamsMatchersPerQuery returns the limit to number of streams matchers per query.

func (*Overrides) QuerySplitDuration added in v1.4.0

func (o *Overrides) QuerySplitDuration(userID string) time.Duration

QuerySplitDuration returns the tenant specific splitby interval applied in the query frontend.

func (*Overrides) RejectOldSamples

func (o *Overrides) RejectOldSamples(userID string) bool

RejectOldSamples returns true when we should reject samples older than certain age.

func (*Overrides) RejectOldSamplesMaxAge

func (o *Overrides) RejectOldSamplesMaxAge(userID string) time.Duration

RejectOldSamplesMaxAge returns the age at which samples should be rejected.

type TenantLimits added in v1.4.0

type TenantLimits func(userID string) *Limits

TenantLimits is a function that returns limits for given tenant, or nil, if there are no tenant-specific limits.

Jump to

Keyboard shortcuts

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