diff --git a/modules/ingester/limiter.go b/modules/ingester/limiter.go index d777c2a..ec7e774 100644 --- a/modules/ingester/limiter.go +++ b/modules/ingester/limiter.go @@ -25,7 +25,7 @@ import ( ) const ( - errMaxSnapshotsPerUserLimitExceeded = "per-user snapshots limit (local: %d global: %d actual local: %d) exceeded" + errMaxSnapshotsPerTenantLimitExceeded = "per-tenant snapshots limit (local: %d global: %d actual local: %d) exceeded" ) // RingCount is the interface exposed by a ring implementation which allows @@ -51,26 +51,26 @@ func NewLimiter(limits *overrides.Overrides, ring RingCount, replicationFactor i } } -// AssertMaxSnapshotsPerUser ensures limit has not been reached compared to the current +// AssertMaxSnapshotsPerTenant ensures limit has not been reached compared to the current // number of streams in input and returns an error if so. -func (l *Limiter) AssertMaxSnapshotsPerUser(userID string, snapshots int) error { - actualLimit := l.maxSnapshotsPerUser(userID) +func (l *Limiter) AssertMaxSnapshotsPerTenant(tenantID string, snapshots int) error { + actualLimit := l.maxSnapshotsPerTenant(tenantID) if snapshots < actualLimit { return nil } - localLimit := l.limits.MaxLocalSnapshotsPerUser(userID) - globalLimit := l.limits.MaxGlobalSnapshotsPerUser(userID) + localLimit := l.limits.MaxLocalSnapshotsPerTenant(tenantID) + globalLimit := l.limits.MaxGlobalSnapshotsPerTenant(tenantID) - return fmt.Errorf(errMaxSnapshotsPerUserLimitExceeded, localLimit, globalLimit, actualLimit) + return fmt.Errorf(errMaxSnapshotsPerTenantLimitExceeded, localLimit, globalLimit, actualLimit) } -func (l *Limiter) maxSnapshotsPerUser(userID string) int { - localLimit := l.limits.MaxLocalSnapshotsPerUser(userID) +func (l *Limiter) maxSnapshotsPerTenant(tenantID string) int { + localLimit := l.limits.MaxLocalSnapshotsPerTenant(tenantID) // We can assume that snapshots are evenly distributed across ingesters // so we do convert the global limit into a local limit - globalLimit := l.limits.MaxGlobalSnapshotsPerUser(userID) + globalLimit := l.limits.MaxGlobalSnapshotsPerTenant(tenantID) localLimit = l.minNonZero(localLimit, l.convertGlobalToLocalLimit(globalLimit)) // If both the local and global limits are disabled, we just diff --git a/modules/ingester/tenantBlockManager.go b/modules/ingester/tenantBlockManager.go index 24e71bf..965a2e1 100644 --- a/modules/ingester/tenantBlockManager.go +++ b/modules/ingester/tenantBlockManager.go @@ -176,7 +176,7 @@ func (i *tenantBlockManager) PushBytes(ctx context.Context, id []byte, snapshotB } // check for max snapshots before grabbing the lock to better load shed - err := i.limiter.AssertMaxSnapshotsPerUser(i.tenantID, int(i.snapshotCount.Load())) + err := i.limiter.AssertMaxSnapshotsPerTenant(i.tenantID, int(i.snapshotCount.Load())) if err != nil { return status.Errorf(codes.FailedPrecondition, "%s max live snapshots exceeded for tenant %s: %v", overrides.ErrorPrefixLiveSnapshotsExceeded, i.tenantID, err) } diff --git a/modules/ingester/tenantBlockManager_test.go b/modules/ingester/tenantBlockManager_test.go index 692a45c..5016eb0 100644 --- a/modules/ingester/tenantBlockManager_test.go +++ b/modules/ingester/tenantBlockManager_test.go @@ -231,7 +231,7 @@ package ingester //func TestInstanceLimits(t *testing.T) { // limits, err := overrides.NewOverrides(overrides.Limits{ // MaxBytesPerSnapshot: 1000, -// MaxLocalSnapshotsPerUser: 4, +// MaxLocalSnapshotsPerTenant: 4, // }) // require.NoError(t, err, "unexpected error creating limits") // limiter := NewLimiter(limits, &ringCountMock{count: 1}, 1) diff --git a/modules/overrides/limits.go b/modules/overrides/limits.go index d105cd3..6b84427 100644 --- a/modules/overrides/limits.go +++ b/modules/overrides/limits.go @@ -35,13 +35,13 @@ const ( ErrorPrefixLiveSnapshotsExceeded = "LIVE_SNAPSHOTS_EXCEEDED:" // ErrorPrefixSnapshotTooLarge is used to flag batches from the ingester that were rejected b/c they exceeded the single trace limit ErrorPrefixSnapshotTooLarge = "SNAPSHOT_TOO_LARGE:" - // ErrorPrefixRateLimited is used to flag batches that have exceeded the spans/second of the tenant + // ErrorPrefixRateLimited is used to flag batches that have exceeded the snapshot/second of the tenant ErrorPrefixRateLimited = "RATE_LIMITED:" // metrics - MetricMaxLocalTracesPerUser = "max_local_traces_per_user" - MetricMaxGlobalTracesPerUser = "max_global_traces_per_user" - MetricMaxBytesPerTrace = "max_bytes_per_snapshot" + MetricMaxLocalSnapshotsPerTenant = "max_local_snapshots_per_tenant" + MetricMaxGlobalSnapshotsPerTenant = "max_global_snapshots_per_tenant" + MetricMaxBytesPerSnapshot = "max_bytes_per_snapshot" MetricMaxBytesPerTagValuesQuery = "max_bytes_per_tag_values_query" MetricIngestionRateLimitBytes = "ingestion_rate_limit_bytes" MetricIngestionBurstSizeBytes = "ingestion_burst_size_bytes" @@ -67,8 +67,8 @@ type Limits struct { IngestionBurstSizeBytes int `yaml:"ingestion_burst_size_bytes" json:"ingestion_burst_size_bytes"` // Ingester enforced limits. - MaxLocalTracesPerUser int `yaml:"max_traces_per_user" json:"max_traces_per_user"` - MaxGlobalTracesPerUser int `yaml:"max_global_traces_per_user" json:"max_global_traces_per_user"` + MaxLocalSnapshotsPerTenant int `yaml:"max_snapshots_per_tenant" json:"max_snapshots_per_tenant"` + MaxGlobalSnapshotsPerTenant int `yaml:"max_global_snapshots_per_tenant" json:"max_global_snapshots_per_tenant"` // Forwarders Forwarders []string `yaml:"forwarders" json:"forwarders"` @@ -100,8 +100,9 @@ type Limits struct { // is not used when doing a trace by id lookup. MaxBytesPerSnapshot int `yaml:"max_bytes_per_snapshot" json:"max_bytes_per_snapshot"` - // Configuration for overrides, convenient if it goes here. - PerTenantOverrideConfig string `yaml:"per_tenant_override_config" json:"per_tenant_override_config"` + // PerTenantOverrideConfig is the path to the per-tenant config + PerTenantOverrideConfig string `yaml:"per_tenant_override_config" json:"per_tenant_override_config"` + // PerTenantOverridePeriod the time between reloads of the override file PerTenantOverridePeriod model.Duration `yaml:"per_tenant_override_period" json:"per_tenant_override_period"` } @@ -113,16 +114,16 @@ func (l *Limits) RegisterFlags(f *flag.FlagSet) { f.IntVar(&l.IngestionBurstSizeBytes, "distributor.ingestion-burst-size-bytes", 20e6, "Per-user ingestion burst size in bytes. Should be set to the expected size (in bytes) of a single push request.") // Ingester limits - f.IntVar(&l.MaxLocalTracesPerUser, "ingester.max-traces-per-user", 10e3, "Maximum number of active traces per user, per ingester. 0 to disable.") - f.IntVar(&l.MaxGlobalTracesPerUser, "ingester.max-global-traces-per-user", 0, "Maximum number of active traces per user, across the cluster. 0 to disable.") - f.IntVar(&l.MaxBytesPerSnapshot, "ingester.max-bytes-per-trace", 50e5, "Maximum size of a trace in bytes. 0 to disable.") + f.IntVar(&l.MaxLocalSnapshotsPerTenant, "ingester.max-snapshots-per-tenant", 10e3, "Maximum number of active snapshots per tenant, per ingester. 0 to disable.") + f.IntVar(&l.MaxGlobalSnapshotsPerTenant, "ingester.max-global-snapshots-per-tenant", 0, "Maximum number of active snapshots per tenant, across the cluster. 0 to disable.") + f.IntVar(&l.MaxBytesPerSnapshot, "ingester.max-bytes-per-snapshot", 50e5, "Maximum size of a snapshots in bytes. 0 to disable.") // Querier limits f.IntVar(&l.MaxBytesPerTagValuesQuery, "querier.max-bytes-per-tag-values-query", 50e5, "Maximum size of response for a tag-values query. Used mainly to limit large the number of values associated with a particular tag") - f.StringVar(&l.PerTenantOverrideConfig, "limits.per-user-override-config", "", "File name of per-user overrides.") + f.StringVar(&l.PerTenantOverrideConfig, "limits.per-tenant-override-config", "", "File name of per tenant overrides.") _ = l.PerTenantOverridePeriod.Set("10s") - f.Var(&l.PerTenantOverridePeriod, "limits.per-user-override-period", "Period with this to reload the overrides.") + f.Var(&l.PerTenantOverridePeriod, "limits.per-tenant-override-period", "Period with this to reload the overrides.") } func (l *Limits) Describe(ch chan<- *prometheus.Desc) { @@ -130,9 +131,9 @@ func (l *Limits) Describe(ch chan<- *prometheus.Desc) { } func (l *Limits) Collect(ch chan<- prometheus.Metric) { - ch <- prometheus.MustNewConstMetric(metricLimitsDesc, prometheus.GaugeValue, float64(l.MaxLocalTracesPerUser), MetricMaxLocalTracesPerUser) - ch <- prometheus.MustNewConstMetric(metricLimitsDesc, prometheus.GaugeValue, float64(l.MaxGlobalTracesPerUser), MetricMaxGlobalTracesPerUser) - ch <- prometheus.MustNewConstMetric(metricLimitsDesc, prometheus.GaugeValue, float64(l.MaxBytesPerSnapshot), MetricMaxBytesPerTrace) + ch <- prometheus.MustNewConstMetric(metricLimitsDesc, prometheus.GaugeValue, float64(l.MaxLocalSnapshotsPerTenant), MetricMaxLocalSnapshotsPerTenant) + ch <- prometheus.MustNewConstMetric(metricLimitsDesc, prometheus.GaugeValue, float64(l.MaxGlobalSnapshotsPerTenant), MetricMaxGlobalSnapshotsPerTenant) + ch <- prometheus.MustNewConstMetric(metricLimitsDesc, prometheus.GaugeValue, float64(l.MaxBytesPerSnapshot), MetricMaxBytesPerSnapshot) ch <- prometheus.MustNewConstMetric(metricLimitsDesc, prometheus.GaugeValue, float64(l.MaxBytesPerTagValuesQuery), MetricMaxBytesPerTagValuesQuery) ch <- prometheus.MustNewConstMetric(metricLimitsDesc, prometheus.GaugeValue, float64(l.IngestionRateLimitBytes), MetricIngestionRateLimitBytes) ch <- prometheus.MustNewConstMetric(metricLimitsDesc, prometheus.GaugeValue, float64(l.IngestionBurstSizeBytes), MetricIngestionBurstSizeBytes) diff --git a/modules/overrides/limits_test.go b/modules/overrides/limits_test.go index 06361ba..114986a 100644 --- a/modules/overrides/limits_test.go +++ b/modules/overrides/limits_test.go @@ -56,8 +56,8 @@ ingestion_rate_strategy: global ingestion_rate_limit_bytes: 100_000 ingestion_burst_size_bytes: 100_000 -max_traces_per_user: 1000 -max_global_traces_per_user: 1000 +max_snapshots_per_tenant: 1000 +max_global_snapshots_per_tenant: 1000 max_bytes_per_snapshot: 100_000 block_retention: 24h @@ -76,8 +76,8 @@ max_search_duration: 5m "ingestion_rate_limit_bytes": 100000, "ingestion_burst_size_bytes": 100000, - "max_traces_per_user": 1000, - "max_global_traces_per_user": 1000, + "max_snapshots_per_tenant": 1000, + "max_global_snapshots_per_tenant": 1000, "max_bytes_per_snapshot": 100000, "block_retention": "24h", diff --git a/modules/overrides/overrides.go b/modules/overrides/overrides.go index bf06384..a3a9ed1 100644 --- a/modules/overrides/overrides.go +++ b/modules/overrides/overrides.go @@ -39,7 +39,7 @@ var ( metricOverridesLimitsDesc = prometheus.NewDesc( "deep_limits_overrides", "Resource limit overrides applied to tenants", - []string{"limit_name", "user"}, + []string{"limit_name", "tenant"}, nil, ) ) @@ -49,9 +49,9 @@ type perTenantOverrides struct { TenantLimits map[string]*Limits `yaml:"overrides"` } -// forUser returns limits for a given tenant, or nil if there are no tenant-specific limits. -func (o *perTenantOverrides) forUser(userID string) *Limits { - l, ok := o.TenantLimits[userID] +// forTenant returns limits for a given tenant, or nil if there are no tenant-specific limits. +func (o *perTenantOverrides) forTenant(tenantID string) *Limits { + l, ok := o.TenantLimits[tenantID] if !ok || l == nil { return nil } @@ -249,133 +249,133 @@ func (o *Overrides) TenantIDs() []string { func (o *Overrides) IngestionRateStrategy() string { // The ingestion rate strategy can't be overridden on a per-tenant basis, // so here we just pick the value for a not-existing user ID (empty string). - return o.getOverridesForUser("").IngestionRateStrategy + return o.getOverridesForTenant("").IngestionRateStrategy } -// MaxLocalSnapshotsPerUser returns the maximum number of traces a user is allowed to store +// MaxLocalSnapshotsPerTenant returns the maximum number of traces a user is allowed to store // in a single ingester. -func (o *Overrides) MaxLocalSnapshotsPerUser(userID string) int { - return o.getOverridesForUser(userID).MaxLocalTracesPerUser +func (o *Overrides) MaxLocalSnapshotsPerTenant(tenantID string) int { + return o.getOverridesForTenant(tenantID).MaxLocalSnapshotsPerTenant } -// MaxGlobalSnapshotsPerUser returns the maximum number of traces a user is allowed to store +// MaxGlobalSnapshotsPerTenant returns the maximum number of traces a user is allowed to store // across the cluster. -func (o *Overrides) MaxGlobalSnapshotsPerUser(userID string) int { - return o.getOverridesForUser(userID).MaxGlobalTracesPerUser +func (o *Overrides) MaxGlobalSnapshotsPerTenant(tenantID string) int { + return o.getOverridesForTenant(tenantID).MaxGlobalSnapshotsPerTenant } // MaxBytesPerSnapshot returns the maximum size of a single trace in bytes allowed for a user. -func (o *Overrides) MaxBytesPerSnapshot(userID string) int { - return o.getOverridesForUser(userID).MaxBytesPerSnapshot +func (o *Overrides) MaxBytesPerSnapshot(tenantID string) int { + return o.getOverridesForTenant(tenantID).MaxBytesPerSnapshot } // Forwarders returns the list of forwarder IDs for a user. -func (o *Overrides) Forwarders(userID string) []string { - return o.getOverridesForUser(userID).Forwarders +func (o *Overrides) Forwarders(tenantID string) []string { + return o.getOverridesForTenant(tenantID).Forwarders } // MaxBytesPerTagValuesQuery returns the maximum size of a response to a tag-values query allowed for a user. -func (o *Overrides) MaxBytesPerTagValuesQuery(userID string) int { - return o.getOverridesForUser(userID).MaxBytesPerTagValuesQuery +func (o *Overrides) MaxBytesPerTagValuesQuery(tenantID string) int { + return o.getOverridesForTenant(tenantID).MaxBytesPerTagValuesQuery } // IngestionRateLimitBytes is the number of spans per second allowed for this tenant. -func (o *Overrides) IngestionRateLimitBytes(userID string) float64 { - return float64(o.getOverridesForUser(userID).IngestionRateLimitBytes) +func (o *Overrides) IngestionRateLimitBytes(tenantID string) float64 { + return float64(o.getOverridesForTenant(tenantID).IngestionRateLimitBytes) } // IngestionBurstSizeBytes is the burst size in spans allowed for this tenant. -func (o *Overrides) IngestionBurstSizeBytes(userID string) int { - return o.getOverridesForUser(userID).IngestionBurstSizeBytes +func (o *Overrides) IngestionBurstSizeBytes(tenantID string) int { + return o.getOverridesForTenant(tenantID).IngestionBurstSizeBytes } // MetricsGeneratorRingSize is the desired size of the metrics-generator ring for this tenant. // Using shuffle sharding, a tenant can use a smaller ring than the entire ring. -func (o *Overrides) MetricsGeneratorRingSize(userID string) int { - return o.getOverridesForUser(userID).MetricsGeneratorRingSize +func (o *Overrides) MetricsGeneratorRingSize(tenantID string) int { + return o.getOverridesForTenant(tenantID).MetricsGeneratorRingSize } // MetricsGeneratorProcessors returns the metrics-generator processors enabled for this tenant. -func (o *Overrides) MetricsGeneratorProcessors(userID string) map[string]struct{} { - return o.getOverridesForUser(userID).MetricsGeneratorProcessors.GetMap() +func (o *Overrides) MetricsGeneratorProcessors(tenantID string) map[string]struct{} { + return o.getOverridesForTenant(tenantID).MetricsGeneratorProcessors.GetMap() } // MetricsGeneratorMaxActiveSeries is the maximum amount of active series in the metrics-generator // registry for this tenant. Note this is a local limit enforced in every instance separately. -func (o *Overrides) MetricsGeneratorMaxActiveSeries(userID string) uint32 { - return o.getOverridesForUser(userID).MetricsGeneratorMaxActiveSeries +func (o *Overrides) MetricsGeneratorMaxActiveSeries(tenantID string) uint32 { + return o.getOverridesForTenant(tenantID).MetricsGeneratorMaxActiveSeries } // MetricsGeneratorCollectionInterval is the collection interval of the metrics-generator registry // for this tenant. -func (o *Overrides) MetricsGeneratorCollectionInterval(userID string) time.Duration { - return o.getOverridesForUser(userID).MetricsGeneratorCollectionInterval +func (o *Overrides) MetricsGeneratorCollectionInterval(tenantID string) time.Duration { + return o.getOverridesForTenant(tenantID).MetricsGeneratorCollectionInterval } // MetricsGeneratorDisableCollection controls whether metrics are remote written for this tenant. -func (o *Overrides) MetricsGeneratorDisableCollection(userID string) bool { - return o.getOverridesForUser(userID).MetricsGeneratorDisableCollection +func (o *Overrides) MetricsGeneratorDisableCollection(tenantID string) bool { + return o.getOverridesForTenant(tenantID).MetricsGeneratorDisableCollection } // MetricsGeneratorForwarderQueueSize is the size of the buffer of requests to send to the metrics-generator // from the distributor for this tenant. -func (o *Overrides) MetricsGeneratorForwarderQueueSize(userID string) int { - return o.getOverridesForUser(userID).MetricsGeneratorForwarderQueueSize +func (o *Overrides) MetricsGeneratorForwarderQueueSize(tenantID string) int { + return o.getOverridesForTenant(tenantID).MetricsGeneratorForwarderQueueSize } // MetricsGeneratorForwarderWorkers is the number of workers to send metrics to the metrics-generator -func (o *Overrides) MetricsGeneratorForwarderWorkers(userID string) int { - return o.getOverridesForUser(userID).MetricsGeneratorForwarderWorkers +func (o *Overrides) MetricsGeneratorForwarderWorkers(tenantID string) int { + return o.getOverridesForTenant(tenantID).MetricsGeneratorForwarderWorkers } // MetricsGeneratorProcessorServiceGraphsHistogramBuckets controls the histogram buckets to be used // by the service graphs processor. -func (o *Overrides) MetricsGeneratorProcessorServiceGraphsHistogramBuckets(userID string) []float64 { - return o.getOverridesForUser(userID).MetricsGeneratorProcessorServiceGraphsHistogramBuckets +func (o *Overrides) MetricsGeneratorProcessorServiceGraphsHistogramBuckets(tenantID string) []float64 { + return o.getOverridesForTenant(tenantID).MetricsGeneratorProcessorServiceGraphsHistogramBuckets } // MetricsGeneratorProcessorServiceGraphsDimensions controls the dimensions that are added to the // service graphs processor. -func (o *Overrides) MetricsGeneratorProcessorServiceGraphsDimensions(userID string) []string { - return o.getOverridesForUser(userID).MetricsGeneratorProcessorServiceGraphsDimensions +func (o *Overrides) MetricsGeneratorProcessorServiceGraphsDimensions(tenantID string) []string { + return o.getOverridesForTenant(tenantID).MetricsGeneratorProcessorServiceGraphsDimensions } // MetricsGeneratorProcessorSpanMetricsHistogramBuckets controls the histogram buckets to be used // by the span metrics processor. -func (o *Overrides) MetricsGeneratorProcessorSpanMetricsHistogramBuckets(userID string) []float64 { - return o.getOverridesForUser(userID).MetricsGeneratorProcessorSpanMetricsHistogramBuckets +func (o *Overrides) MetricsGeneratorProcessorSpanMetricsHistogramBuckets(tenantID string) []float64 { + return o.getOverridesForTenant(tenantID).MetricsGeneratorProcessorSpanMetricsHistogramBuckets } // MetricsGeneratorProcessorSpanMetricsDimensions controls the dimensions that are added to the // span metrics processor. -func (o *Overrides) MetricsGeneratorProcessorSpanMetricsDimensions(userID string) []string { - return o.getOverridesForUser(userID).MetricsGeneratorProcessorSpanMetricsDimensions +func (o *Overrides) MetricsGeneratorProcessorSpanMetricsDimensions(tenantID string) []string { + return o.getOverridesForTenant(tenantID).MetricsGeneratorProcessorSpanMetricsDimensions } // MetricsGeneratorProcessorSpanMetricsIntrinsicDimensions controls the intrinsic dimensions such as service, span_kind, or // span_name that are activated or deactivated on the span metrics processor. -func (o *Overrides) MetricsGeneratorProcessorSpanMetricsIntrinsicDimensions(userID string) map[string]bool { - return o.getOverridesForUser(userID).MetricsGeneratorProcessorSpanMetricsIntrinsicDimensions +func (o *Overrides) MetricsGeneratorProcessorSpanMetricsIntrinsicDimensions(tenantID string) map[string]bool { + return o.getOverridesForTenant(tenantID).MetricsGeneratorProcessorSpanMetricsIntrinsicDimensions } // BlockRetention is the duration of the block retention for this tenant. -func (o *Overrides) BlockRetention(userID string) time.Duration { - return time.Duration(o.getOverridesForUser(userID).BlockRetention) +func (o *Overrides) BlockRetention(tenantID string) time.Duration { + return time.Duration(o.getOverridesForTenant(tenantID).BlockRetention) } // MaxSearchDuration is the duration of the max search duration for this tenant. -func (o *Overrides) MaxSearchDuration(userID string) time.Duration { - return time.Duration(o.getOverridesForUser(userID).MaxSearchDuration) +func (o *Overrides) MaxSearchDuration(tenantID string) time.Duration { + return time.Duration(o.getOverridesForTenant(tenantID).MaxSearchDuration) } -func (o *Overrides) getOverridesForUser(userID string) *Limits { +func (o *Overrides) getOverridesForTenant(tenantID string) *Limits { if tenantOverrides := o.tenantOverrides(); tenantOverrides != nil { - l := tenantOverrides.forUser(userID) + l := tenantOverrides.forTenant(tenantID) if l != nil { return l } - l = tenantOverrides.forUser(wildcardTenant) + l = tenantOverrides.forTenant(wildcardTenant) if l != nil { return l } @@ -395,9 +395,9 @@ func (o *Overrides) Collect(ch chan<- prometheus.Metric) { } for tenant, limits := range overrides.TenantLimits { - ch <- prometheus.MustNewConstMetric(metricOverridesLimitsDesc, prometheus.GaugeValue, float64(limits.MaxLocalTracesPerUser), MetricMaxLocalTracesPerUser, tenant) - ch <- prometheus.MustNewConstMetric(metricOverridesLimitsDesc, prometheus.GaugeValue, float64(limits.MaxGlobalTracesPerUser), MetricMaxGlobalTracesPerUser, tenant) - ch <- prometheus.MustNewConstMetric(metricOverridesLimitsDesc, prometheus.GaugeValue, float64(limits.MaxBytesPerSnapshot), MetricMaxBytesPerTrace, tenant) + ch <- prometheus.MustNewConstMetric(metricOverridesLimitsDesc, prometheus.GaugeValue, float64(limits.MaxLocalSnapshotsPerTenant), MetricMaxLocalSnapshotsPerTenant, tenant) + ch <- prometheus.MustNewConstMetric(metricOverridesLimitsDesc, prometheus.GaugeValue, float64(limits.MaxGlobalSnapshotsPerTenant), MetricMaxGlobalSnapshotsPerTenant, tenant) + ch <- prometheus.MustNewConstMetric(metricOverridesLimitsDesc, prometheus.GaugeValue, float64(limits.MaxBytesPerSnapshot), MetricMaxBytesPerSnapshot, tenant) ch <- prometheus.MustNewConstMetric(metricOverridesLimitsDesc, prometheus.GaugeValue, float64(limits.IngestionRateLimitBytes), MetricIngestionRateLimitBytes, tenant) ch <- prometheus.MustNewConstMetric(metricOverridesLimitsDesc, prometheus.GaugeValue, float64(limits.IngestionBurstSizeBytes), MetricIngestionBurstSizeBytes, tenant) ch <- prometheus.MustNewConstMetric(metricOverridesLimitsDesc, prometheus.GaugeValue, float64(limits.BlockRetention), MetricBlockRetention, tenant) diff --git a/modules/overrides/overrides_test.go b/modules/overrides/overrides_test.go index a3ba5ef..acc5625 100644 --- a/modules/overrides/overrides_test.go +++ b/modules/overrides/overrides_test.go @@ -48,11 +48,11 @@ func TestOverrides(t *testing.T) { { name: "limits only", limits: Limits{ - MaxGlobalTracesPerUser: 1, - MaxLocalTracesPerUser: 2, - MaxBytesPerSnapshot: 3, - IngestionBurstSizeBytes: 4, - IngestionRateLimitBytes: 5, + MaxGlobalSnapshotsPerTenant: 1, + MaxLocalSnapshotsPerTenant: 2, + MaxBytesPerSnapshot: 3, + IngestionBurstSizeBytes: 4, + IngestionRateLimitBytes: 5, }, expectedMaxGlobalTraces: map[string]int{"user1": 1, "user2": 1}, expectedMaxLocalTraces: map[string]int{"user1": 2, "user2": 2}, @@ -64,21 +64,21 @@ func TestOverrides(t *testing.T) { { name: "basic overrides", limits: Limits{ - MaxGlobalTracesPerUser: 1, - MaxLocalTracesPerUser: 2, - MaxBytesPerSnapshot: 3, - IngestionBurstSizeBytes: 4, - IngestionRateLimitBytes: 5, + MaxGlobalSnapshotsPerTenant: 1, + MaxLocalSnapshotsPerTenant: 2, + MaxBytesPerSnapshot: 3, + IngestionBurstSizeBytes: 4, + IngestionRateLimitBytes: 5, }, overrides: &perTenantOverrides{ TenantLimits: map[string]*Limits{ "user1": { - MaxGlobalTracesPerUser: 6, - MaxLocalTracesPerUser: 7, - MaxBytesPerSnapshot: 8, - IngestionBurstSizeBytes: 9, - IngestionRateLimitBytes: 10, - MaxSearchDuration: model.Duration(11 * time.Second), + MaxGlobalSnapshotsPerTenant: 6, + MaxLocalSnapshotsPerTenant: 7, + MaxBytesPerSnapshot: 8, + IngestionBurstSizeBytes: 9, + IngestionRateLimitBytes: 10, + MaxSearchDuration: model.Duration(11 * time.Second), }, }, }, @@ -92,28 +92,28 @@ func TestOverrides(t *testing.T) { { name: "wildcard override", limits: Limits{ - MaxGlobalTracesPerUser: 1, - MaxLocalTracesPerUser: 2, - MaxBytesPerSnapshot: 3, - IngestionBurstSizeBytes: 4, - IngestionRateLimitBytes: 5, + MaxGlobalSnapshotsPerTenant: 1, + MaxLocalSnapshotsPerTenant: 2, + MaxBytesPerSnapshot: 3, + IngestionBurstSizeBytes: 4, + IngestionRateLimitBytes: 5, }, overrides: &perTenantOverrides{ TenantLimits: map[string]*Limits{ "user1": { - MaxGlobalTracesPerUser: 6, - MaxLocalTracesPerUser: 7, - MaxBytesPerSnapshot: 8, - IngestionBurstSizeBytes: 9, - IngestionRateLimitBytes: 10, + MaxGlobalSnapshotsPerTenant: 6, + MaxLocalSnapshotsPerTenant: 7, + MaxBytesPerSnapshot: 8, + IngestionBurstSizeBytes: 9, + IngestionRateLimitBytes: 10, }, "*": { - MaxGlobalTracesPerUser: 11, - MaxLocalTracesPerUser: 12, - MaxBytesPerSnapshot: 13, - IngestionBurstSizeBytes: 14, - IngestionRateLimitBytes: 15, - MaxSearchDuration: model.Duration(16 * time.Second), + MaxGlobalSnapshotsPerTenant: 11, + MaxLocalSnapshotsPerTenant: 12, + MaxBytesPerSnapshot: 13, + IngestionBurstSizeBytes: 14, + IngestionRateLimitBytes: 15, + MaxSearchDuration: model.Duration(16 * time.Second), }, }, }, @@ -148,11 +148,11 @@ func TestOverrides(t *testing.T) { require.NoError(t, err) for user, expectedVal := range tt.expectedMaxLocalTraces { - assert.Equal(t, expectedVal, overrides.MaxLocalSnapshotsPerUser(user)) + assert.Equal(t, expectedVal, overrides.MaxLocalSnapshotsPerTenant(user)) } for user, expectedVal := range tt.expectedMaxGlobalTraces { - assert.Equal(t, expectedVal, overrides.MaxGlobalSnapshotsPerUser(user)) + assert.Equal(t, expectedVal, overrides.MaxGlobalSnapshotsPerTenant(user)) } for user, expectedVal := range tt.expectedIngestionBurstSpans {