Documentation ¶
Index ¶
- Constants
- Variables
- func SetDefaultLimitsForYAMLUnmarshalling(defaults Limits)
- func TenantLimitsHandler(defaultLimits Limits, tenantLimits TenantLimits) http.HandlerFunc
- func ValidateLabels(limits LabelValidationLimits, tenantID string, ls []*typesv1.LabelPair) error
- func ValidateProfile(limits ProfileValidationLimits, tenantID string, prof *googlev1.Profile, ...) error
- type Error
- type LabelValidationLimits
- type LimitError
- type Limits
- type MockLimits
- func (m MockLimits) MaxLabelNameLength(userID string) int
- func (m MockLimits) MaxLabelNamesPerSeries(userID string) int
- func (m MockLimits) MaxLabelValueLength(userID string) int
- func (m MockLimits) MaxProfileSizeBytes(userID string) int
- func (m MockLimits) MaxProfileStacktraceDepth(userID string) int
- func (m MockLimits) MaxProfileStacktraceSampleLabels(userID string) int
- func (m MockLimits) MaxProfileStacktraceSamples(userID string) int
- func (m MockLimits) MaxProfileSymbolValueLength(userID string) int
- func (m MockLimits) MaxQueryLength(tenantID string) time.Duration
- func (m MockLimits) MaxQueryLookback(tenantID string) time.Duration
- func (m MockLimits) MaxQueryParallelism(string) int
- func (m MockLimits) QuerySplitDuration(string) time.Duration
- func (m MockLimits) RejectNewerThan(userID string) time.Duration
- func (m MockLimits) RejectOlderThan(userID string) time.Duration
- type Overrides
- func (o *Overrides) AllByTenantID() map[string]*Limits
- func (o *Overrides) DefaultLimits() *Limits
- func (o *Overrides) IngestionBurstSizeBytes(tenantID string) int
- func (o *Overrides) IngestionRateBytes(tenantID string) float64
- func (o *Overrides) IngestionTenantShardSize(tenantID string) int
- func (o *Overrides) MaxGlobalSeriesPerTenant(tenantID string) int
- func (o *Overrides) MaxLabelNameLength(tenantID string) int
- func (o *Overrides) MaxLabelNamesPerSeries(tenantID string) int
- func (o *Overrides) MaxLabelValueLength(tenantID string) int
- func (o *Overrides) MaxLocalSeriesPerTenant(tenantID string) int
- func (o *Overrides) MaxProfileSizeBytes(tenantID string) int
- func (o *Overrides) MaxProfileStacktraceDepth(tenantID string) int
- func (o *Overrides) MaxProfileStacktraceSampleLabels(tenantID string) int
- func (o *Overrides) MaxProfileStacktraceSamples(tenantID string) int
- func (o *Overrides) MaxProfileSymbolValueLength(tenantID string) int
- func (o *Overrides) MaxQueriersPerTenant(tenant string) int
- func (o *Overrides) MaxQueryLength(tenantID string) time.Duration
- func (o *Overrides) MaxQueryLookback(tenantID string) time.Duration
- func (o *Overrides) MaxQueryParallelism(tenantID string) int
- func (o *Overrides) MaxSessionsPerSeries(tenantID string) int
- func (o *Overrides) QuerySplitDuration(tenantID string) time.Duration
- func (o *Overrides) RejectNewerThan(tenantID string) time.Duration
- func (o *Overrides) RejectOlderThan(tenantID string) time.Duration
- func (o *Overrides) StoreGatewayTenantShardSize(userID string) int
- type OverwriteMarshalingStringMap
- func (sm *OverwriteMarshalingStringMap) Map() map[string]string
- func (sm OverwriteMarshalingStringMap) MarshalJSON() ([]byte, error)
- func (sm OverwriteMarshalingStringMap) MarshalYAML() (interface{}, error)
- func (sm *OverwriteMarshalingStringMap) UnmarshalJSON(val []byte) error
- func (sm *OverwriteMarshalingStringMap) UnmarshalYAML(unmarshal func(interface{}) error) error
- type ProfileValidationLimits
- type RangeRequestLimits
- type Reason
- type TenantLimits
- type TenantLimitsResponse
- type ValidatedRangeRequest
Constants ¶
const ( ReasonLabel string = "reason" Unknown Reason = "unknown" // InvalidLabels is a reason for discarding profiles which have labels that are invalid. InvalidLabels Reason = "invalid_labels" // MissingLabels is a reason for discarding profiles which have no labels. MissingLabels Reason = "missing_labels" // RateLimited is one of the values for the reason to discard samples. RateLimited Reason = "rate_limited" // NotInIngestionWindow is a reason for discarding profiles when Pyroscope doesn't accept profiles // that are outside of the ingestion window. NotInIngestionWindow Reason = "not_in_ingestion_window" // MaxLabelNamesPerSeries is a reason for discarding a request which has too many label names MaxLabelNamesPerSeries Reason = "max_label_names_per_series" // LabelNameTooLong is a reason for discarding a request which has a label name too long LabelNameTooLong Reason = "label_name_too_long" // LabelValueTooLong is a reason for discarding a request which has a label value too long LabelValueTooLong Reason = "label_value_too_long" // DuplicateLabelNames is a reason for discarding a request which has duplicate label names DuplicateLabelNames Reason = "duplicate_label_names" // SeriesLimit is a reason for discarding lines when we can't create a new stream // because the limit of active streams has been reached. SeriesLimit Reason = "series_limit" QueryLimit Reason = "query_limit" SamplesLimit Reason = "samples_limit" ProfileSizeLimit Reason = "profile_size_limit" SampleLabelsLimit Reason = "sample_labels_limit" MalformedProfile Reason = "malformed_profile" SeriesLimitErrorMsg = "" /* 188-byte string literal not displayed */ MissingLabelsErrorMsg = "error at least one label pair is required per profile" InvalidLabelsErrorMsg = "invalid labels '%s' with error: %s" MaxLabelNamesPerSeriesErrorMsg = "profile series '%s' has %d label names; limit %d" LabelNameTooLongErrorMsg = "profile with labels '%s' has label name too long: '%s'" LabelValueTooLongErrorMsg = "profile with labels '%s' has label value too long: '%s'" DuplicateLabelNamesErrorMsg = "profile with labels '%s' has duplicate label name: '%s'" QueryTooLongErrorMsg = "the query time range exceeds the limit (max_query_length, actual: %s, limit: %s)" ProfileTooBigErrorMsg = "the profile with labels '%s' exceeds the size limit (max_profile_size_byte, actual: %d, limit: %d)" ProfileTooManySamplesErrorMsg = "the profile with labels '%s' exceeds the samples count limit (max_profile_stacktrace_samples, actual: %d, limit: %d)" ProfileTooManySampleLabelsErrorMsg = "the profile with labels '%s' exceeds the sample labels limit (max_profile_stacktrace_sample_labels, actual: %d, limit: %d)" NotInIngestionWindowErrorMsg = "profile with labels '%s' is outside of ingestion window (profile timestamp: %s, %s)" )
Variables ¶
var ( // DiscardedBytes is a metric of the total discarded bytes, by reason. DiscardedBytes = promauto.NewCounterVec( prometheus.CounterOpts{ Namespace: "pyroscope", Name: "discarded_bytes_total", Help: "The total number of bytes that were discarded.", }, []string{ReasonLabel, "tenant"}, ) // DiscardedProfiles is a metric of the number of discarded profiles, by reason. DiscardedProfiles = promauto.NewCounterVec( prometheus.CounterOpts{ Namespace: "pyroscope", Name: "discarded_samples_total", Help: "The total number of samples that were discarded.", }, []string{ReasonLabel, "tenant"}, ) )
Functions ¶
func SetDefaultLimitsForYAMLUnmarshalling ¶
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 TenantLimitsHandler ¶
func TenantLimitsHandler(defaultLimits Limits, tenantLimits TenantLimits) http.HandlerFunc
TenantLimitsHandler handles user limits.
func ValidateLabels ¶
func ValidateLabels(limits LabelValidationLimits, tenantID string, ls []*typesv1.LabelPair) error
ValidateLabels validates the labels of a profile.
func ValidateProfile ¶
func ValidateProfile(limits ProfileValidationLimits, tenantID string, prof *googlev1.Profile, uncompressedSize int, ls phlaremodel.Labels, now model.Time) error
Types ¶
type LabelValidationLimits ¶
type LimitError ¶
type LimitError string
LimitError are errors that do not comply with the limits specified.
func (LimitError) Error ¶
func (e LimitError) Error() string
type Limits ¶
type Limits struct { // Distributor enforced limits. IngestionRateMB float64 `yaml:"ingestion_rate_mb" json:"ingestion_rate_mb"` IngestionBurstSizeMB float64 `yaml:"ingestion_burst_size_mb" json:"ingestion_burst_size_mb"` MaxLabelNameLength int `yaml:"max_label_name_length" json:"max_label_name_length"` MaxLabelValueLength int `yaml:"max_label_value_length" json:"max_label_value_length"` MaxLabelNamesPerSeries int `yaml:"max_label_names_per_series" json:"max_label_names_per_series"` MaxSessionsPerSeries int `yaml:"max_sessions_per_series" json:"max_sessions_per_series"` MaxProfileSizeBytes int `yaml:"max_profile_size_bytes" json:"max_profile_size_bytes"` MaxProfileStacktraceSamples int `yaml:"max_profile_stacktrace_samples" json:"max_profile_stacktrace_samples"` MaxProfileStacktraceSampleLabels int `yaml:"max_profile_stacktrace_sample_labels" json:"max_profile_stacktrace_sample_labels"` MaxProfileStacktraceDepth int `yaml:"max_profile_stacktrace_depth" json:"max_profile_stacktrace_depth"` MaxProfileSymbolValueLength int `yaml:"max_profile_symbol_value_length" json:"max_profile_symbol_value_length"` // The tenant shard size determines the how many ingesters a particular // tenant will be sharded to. Needs to be specified on distributors for // correct distribution and on ingesters so that the local ingestion limit // can be calculated correctly. IngestionTenantShardSize int `yaml:"ingestion_tenant_shard_size" json:"ingestion_tenant_shard_size"` // Ingester enforced limits. MaxLocalSeriesPerTenant int `yaml:"max_local_series_per_tenant" json:"max_local_series_per_tenant"` MaxGlobalSeriesPerTenant int `yaml:"max_global_series_per_tenant" json:"max_global_series_per_tenant"` // Querier enforced limits. MaxQueryLookback model.Duration `yaml:"max_query_lookback" json:"max_query_lookback"` MaxQueryLength model.Duration `yaml:"max_query_length" json:"max_query_length"` MaxQueryParallelism int `yaml:"max_query_parallelism" json:"max_query_parallelism"` // Store-gateway. StoreGatewayTenantShardSize int `yaml:"store_gateway_tenant_shard_size" json:"store_gateway_tenant_shard_size"` // Query frontend. QuerySplitDuration model.Duration `yaml:"split_queries_by_interval" json:"split_queries_by_interval"` // Ensure profiles are dated within the IngestionWindow of the distributor. RejectOlderThan model.Duration `yaml:"reject_older_than" json:"reject_older_than"` RejectNewerThan model.Duration `yaml:"reject_newer_than" json:"reject_newer_than"` }
Limits describe all the limits for tenants; can be used to describe global default limits via flags, or per-tenant limits via yaml config. NOTE: we use custom `model.Duration` instead of standard `time.Duration` because, to support tenant-friendly duration format (e.g: "1h30m45s") in JSON value.
func MockDefaultLimits ¶
func MockDefaultLimits() *Limits
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 MockLimits ¶
type MockLimits struct { QuerySplitDurationValue time.Duration MaxQueryParallelismValue int MaxQueryLengthValue time.Duration MaxQueryLookbackValue time.Duration MaxLabelNameLengthValue int MaxLabelValueLengthValue int MaxLabelNamesPerSeriesValue int RejectOlderThanValue time.Duration RejectNewerThanValue time.Duration MaxProfileSizeBytesValue int MaxProfileStacktraceSamplesValue int MaxProfileStacktraceDepthValue int MaxProfileStacktraceSampleLabelsValue int MaxProfileSymbolValueLengthValue int }
func (MockLimits) MaxLabelNameLength ¶
func (m MockLimits) MaxLabelNameLength(userID string) int
func (MockLimits) MaxLabelNamesPerSeries ¶
func (m MockLimits) MaxLabelNamesPerSeries(userID string) int
func (MockLimits) MaxLabelValueLength ¶
func (m MockLimits) MaxLabelValueLength(userID string) int
func (MockLimits) MaxProfileSizeBytes ¶
func (m MockLimits) MaxProfileSizeBytes(userID string) int
func (MockLimits) MaxProfileStacktraceDepth ¶
func (m MockLimits) MaxProfileStacktraceDepth(userID string) int
func (MockLimits) MaxProfileStacktraceSampleLabels ¶
func (m MockLimits) MaxProfileStacktraceSampleLabels(userID string) int
func (MockLimits) MaxProfileStacktraceSamples ¶
func (m MockLimits) MaxProfileStacktraceSamples(userID string) int
func (MockLimits) MaxProfileSymbolValueLength ¶
func (m MockLimits) MaxProfileSymbolValueLength(userID string) int
func (MockLimits) MaxQueryLength ¶
func (m MockLimits) MaxQueryLength(tenantID string) time.Duration
func (MockLimits) MaxQueryLookback ¶
func (m MockLimits) MaxQueryLookback(tenantID string) time.Duration
func (MockLimits) MaxQueryParallelism ¶
func (m MockLimits) MaxQueryParallelism(string) int
func (MockLimits) QuerySplitDuration ¶
func (m MockLimits) QuerySplitDuration(string) time.Duration
func (MockLimits) RejectNewerThan ¶ added in v1.1.0
func (m MockLimits) RejectNewerThan(userID string) time.Duration
func (MockLimits) RejectOlderThan ¶ added in v1.1.0
func (m MockLimits) RejectOlderThan(userID string) time.Duration
type Overrides ¶
type Overrides struct {
// contains filtered or unexported fields
}
Overrides periodically fetch a set of per-tenant overrides, and provides convenience functions for fetching the correct value.
func MockDefaultOverrides ¶
func MockDefaultOverrides() *Overrides
func MockOverrides ¶
func NewOverrides ¶
func NewOverrides(defaults Limits, tenantLimits TenantLimits) (*Overrides, error)
NewOverrides makes a new Overrides.
func (*Overrides) AllByTenantID ¶
func (*Overrides) DefaultLimits ¶
func (*Overrides) IngestionBurstSizeBytes ¶
IngestionBurstSizeBytes returns the burst size for ingestion rate.
func (*Overrides) IngestionRateBytes ¶
IngestionRateBytes returns the limit on ingester rate (MBs per second).
func (*Overrides) IngestionTenantShardSize ¶
IngestionTenantShardSize returns the ingesters shard size for a given user.
func (*Overrides) MaxGlobalSeriesPerTenant ¶
MaxGlobalSeriesPerTenant returns the maximum number of series a tenant is allowed to store across the cluster.
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) MaxLocalSeriesPerTenant ¶
MaxLocalSeriesPerTenant returns the maximum number of series a tenant is allowed to store in a single ingester.
func (*Overrides) MaxProfileSizeBytes ¶
MaxProfileSizeBytes returns the maximum size of a profile in bytes.
func (*Overrides) MaxProfileStacktraceDepth ¶
MaxProfileStacktraceDepth returns the maximum depth of a profile stacktrace.
func (*Overrides) MaxProfileStacktraceSampleLabels ¶
MaxProfileStacktraceSampleLabels returns the maximum number of labels in a profile sample.
func (*Overrides) MaxProfileStacktraceSamples ¶
MaxProfileStacktraceSamples returns the maximum number of samples in a profile.
func (*Overrides) MaxProfileSymbolValueLength ¶
MaxProfileSymbolValueLength returns the maximum length of a profile symbol value (labels, function name and filename, etc...).
func (*Overrides) MaxQueriersPerTenant ¶
MaxQueriersPerTenant returns the limit to the number of queriers that can be used Shuffle sharding will be used to distribute queries across queriers. 0 means no limit. Currently disabled.
func (*Overrides) MaxQueryLength ¶
MaxQueryLength returns the limit of the length (in time) of a query.
func (*Overrides) MaxQueryLookback ¶
MaxQueryLookback returns the max lookback period of queries.
func (*Overrides) MaxQueryParallelism ¶
MaxQueryParallelism returns the limit to the number of sub-queries the frontend will process in parallel.
func (*Overrides) MaxSessionsPerSeries ¶ added in v1.1.0
MaxSessionsPerSeries returns the maximum number of sessions per single series.
func (*Overrides) QuerySplitDuration ¶
QuerySplitDuration returns the tenant specific split by interval applied in the query frontend.
func (*Overrides) RejectNewerThan ¶ added in v1.1.0
RejectNewerThan will ensure that profiles are further than the return value into the future are reject.
func (*Overrides) RejectOlderThan ¶ added in v1.1.0
RejectOlderThan will ensure that profiles that are older than the return value are rejected.
func (*Overrides) StoreGatewayTenantShardSize ¶
StoreGatewayTenantShardSize returns the store-gateway shard size for a given user.
type OverwriteMarshalingStringMap ¶
type OverwriteMarshalingStringMap struct {
// contains filtered or unexported fields
}
OverwriteMarshalingStringMap will overwrite the src map when unmarshaling as opposed to merging.
func NewOverwriteMarshalingStringMap ¶
func NewOverwriteMarshalingStringMap(m map[string]string) OverwriteMarshalingStringMap
func (*OverwriteMarshalingStringMap) Map ¶
func (sm *OverwriteMarshalingStringMap) Map() map[string]string
func (OverwriteMarshalingStringMap) MarshalJSON ¶
func (sm OverwriteMarshalingStringMap) MarshalJSON() ([]byte, error)
MarshalJSON explicitly uses the the type receiver and not pointer receiver or it won't be called
func (OverwriteMarshalingStringMap) MarshalYAML ¶
func (sm OverwriteMarshalingStringMap) MarshalYAML() (interface{}, error)
MarshalYAML explicitly uses the the type receiver and not pointer receiver or it won't be called
func (*OverwriteMarshalingStringMap) UnmarshalJSON ¶
func (sm *OverwriteMarshalingStringMap) UnmarshalJSON(val []byte) error
func (*OverwriteMarshalingStringMap) UnmarshalYAML ¶
func (sm *OverwriteMarshalingStringMap) UnmarshalYAML(unmarshal func(interface{}) error) error
type ProfileValidationLimits ¶
type ProfileValidationLimits interface { MaxProfileSizeBytes(tenantID string) int MaxProfileStacktraceSamples(tenantID string) int MaxProfileStacktraceSampleLabels(tenantID string) int MaxProfileStacktraceDepth(tenantID string) int MaxProfileSymbolValueLength(tenantID string) int RejectNewerThan(tenantID string) time.Duration RejectOlderThan(tenantID string) time.Duration }
type RangeRequestLimits ¶
type TenantLimits ¶
type TenantLimits interface { // TenantLimits is a function that returns limits for given tenant, or // nil, if there are no tenant-specific limits. TenantLimits(tenantID string) *Limits // AllByTenantID gets a mapping of all tenant IDs and limits for that tenant AllByTenantID() map[string]*Limits }
func NewMockTenantLimits ¶
func NewMockTenantLimits(limits map[string]*Limits) TenantLimits
NewMockTenantLimits creates a new mockTenantLimits that returns per-tenant limits based on the given map
type TenantLimitsResponse ¶
type ValidatedRangeRequest ¶
func ValidateRangeRequest ¶
func ValidateRangeRequest(limits RangeRequestLimits, tenantIDs []string, req model.Interval, now model.Time) (ValidatedRangeRequest, error)