retention

package
v3.7.3 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyMarkers

func CopyMarkers(src string, dst client.ObjectClient, dstName string) error

CopyMarkers checks for markers in the src dir and copies them to the dst. dstName must be a human-readable name for what dst is.

func ExtractIntervalFromTableName

func ExtractIntervalFromTableName(tableName string) model.Interval

ExtractIntervalFromTableName gives back the time interval for which the table is expected to hold the chunks index.

Types

type Chunk added in v3.5.0

type Chunk struct {
	ChunkID string
	From    model.Time
	Through model.Time
}

func (Chunk) String added in v3.5.0

func (c Chunk) String() string

type ChunkClient

type ChunkClient interface {
	DeleteChunk(ctx context.Context, userID, chunkID string) error
	IsChunkNotFoundErr(err error) bool
}

type ExpirationChecker

type ExpirationChecker interface {
	Expired(userID []byte, chk Chunk, lbls labels.Labels, seriesID []byte, tableName string, now model.Time) (bool, filter.Func)
	IntervalMayHaveExpiredChunks(interval model.Interval, userID string) bool
	MarkPhaseStarted()
	MarkPhaseFailed()
	MarkPhaseTimedOut()
	MarkPhaseFinished()
	DropFromIndex(userID []byte, chk Chunk, labels labels.Labels, tableEndTime model.Time, now model.Time) bool
	CanSkipSeries(userID []byte, lbls labels.Labels, seriesID []byte, seriesStart model.Time, tableName string, now model.Time) bool
	MarkSeriesAsProcessed(userID, seriesID []byte, lbls labels.Labels, tableName string) error
}

func NeverExpiringExpirationChecker

func NeverExpiringExpirationChecker(_ Limits) ExpirationChecker

NeverExpiringExpirationChecker returns an expiration checker that never expires anything

func NewExpirationChecker

func NewExpirationChecker(limits Limits) ExpirationChecker

type IndexCleaner added in v3.5.0

type IndexCleaner interface {
	RemoveChunk(from, through model.Time, userID []byte, labels labels.Labels, chunkID string) (bool, error)
	// CleanupSeries is for cleaning up the series that do have any chunks left in the index.
	// It would only be called for the series that have all their chunks deleted without adding new ones.
	CleanupSeries(userID []byte, lbls labels.Labels) error
}

type IndexProcessor

type IndexProcessor interface {
	SeriesIterator

	IndexCleaner
	ChunkExists(userID []byte, lbls labels.Labels, chunkRef logproto.ChunkRef) (bool, error)
	// contains filtered or unexported methods
}

type IntervalFilter

type IntervalFilter struct {
	Interval model.Interval
	Filter   filter.Func
}

IntervalFilter contains the interval to delete and the function that filters lines. These will be applied to a chunk.

type Limits

type Limits interface {
	RetentionPeriod(userID string) time.Duration
	StreamRetention(userID string) []validation.StreamRetention
	AllByUserID() map[string]*validation.Limits
	DefaultLimits() *validation.Limits
	PoliciesStreamMapping(userID string) validation.PolicyStreamMapping
}

type Marker

type Marker struct {
	// contains filtered or unexported fields
}

func NewMarker

func NewMarker(markerStorageClient client.ObjectClient, expiration ExpirationChecker, markTimeout time.Duration, chunkClient client.Client, r prometheus.Registerer) (*Marker, error)

func (*Marker) FindAndMarkChunksForDeletion added in v3.6.0

func (t *Marker) FindAndMarkChunksForDeletion(ctx context.Context, tableName, userID string, indexProcessor IndexProcessor, logger log.Logger) (bool, bool, error)

FindAndMarkChunksForDeletion finds expired chunks using the ExpirationChecker from the given table and marks them for deletion.

func (*Marker) MarkChunksForDeletion added in v3.6.0

func (t *Marker) MarkChunksForDeletion(tableName string, chunks []string) error

MarkChunksForDeletion marks the given list of chunks for deletion

type MarkerProcessor

type MarkerProcessor interface {
	// Start starts parsing marks and calling deleteFunc for each.
	// If deleteFunc returns no error the mark is deleted from the storage.
	// Otherwise the mark will reappears in future iteration.
	Start(deleteFunc func(ctx context.Context, chunkId []byte) error)
	// Stop stops processing marks.
	Stop()
}

type MarkerStorageWriter

type MarkerStorageWriter interface {
	Put(chunkID []byte) error
	Count() int64
	Close() error
}

func NewMarkerWriter added in v3.7.0

func NewMarkerWriter(markerStorageClient client.ObjectClient) (MarkerStorageWriter, error)

type Series added in v3.5.0

type Series interface {
	SeriesID() []byte
	UserID() []byte
	Labels() labels.Labels
	Chunks() []Chunk
	Reset(seriesID, userID []byte, labels labels.Labels)
	AppendChunks(ref ...Chunk)
}

func NewSeries added in v3.6.0

func NewSeries() Series

type SeriesCallback added in v3.5.0

type SeriesCallback func(series Series) (err error)

type SeriesIterator added in v3.5.0

type SeriesIterator interface {
	ForEachSeries(ctx context.Context, callback SeriesCallback) error
}

type Sweeper

type Sweeper struct {
	// contains filtered or unexported fields
}

func NewSweeper

func NewSweeper(
	markerStorageClient client.ObjectClient,
	deleteClient ChunkClient,
	deleteWorkerCount int,
	minAgeDelete time.Duration,
	backoffConfig backoff.Config,
	r prometheus.Registerer,
) (*Sweeper, error)

func (*Sweeper) Start

func (s *Sweeper) Start()

func (*Sweeper) Stop

func (s *Sweeper) Stop()

type TableMarker

type TableMarker interface {
	// FindAndMarkChunksForDeletion marks chunks to delete for a given table and returns if it's empty or modified.
	FindAndMarkChunksForDeletion(ctx context.Context, tableName, userID string, indexProcessor IndexProcessor, logger log.Logger) (bool, bool, error)

	// MarkChunksForDeletion marks the given list of chunks for deletion
	MarkChunksForDeletion(tableName string, chunks []string) error
}

type TenantRetentionSnapshot added in v3.5.0

type TenantRetentionSnapshot struct {
	// contains filtered or unexported fields
}

TenantRetentionSnapshot is a snapshot of retention rules for a tenant. The underlying retention rules may change on the original limits object passed to NewTenantRetentionSnapshot, but the snapshot is immutable.

func NewTenantRetentionSnapshot added in v3.5.0

func NewTenantRetentionSnapshot(limits Limits, userID string) *TenantRetentionSnapshot

func (*TenantRetentionSnapshot) RetentionHoursFor added in v3.5.0

func (r *TenantRetentionSnapshot) RetentionHoursFor(lbs labels.Labels) string

func (*TenantRetentionSnapshot) RetentionPeriodFor added in v3.5.0

func (r *TenantRetentionSnapshot) RetentionPeriodFor(lbs labels.Labels) time.Duration

type TenantsRetention

type TenantsRetention struct {
	// contains filtered or unexported fields
}

func NewTenantsRetention

func NewTenantsRetention(l Limits) *TenantsRetention

func (*TenantsRetention) RetentionHoursFor added in v3.5.0

func (tr *TenantsRetention) RetentionHoursFor(userID string, lbs labels.Labels) string

func (*TenantsRetention) RetentionPeriodFor

func (tr *TenantsRetention) RetentionPeriodFor(userID string, lbs labels.Labels) time.Duration

Jump to

Keyboard shortcuts

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