local

package
v0.0.0-...-bfdd474 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2015 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package local contains the local time series storage used by Prometheus.

Index

Constants

View Source
const (
	// Version of the storage as it can be found in the version file.
	// Increment to protect against incompatible changes.
	Version = 1
)

Variables

View Source
var DefaultChunkEncoding = doubleDelta

The DefaultChunkEncoding can be changed via a flag.

Functions

func NewTestStorage

func NewTestStorage(t testutil.T, encoding chunkEncoding) (*memorySeriesStorage, testutil.Closer)

NewTestStorage creates a storage instance backed by files in a temporary directory. The returned storage is already in serving state. Upon closing the returned test.Closer, the temporary directory is cleaned up.

Types

type MemorySeriesStorageOptions

type MemorySeriesStorageOptions struct {
	MemoryChunks               int           // How many chunks to keep in memory.
	MaxChunksToPersist         int           // Max number of chunks waiting to be persisted.
	PersistenceStoragePath     string        // Location of persistence files.
	PersistenceRetentionPeriod time.Duration // Chunks at least that old are dropped.
	CheckpointInterval         time.Duration // How often to checkpoint the series map and head chunks.
	CheckpointDirtySeriesLimit int           // How many dirty series will trigger an early checkpoint.
	Dirty                      bool          // Force the storage to consider itself dirty on startup.
	PedanticChecks             bool          // If dirty, perform crash-recovery checks on each series file.
	SyncStrategy               SyncStrategy  // Which sync strategy to apply to series files.
}

MemorySeriesStorageOptions contains options needed by NewMemorySeriesStorage. It is not safe to leave any of those at their zero values.

type Preloader

type Preloader interface {
	PreloadRange(
		fp model.Fingerprint,
		from model.Time, through model.Time,
		stalenessDelta time.Duration,
	) error
	// Close unpins any previously requested series data from memory.
	Close()
}

A Preloader preloads series data necessary for a query into memory and pins them until released via Close(). Its methods are generally not goroutine-safe.

type SeriesIterator

type SeriesIterator interface {
	// Gets the two values that are immediately adjacent to a given time. In
	// case a value exist at precisely the given time, only that single
	// value is returned. Only the first or last value is returned (as a
	// single value), if the given time is before or after the first or last
	// value, respectively.
	ValueAtTime(model.Time) []model.SamplePair
	// Gets the boundary values of an interval: the first and last value
	// within a given interval.
	BoundaryValues(metric.Interval) []model.SamplePair
	// Gets all values contained within a given interval.
	RangeValues(metric.Interval) []model.SamplePair
}

SeriesIterator enables efficient access of sample values in a series. Its methods are not goroutine-safe. A SeriesIterator iterates over a snapshot of a series, i.e. it is safe to continue using a SeriesIterator after or during modifying the corresponding series, but the iterator will represent the state of the series prior the modification.

type Storage

type Storage interface {
	prometheus.Collector
	// Append stores a sample in the Storage. Multiple samples for the same
	// fingerprint need to be submitted in chronological order, from oldest
	// to newest. When Append has returned, the appended sample might not be
	// queryable immediately. (Use WaitForIndexing to wait for complete
	// processing.) The implementation might remove labels with empty value
	// from the provided Sample as those labels are considered equivalent to
	// a label not present at all.
	Append(*model.Sample)
	// NewPreloader returns a new Preloader which allows preloading and pinning
	// series data into memory for use within a query.
	NewPreloader() Preloader
	// MetricsForLabelMatchers returns the metrics from storage that satisfy the given
	// label matchers. At least one label matcher must be specified that does not
	// match the empty string.
	MetricsForLabelMatchers(...*metric.LabelMatcher) map[model.Fingerprint]metric.Metric
	// LastSamplePairForFingerprint returns the last sample pair for the
	// provided fingerprint. If the respective time series does not exist or
	// has an evicted head chunk, nil is returned.
	LastSamplePairForFingerprint(model.Fingerprint) *model.SamplePair
	// Get all of the label values that are associated with a given label name.
	LabelValuesForLabelName(model.LabelName) model.LabelValues
	// Get the metric associated with the provided fingerprint.
	MetricForFingerprint(model.Fingerprint) metric.Metric
	// Construct an iterator for a given fingerprint.
	// The iterator will never return samples older than retention time,
	// relative to the time NewIterator was called.
	NewIterator(model.Fingerprint) SeriesIterator
	// Drop all time series associated with the given fingerprints. This operation
	// will not show up in the series operations metrics.
	DropMetricsForFingerprints(...model.Fingerprint)
	// Run the various maintenance loops in goroutines. Returns when the
	// storage is ready to use. Keeps everything running in the background
	// until Stop is called.
	Start() error
	// Stop shuts down the Storage gracefully, flushes all pending
	// operations, stops all maintenance loops,and frees all resources.
	Stop() error
	// WaitForIndexing returns once all samples in the storage are
	// indexed. Indexing is needed for FingerprintsForLabelMatchers and
	// LabelValuesForLabelName and may lag behind.
	WaitForIndexing()
}

Storage ingests and manages samples, along with various indexes. All methods are goroutine-safe. Storage implements storage.SampleAppender.

func NewMemorySeriesStorage

func NewMemorySeriesStorage(o *MemorySeriesStorageOptions) Storage

NewMemorySeriesStorage returns a newly allocated Storage. Storage.Serve still has to be called to start the storage.

type SyncStrategy

type SyncStrategy int

SyncStrategy is an enum to select a sync strategy for series files.

const (
	Never SyncStrategy
	Always
	Adaptive
)

Possible values for SyncStrategy.

func (*SyncStrategy) Set

func (ss *SyncStrategy) Set(s string) error

Set implements flag.Value.

func (SyncStrategy) String

func (ss SyncStrategy) String() string

String implements flag.Value.

Directories

Path Synopsis
Package codable provides types that implement encoding.BinaryMarshaler and encoding.BinaryUnmarshaler and functions that help to encode and decode primitives.
Package codable provides types that implement encoding.BinaryMarshaler and encoding.BinaryUnmarshaler and functions that help to encode and decode primitives.
Package index provides a number of indexes backed by persistent key-value stores.
Package index provides a number of indexes backed by persistent key-value stores.

Jump to

Keyboard shortcuts

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