Documentation ¶
Index ¶
- Constants
- Variables
- func SetDefaultLimitsForYAMLUnmarshalling(defaults Limits)
- func TenantLimitsHandler(defaultLimits Limits, tenantLimits TenantLimits) http.HandlerFunc
- func ValidateLabels(limits LabelValidationLimits, userID string, ls []*typesv1.LabelPair) error
- type Error
- type LabelValidationLimits
- type LimitError
- type Limits
- 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) 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
- 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 Reason
- type TenantLimits
- type TenantLimitsResponse
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" // OutOfOrder is a reason for discarding profiles when Phlare doesn't accept out // of order profiles. OutOfOrder Reason = "out_of_order" // 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" 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'" )
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, userID string, ls []*typesv1.LabelPair) error
ValidateLabels validates the labels of a profile.
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"` // 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"` }
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 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 ¶ added in v0.6.0
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) 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.
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 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