Documentation
¶
Index ¶
- Variables
- func Checkpoint(logger *slog.Logger, w *wlog.WL, atIndex, batchSize int, ...) error
- type ActiveSeries
- type DB
- func (db *DB) Appender(context.Context) storage.Appender
- func (db *DB) AppenderV2(context.Context) storage.AppenderV2
- func (*DB) ChunkQuerier(int64, int64) (storage.ChunkQuerier, error)
- func (db *DB) Close() error
- func (*DB) ExemplarQuerier(context.Context) (storage.ExemplarQuerier, error)
- func (*DB) Querier(int64, int64) (storage.Querier, error)
- func (db *DB) SetWriteNotified(wn wlog.WriteNotified)
- func (*DB) StartTime() (int64, error)
- type DeletedSeries
- type Options
Constants ¶
This section is empty.
Variables ¶
var ( DefaultTruncateFrequency = 2 * time.Hour DefaultMinWALTime = int64(5 * time.Minute / time.Millisecond) DefaultMaxWALTime = int64(4 * time.Hour / time.Millisecond) )
Default values for options.
var ErrUnsupported = errors.New("unsupported operation with WAL-only storage")
Functions ¶
func Checkpoint ¶ added in v0.312.0
func Checkpoint(logger *slog.Logger, w *wlog.WL, atIndex, batchSize int, activeSeries iter.Seq[ActiveSeries], deletedSeries iter.Seq[DeletedSeries]) error
Checkpoint creates an unindexed checkpoint containing record.RefSeries and last timestamp for ActiveSeries and record.RefSeries for DeletedSeries.
This API accepts interfaces so downstream users of this package can provide their own series storage while reusing Prometheus checkpoint writing logic.
The difference between this implementation and wlog.Checkpoint is that it skips re-read current checkpoint + segments and relies on data in memory.
Types ¶
type ActiveSeries ¶ added in v0.312.0
type ActiveSeries interface {
Ref() chunks.HeadSeriesRef
Labels() labels.Labels
LastSampleTimestamp() int64
}
ActiveSeries describes a live series to be written by Checkpoint.
This interface is intentionally exported so downstream users of this package can use Checkpoint without depending on Prometheus internal series types.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents a WAL-only storage. It implements storage.DB.
func Open ¶
func Open(l *slog.Logger, reg prometheus.Registerer, rs *remote.Storage, dir string, opts *Options) (*DB, error)
Open returns a new agent.DB in the given directory.
func (*DB) AppenderV2 ¶ added in v0.309.0
func (db *DB) AppenderV2(context.Context) storage.AppenderV2
AppenderV2 implements storage.AppenderV2.
func (*DB) ChunkQuerier ¶
ChunkQuerier implements the Storage interface.
func (*DB) ExemplarQuerier ¶
ExemplarQuerier implements the Storage interface.
func (*DB) SetWriteNotified ¶ added in v0.48.1
func (db *DB) SetWriteNotified(wn wlog.WriteNotified)
SetWriteNotified allows to set an instance to notify when a write happens. It must be used during initialization. It is not safe to use it during execution.
type DeletedSeries ¶ added in v0.312.0
type DeletedSeries interface {
Ref() chunks.HeadSeriesRef
Labels() labels.Labels
}
DeletedSeries describes a deleted series to be written by Checkpoint.
This interface is intentionally exported so downstream users of this package can use Checkpoint without depending on Prometheus internal series types.
type Options ¶
type Options struct {
// Segments (wal files) max size.
// WALSegmentSize <= 0, segment size is default size.
// WALSegmentSize > 0, segment size is WALSegmentSize.
WALSegmentSize int
// WALCompression configures the compression type to use on records in the WAL.
WALCompression compression.Type
// StripeSize is the size (power of 2) in entries of the series hash map. Reducing the size will save memory but impact performance.
StripeSize int
// TruncateFrequency determines how frequently to truncate data from the WAL.
TruncateFrequency time.Duration
// Shortest and longest amount of time data can exist in the WAL before being
// deleted.
MinWALTime, MaxWALTime int64
// NoLockfile disables creation and consideration of a lock file.
NoLockfile bool
// OutOfOrderTimeWindow specifies how much out of order is allowed, if any.
OutOfOrderTimeWindow int64
// EnableSTAsZeroSample represents 'created-timestamp-zero-ingestion' feature flag.
// If true, ST, if non-empty and earlier than sample timestamp, will be stored
// as a zero sample before the actual sample.
//
// The zero sample is best-effort, only debug log on failure is emitted.
// NOTE(bwplotka): This feature might be deprecated and removed once PROM-60
// is implemented.
EnableSTAsZeroSample bool
// EnableSTStorage determines whether agent DB should write a Start Timestamp (ST)
// per sample to WAL.
// Controlled by the `--enable-feature=st-storage` CLI flag; when enabled, ST is
// persisted to the WAL for samples that include a non-zero start timestamp in
// supported record types.
EnableSTStorage bool
// CheckpointFromInMemorySeries changes checkpoint implementation to use only in-memory series data when building a checkpoint.
// This prevents re-reading the previous checkpoint and segments from disk.
CheckpointFromInMemorySeries bool
// CheckpointBatchSize specifies a size of a single WAL log entry chunk to be flushed.
//
// Has no effect if CheckpointFromInMemorySeries is false.
CheckpointBatchSize int
}
Options of the WAL storage.
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions used for the WAL storage. They are reasonable for setups using millisecond-precision timestamps.