storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound                    = errors.New("not found")
	ErrOutOfOrderSample            = errors.New("out of order sample")
	ErrDuplicateSampleForTimestamp = errors.New("duplicate sample for timestamp")
	ErrOutOfBounds                 = errors.New("out of bounds")
)

The errors exposed.

View Source
var (
	// DefaultRemoteReadConfig is the default remote read configuration.
	DefaultRemoteReadConfig = RemoteReadConfig{
		RemoteTimeout: model.Duration(1 * time.Minute),
	}
)
View Source
var NoopSeriesIt = noopSeriesIterator{}

NoopSeriesIt is a SeriesIterator that does nothing.

Functions

func ToQuery

func ToQuery(from, to int64, matchers []*labels.Matcher, p *SelectParams) (*prompb.Query, error)

ToQuery builds a Query proto.

Types

type Appender

type Appender interface {
	Add(l labels.Labels, t int64, v float64) (uint64, error)

	AddFast(l labels.Labels, ref uint64, t int64, v float64) error

	// Commit submits the collected samples and purges the batch.
	Commit() error

	Rollback() error
}

Appender provides batched appends against a storage.

type BufferedSeriesIterator

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

BufferedSeriesIterator wraps an iterator with a look-back buffer.

func NewBuffer

func NewBuffer(delta int64) *BufferedSeriesIterator

NewBuffer returns a new iterator that buffers the values within the time range of the current element and the duration of delta before, initialized with an empty iterator. Use Reset() to set an actual iterator to be buffered.

func NewBufferIterator

func NewBufferIterator(it SeriesIterator, delta int64) *BufferedSeriesIterator

NewBufferIterator returns a new iterator that buffers the values within the time range of the current element and the duration of delta before.

func (*BufferedSeriesIterator) Buffer

Buffer returns an iterator over the buffered data. Invalidates previously returned iterators.

func (*BufferedSeriesIterator) Err

func (b *BufferedSeriesIterator) Err() error

Err returns the last encountered error.

func (*BufferedSeriesIterator) Next

func (b *BufferedSeriesIterator) Next() bool

Next advances the iterator to the next element.

func (*BufferedSeriesIterator) PeekBack

func (b *BufferedSeriesIterator) PeekBack(n int) (t int64, v float64, ok bool)

PeekBack returns the nth previous element of the iterator. If there is none buffered, ok is false.

func (*BufferedSeriesIterator) ReduceDelta

func (b *BufferedSeriesIterator) ReduceDelta(delta int64) bool

ReduceDelta lowers the buffered time delta, for the current SeriesIterator only.

func (*BufferedSeriesIterator) Reset

Reset re-uses the buffer with a new iterator, resetting the buffered time delta to its original value.

func (*BufferedSeriesIterator) Seek

func (b *BufferedSeriesIterator) Seek(t int64) bool

Seek advances the iterator to the element at time t or greater.

func (*BufferedSeriesIterator) Values

func (b *BufferedSeriesIterator) Values() (int64, float64)

Values returns the current element of the iterator.

type Client

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

Client allows reading and writing from/to a remote HTTP endpoint.

func NewClient

func NewClient(index int, conf *ClientConfig) (*Client, error)

NewClient creates a new Client.

func (Client) Name

func (c Client) Name() string

Name identifies the client.

func (*Client) Read

func (c *Client) Read(ctx context.Context, query *prompb.Query) (*prompb.QueryResult, error)

Read reads from a remote endpoint.

func (*Client) Store

func (c *Client) Store(ctx context.Context, req *prompb.WriteRequest) error

Store sends a batch of samples to the HTTP endpoint.

type ClientConfig

type ClientConfig struct {
	URL              *config_util.URL
	Timeout          model.Duration
	HTTPClientConfig config_util.HTTPClientConfig
}

ClientConfig configures a Client.

type Querier

type Querier interface {
	// Select returns a set of series that matches the given label matchers.
	Select(*SelectParams, ...*labels.Matcher) (SeriesSet, error)

	// LabelValues returns all potential values for a label name.
	LabelValues(name string) ([]string, error)

	// Close releases the resources of the Querier.
	Close() error
}

Querier provides reading access to time series data.

func NewMergeQuerier added in v0.0.4

func NewMergeQuerier(queriers []Querier) Querier

NewMergeQuerier returns a new Querier that merges results of input queriers. NB NewMergeQuerier will return NoopQuerier if no queriers are passed to it, and will filter NoopQueriers from its arguments, in order to reduce overhead when only one querier is passed.

func NoopQuerier

func NoopQuerier() Querier

NoopQuerier is a Querier that does nothing.

type Queryable

type Queryable interface {
	// Querier returns a new Querier on the storage.
	Querier(ctx context.Context, mint, maxt int64) (Querier, error)
}

A Queryable handles queries against a storage.

func QueryableClient

func QueryableClient(c *Client) Queryable

QueryableClient returns a storage.Queryable which queries the given Client to select series sets.

func RequiredMatchersFilter

func RequiredMatchersFilter(next Queryable, required []*labels.Matcher) Queryable

RequiredMatchersFilter returns a storage.Queryable which creates a requiredMatchersQuerier.

type QueryableFunc

type QueryableFunc func(ctx context.Context, mint, maxt int64) (Querier, error)

QueryableFunc is an adapter to allow the use of ordinary functions as Queryables. It follows the idea of http.HandlerFunc.

func (QueryableFunc) Querier

func (f QueryableFunc) Querier(ctx context.Context, mint, maxt int64) (Querier, error)

Querier calls f() with the given parameters.

type RemoteReadConfig

type RemoteReadConfig struct {
	URL           *config_util.URL `yaml:"url"`
	RemoteTimeout model.Duration   `yaml:"remote_timeout,omitempty"`
	ReadRecent    bool             `yaml:"read_recent,omitempty"`
	Name          string           `yaml:"name,omitempty"`

	// We cannot do proper Go type embedding below as the parser will then parse
	// values arbitrarily into the overflow maps of further-down types.
	HTTPClientConfig config_util.HTTPClientConfig `yaml:",inline"`

	// RequiredMatchers is an optional list of equality matchers which have to
	// be present in a selector to query the remote read endpoint.
	RequiredMatchers model.LabelSet `yaml:"required_matchers,omitempty"`
}

func (*RemoteReadConfig) UnmarshalYAML

func (c *RemoteReadConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type SelectParams

type SelectParams struct {
	Start int64 // Start time in milliseconds for this select.
	End   int64 // End time in milliseconds for this select.

	Step int64  // Query step size in milliseconds.
	Func string // String representation of surrounding function or aggregation.
}

SelectParams specifies parameters passed to data selections.

type Series

type Series interface {
	// Labels returns the complete set of labels identifying the series.
	Labels() labels.Labels

	// Iterator returns a new iterator of the data of the series.
	Iterator() SeriesIterator
}

Series represents a single time series.

type SeriesIterator

type SeriesIterator interface {
	// Seek advances the iterator forward to the value at or after
	// the given timestamp.
	Seek(t int64) bool
	// At returns the current timestamp/value pair.
	At() (t int64, v float64)
	// Next advances the iterator by one.
	Next() bool
	// Err returns the current error.
	Err() error
}

SeriesIterator iterates over the data of a time series.

type SeriesSet

type SeriesSet interface {
	Next() bool
	At() Series
	Err() error
}

SeriesSet contains a set of series.

func FromQueryResult

func FromQueryResult(res *prompb.QueryResult) SeriesSet

FromQueryResult unpacks a QueryResult proto.

func NewMergeSeriesSet added in v0.0.4

func NewMergeSeriesSet(sets []SeriesSet) SeriesSet

NewMergeSeriesSet returns a new series set that merges (deduplicates) series returned by the input series sets when iterating.

func NoopSeriesSet

func NoopSeriesSet() SeriesSet

NoopSeriesSet is a SeriesSet that does nothing.

type Storage

type Storage interface {
	Queryable

	// StartTime returns the oldest timestamp stored in the storage.
	StartTime() (int64, error)

	// Appender returns a new appender against the storage.
	Appender() (Appender, error)

	// Close closes the storage and all its underlying resources.
	Close() error
}

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

func NewStorage

func NewStorage(configs []*RemoteReadConfig) (Storage, error)

Jump to

Keyboard shortcuts

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