tsdb

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBlock

func CreateBlock(ctx context.Context, series []storage.Series, dir string, extendMeta func(tsdb.BlockMeta) interface{}) (ulid.ULID, error)

CreateBlock uses supplied series with samples, and generates new TSDB block.

CreateBlock creates new subdirectory for the block in supplied directory, and returns generated block ID. Block is only fully written if there was no returned error.

It is safe to call CreateBlock multiple times (also concurrently) using the same directory. Each call will generate different block ID.

Unlike Builder, CreateBlock uses only in-memory data, and assumes that series are already sorted by label.

func ReadMetaFile

func ReadMetaFile(blockDir string) (*tsdb.BlockMeta, error)

ReadMetaFile is a convenience function for reading meta files.

Types

type Builder

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

Builder helps to build TSDB block. All series that should be included in the TSDB block should be added using AddSeriesWithSamples method. After adding all series, FinishBlock will complete the writing of the block.

func NewBuilder

func NewBuilder(workDirectory string, opts Options) (*Builder, error)

NewBuilder creates builder for building a single TSDB block. Multiple builders can use the same work directory, each builder will create subdirectory for the block that it's building. This subdirectory will be a valid TSDB block only if at no point Builder returns an error from any of its methods.

func (*Builder) AddSeriesWithSamples

func (b *Builder) AddSeriesWithSamples(lbls labels.Labels, samples chunkenc.Iterator) error

AddSeriesWithSamples adds single series to the block builder. AddSeriesWithSamples can be called with series in random order, and even concurrently from different goroutines.

func (*Builder) FinishBlock

func (b *Builder) FinishBlock(ctx context.Context, extendMeta func(tsdb.BlockMeta) interface{}) (ulid.ULID, error)

FinishBlock will build the final TSDB block from series added previously via AddSeriesWithSamples. FinishBlock should only be called once, after all calls to AddSeriesWithSamples have finished successfully. It is caller's responsibility to guarantee that, otherwise races will happen. Calling another AddSeriesWithSamples after FinishBlock has been called is undefined, and will likely panic for some reason.

extendMeta function can return either passed meta, or return another object that will be stored into meta.json file. Eg. Grafana Mimir stores metadata.Meta (from Thanos) into the meta.json file.

type Options

type Options struct {
	SymbolsBatchSize int // How many symbols to keep in memory, before flushing them to files.
	SeriesBatchSize  int // How many series to keep in memory, before flushing them to files.

	MinBlockTime time.Time // If not zero, samples with timestamp lower than this value will be ignored.
	MaxBlockTime time.Time // If not zero, samples with timestamp equal of higher than this value will be ignored.
}

Options for Builder.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns default builder options that can be used in NewBuilder function.

Jump to

Keyboard shortcuts

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