validation

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LabelsToMetric

func LabelsToMetric(ls []prompb.Label) model.Metric

LabelsToMetric converts a Labels to Metric Don't do this on any performance sensitive paths.

func MetricNameFromLabels

func MetricNameFromLabels(labels []prompb2.Label) string

MetricNameFromLabels extracts the metric name from a list of LabelPairs. The returned metric name string is a reference to the label value (no copy).

Types

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 InitOverrides

func InitOverrides(defaults config.Limits, tenantLimits TenantLimits) *Overrides

InitOverrides makes a new global Overrides.

func Limits

func Limits() *Overrides

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) EnforceMetadataMetricName

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

EnforceMetadataMetricName whether to enforce the presence of a metric name on metadata.

func (*Overrides) EnforceMetricName

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

EnforceMetricName whether to enforce the presence of a metric name.

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) MaxMetadataLength

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

MaxMetadataLength returns maximum length metadata can be. Metadata refers to the Metric Name, HELP and UNIT.

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) PromLimitEnabled

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

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

type TenantLimits interface {
	// ByUserID gets limits specific to a particular tenant or nil if there are none
	ByUserID(userID string) *config.Limits

	// AllByUserID gets a mapping of all tenant IDs and limits for that user
	AllByUserID() map[string]*config.Limits
}

TenantLimits exposes per-tenant limit overrides to various resource usage limits

type ValidationError

type ValidationError error

ValidationError is an error returned by series validation.

nolint:golint ignore stutter warning

func ValidateLabels

func ValidateLabels(userID string, ls []prompb2.Label, unsafeMetricName string) ValidationError

ValidateLabels returns an err if the labels are invalid. The returned error may retain the provided series labels.

func ValidateMetadata

func ValidateMetadata(userID string, metadata *prompb.MetricMetadata) ValidationError

ValidateMetadata returns an err if a metric metadata is invalid.

func ValidateQueryTimeRange

func ValidateQueryTimeRange(userID string, startTime, endTime time.Time) ValidationError

validate query time range.

func ValidateSample

func ValidateSample(userID string, metricName string, s prompb2.Sample) ValidationError

ValidateSample returns an err if the sample is invalid. The returned error may retain the provided series labels.

func ValidateSeries

func ValidateSeries(userID string, ts *prompb2.TimeSeries) ValidationError

Validates a single series from a write request.

Jump to

Keyboard shortcuts

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