cleaner

package
v3.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

This directory was copied and adapted from https://github.com/grafana/agent/tree/main/pkg/metrics. We cannot vendor the agent in since the agent vendors loki in, which would cause a cyclic dependency. NOTE: many changes have been made to the original code for our use-case.

Index

Constants

View Source
const (
	DefaultCleanupAge    = 12 * time.Hour
	DefaultCleanupPeriod = 0 * time.Second // disabled by default
)

Default settings for the WAL cleaner.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MinAge time.Duration `yaml:"min_age,omitempty"`
	Period time.Duration `yaml:"period,omitempty"`
}

Config specifies the configurable settings of the WAL cleaner

func (*Config) RegisterFlags

func (c *Config) RegisterFlags(f *flag.FlagSet)

func (*Config) Validate

func (c *Config) Validate() error

type Metrics

type Metrics struct {
	DiscoveryError     *prometheus.CounterVec
	SegmentError       *prometheus.CounterVec
	ManagedStorage     prometheus.Gauge
	AbandonedStorage   prometheus.Gauge
	CleanupRunsSuccess prometheus.Counter
	CleanupRunsErrors  prometheus.Counter
	CleanupTimes       prometheus.Histogram
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(r prometheus.Registerer) *Metrics

func (*Metrics) Unregister

func (m *Metrics) Unregister()

type WALCleaner

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

WALCleaner periodically checks for Write Ahead Logs (WALs) that are not associated with any active instance.ManagedInstance and have not been written to in some configured amount of time and deletes them.

func NewWALCleaner

func NewWALCleaner(logger log.Logger, manager instance.Manager, metrics *Metrics, walDirectory string, cfg Config) *WALCleaner

NewWALCleaner creates a new cleaner that looks for abandoned WALs in the given directory and removes them if they haven't been modified in over minAge. Starts a goroutine to periodically run the cleanup method in a loop

func (*WALCleaner) Stop

func (c *WALCleaner) Stop()

Stop the cleaner and any background tasks running

Jump to

Keyboard shortcuts

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