Documentation
¶
Overview ¶
Package tsdb wraps the Prometheus TSDB with rule-derived retention, a size ceiling, and pressure shrinking.
Index ¶
- Constants
- func ClampRetention(r time.Duration) time.Duration
- type DB
- func (d *DB) Appender(ctx context.Context) storage.Appender
- func (d *DB) Close() error
- func (d *DB) Querier(mint, maxt int64) (storage.Querier, error)
- func (d *DB) Relax() error
- func (d *DB) Retention() time.Duration
- func (d *DB) SetMaxBytes(n int64) error
- func (d *DB) SetRetention(r time.Duration) (time.Duration, error)
- func (d *DB) Shrink(ctx context.Context, target int64) (freed int64, err error)
- func (d *DB) Size() int64
- func (d *DB) Stats() Stats
- type Options
- type Stats
Constants ¶
View Source
const ( DefaultBlockDuration = 30 * time.Minute DefaultWALSegmentBytes = 8 << 20 )
Defaults.
View Source
const HardCeiling = 6 * time.Hour
HardCeiling bounds retention regardless of what rules request.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is an open local TSDB. It implements storage.Queryable and storage.Appendable.
func (*DB) SetMaxBytes ¶
SetMaxBytes changes the configured size bound; zero disables it.
func (*DB) SetRetention ¶
SetRetention applies a rule-derived retention (clamped) and returns the effective value.
func (*DB) Shrink ¶
Shrink drops the oldest data toward target and keeps target as a size limit until Relax.
type Options ¶
type Options struct {
// Retention is derived from rules; zero or anything above HardCeiling means HardCeiling.
Retention time.Duration
// MaxBytes bounds blocks, WAL, and head chunks together; zero disables the size bound.
MaxBytes int64
// BlockDuration is the head compaction granularity, which is also the retention granularity.
BlockDuration time.Duration
// WALSegmentBytes must be a multiple of 32 KiB.
WALSegmentBytes int
Logger *slog.Logger
}
Options configures Open.
Click to show internal directories.
Click to hide internal directories.