mirror of
https://github.com/grafana/tempo.git
synced 2025-03-14 03:06:42 +00:00
Allow compaction disable per tenant (#3965)
* Allow compaction disable per tenant * Update mock * Rename legacy yaml key * Rename methods and fields for clarity about disablement * Rename methods and fields for clarity about disablement * Update changelog
This commit is contained in:
@ -49,6 +49,7 @@
|
||||
* [ENHANCEMENT] Added new Traces api V2[#3912](https://github.com/grafana/tempo/pull/3912) (@javiermolinar)
|
||||
* [ENHANCEMENT] Update to the latest dskit [#3915](https://github.com/grafana/tempo/pull/3915) (@andreasgerstmayr)
|
||||
* [ENHANCEMENT] Reduce allocs building queriers sharded requests [#3932](https://github.com/grafana/tempo/pull/3932) (@javiermolinar)
|
||||
* [ENHANCEMENT] Allow compaction disablement per-tenant [#3965](https://github.com/grafana/tempo/pull/3965) (@zalegrala)
|
||||
|
||||
* [ENHANCEMENT] Implement polling tenants concurrently [#3647](https://github.com/grafana/tempo/pull/3647) (@zalegrala)
|
||||
* [BUGFIX] Fix panic in certain metrics queries using `rate()` with `by` [#3847](https://github.com/grafana/tempo/pull/3847) (@stoewer)
|
||||
|
@ -254,6 +254,11 @@ func (c *Compactor) BlockRetentionForTenant(tenantID string) time.Duration {
|
||||
return c.overrides.BlockRetention(tenantID)
|
||||
}
|
||||
|
||||
// CompactionDisabledForTenant implements CompactorOverrides
|
||||
func (c *Compactor) CompactionDisabledForTenant(tenantID string) bool {
|
||||
return c.overrides.CompactionDisabled(tenantID)
|
||||
}
|
||||
|
||||
func (c *Compactor) MaxBytesPerTraceForTenant(tenantID string) int {
|
||||
return c.overrides.MaxBytesPerTrace(tenantID)
|
||||
}
|
||||
|
@ -164,8 +164,9 @@ type ReadOverrides struct {
|
||||
|
||||
type CompactionOverrides struct {
|
||||
// Compactor enforced overrides.
|
||||
BlockRetention model.Duration `yaml:"block_retention,omitempty" json:"block_retention,omitempty"`
|
||||
CompactionWindow model.Duration `yaml:"compaction_window,omitempty" json:"compaction_window,omitempty"`
|
||||
BlockRetention model.Duration `yaml:"block_retention,omitempty" json:"block_retention,omitempty"`
|
||||
CompactionWindow model.Duration `yaml:"compaction_window,omitempty" json:"compaction_window,omitempty"`
|
||||
CompactionDisabled bool `yaml:"compaction_disabled,omitempty" json:"compaction_disabled,omitempty"`
|
||||
}
|
||||
|
||||
type GlobalOverrides struct {
|
||||
|
@ -117,8 +117,9 @@ type LegacyOverrides struct {
|
||||
MetricsGeneratorIngestionSlack time.Duration `yaml:"metrics_generator_ingestion_time_range_slack" json:"metrics_generator_ingestion_time_range_slack"`
|
||||
|
||||
// Compactor enforced limits.
|
||||
BlockRetention model.Duration `yaml:"block_retention" json:"block_retention"`
|
||||
CompactionWindow model.Duration `yaml:"compaction_window" json:"compaction_window"`
|
||||
BlockRetention model.Duration `yaml:"block_retention" json:"block_retention"`
|
||||
CompactionDisabled bool `yaml:"compaction_disabled" json:"compaction_disabled"`
|
||||
CompactionWindow model.Duration `yaml:"compaction_window" json:"compaction_window"`
|
||||
|
||||
// Querier and Ingester enforced limits.
|
||||
MaxBytesPerTagValuesQuery int `yaml:"max_bytes_per_tag_values_query" json:"max_bytes_per_tag_values_query"`
|
||||
@ -155,8 +156,9 @@ func (l *LegacyOverrides) toNewLimits() Overrides {
|
||||
UnsafeQueryHints: l.UnsafeQueryHints,
|
||||
},
|
||||
Compaction: CompactionOverrides{
|
||||
BlockRetention: l.BlockRetention,
|
||||
CompactionWindow: l.CompactionWindow,
|
||||
BlockRetention: l.BlockRetention,
|
||||
CompactionDisabled: l.CompactionDisabled,
|
||||
CompactionWindow: l.CompactionWindow,
|
||||
},
|
||||
MetricsGenerator: MetricsGeneratorOverrides{
|
||||
RingSize: l.MetricsGeneratorRingSize,
|
||||
|
@ -71,6 +71,7 @@ type Interface interface {
|
||||
MetricsGeneratorProcessorServiceGraphsEnableVirtualNodeLabel(userID string) bool
|
||||
MetricsGeneratorProcessorSpanMetricsTargetInfoExcludedDimensions(userID string) []string
|
||||
BlockRetention(userID string) time.Duration
|
||||
CompactionDisabled(userID string) bool
|
||||
MaxSearchDuration(userID string) time.Duration
|
||||
MaxMetricsDuration(userID string) time.Duration
|
||||
DedicatedColumns(userID string) backend.DedicatedColumns
|
||||
|
@ -515,6 +515,11 @@ func (o *runtimeConfigOverridesManager) BlockRetention(userID string) time.Durat
|
||||
return time.Duration(o.getOverridesForUser(userID).Compaction.BlockRetention)
|
||||
}
|
||||
|
||||
// CompactionDisabled will not compact tenants which have this enabled.
|
||||
func (o *runtimeConfigOverridesManager) CompactionDisabled(userID string) bool {
|
||||
return o.getOverridesForUser(userID).Compaction.CompactionDisabled
|
||||
}
|
||||
|
||||
func (o *runtimeConfigOverridesManager) DedicatedColumns(userID string) backend.DedicatedColumns {
|
||||
return o.getOverridesForUser(userID).Storage.DedicatedColumns
|
||||
}
|
||||
|
@ -104,6 +104,12 @@ func (rw *readerWriter) doCompaction(ctx context.Context) {
|
||||
|
||||
// Select the next tenant to run compaction for
|
||||
tenantID := tenants[rw.compactorTenantOffset]
|
||||
|
||||
// Skip compaction for tenants which have it disabled.
|
||||
if rw.compactorOverrides.CompactionDisabledForTenant(tenantID) {
|
||||
return
|
||||
}
|
||||
|
||||
// Get the meta file of all non-compacted blocks for the given tenant
|
||||
blocklist := rw.blocklist.Metas(tenantID)
|
||||
|
||||
|
@ -48,6 +48,7 @@ func (m *mockJobSharder) Owns(string) bool { return true }
|
||||
|
||||
type mockOverrides struct {
|
||||
blockRetention time.Duration
|
||||
disabled bool
|
||||
maxBytesPerTrace int
|
||||
maxCompactionWindow time.Duration
|
||||
}
|
||||
@ -56,6 +57,10 @@ func (m *mockOverrides) BlockRetentionForTenant(_ string) time.Duration {
|
||||
return m.blockRetention
|
||||
}
|
||||
|
||||
func (m *mockOverrides) CompactionDisabledForTenant(_ string) bool {
|
||||
return m.disabled
|
||||
}
|
||||
|
||||
func (m *mockOverrides) MaxBytesPerTraceForTenant(_ string) int {
|
||||
return m.maxBytesPerTrace
|
||||
}
|
||||
|
@ -108,6 +108,7 @@ type CompactorSharder interface {
|
||||
|
||||
type CompactorOverrides interface {
|
||||
BlockRetentionForTenant(tenantID string) time.Duration
|
||||
CompactionDisabledForTenant(tenantID string) bool
|
||||
MaxBytesPerTraceForTenant(tenantID string) int
|
||||
MaxCompactionRangeForTenant(tenantID string) time.Duration
|
||||
}
|
||||
|
Reference in New Issue
Block a user