simple_storage

package
v0.5.14 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package simple_storage provides an in-memory time series storage implementation for PromQL.

Index

Constants

View Source
const SampleMetrics = `` /* 289-byte string literal not displayed */

SampleMetrics provides a small Prometheus exposition set with a counter and a gauge.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricSample

type MetricSample struct {
	Labels    map[string]string
	Value     float64
	Timestamp int64
}

MetricSample represents a single metric sample

type SaveOptions

type SaveOptions struct {
	// TimestampMode controls how timestamps are written: "keep" (default), "remove", or "set" (use FixedTimestamp)
	TimestampMode string
	// FixedTimestamp is used when TimestampMode=="set" (milliseconds since epoch)
	// When TimestampMode=="set", the latest timestamp is aligned to FixedTimestamp and all others are offset accordingly
	FixedTimestamp int64
	// SeriesRegex filters which time series to write. It matches against "name{labels}" (labels sorted, quoted), excluding value/timestamp.
	SeriesRegex *regexp.Regexp
}

SaveOptions controls optional behaviors for SaveToWriter

type SimpleIterator

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

SimpleIterator implements chunkenc.Iterator

func (*SimpleIterator) At

func (it *SimpleIterator) At() (int64, float64)

func (*SimpleIterator) AtFloatHistogram

func (*SimpleIterator) AtHistogram

func (*SimpleIterator) AtT

func (it *SimpleIterator) AtT() int64

func (*SimpleIterator) Err

func (it *SimpleIterator) Err() error

func (*SimpleIterator) Next

func (it *SimpleIterator) Next() chunkenc.ValueType

func (*SimpleIterator) Seek

func (it *SimpleIterator) Seek(t int64) chunkenc.ValueType

type SimpleQuerier

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

SimpleQuerier implements storage.Querier

func (*SimpleQuerier) Close

func (q *SimpleQuerier) Close() error

func (*SimpleQuerier) LabelNames

func (q *SimpleQuerier) LabelNames(_ context.Context, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error)

func (*SimpleQuerier) LabelValues

func (q *SimpleQuerier) LabelValues(_ context.Context, name string, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error)

func (*SimpleQuerier) Select

func (q *SimpleQuerier) Select(_ context.Context, sortSeries bool, hints *storage.SelectHints, matchers ...*labels.Matcher) storage.SeriesSet

type SimpleSeries

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

SimpleSeries implements storage.Series

func (*SimpleSeries) Iterator

func (*SimpleSeries) Labels

func (s *SimpleSeries) Labels() labels.Labels

type SimpleSeriesSet

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

SimpleSeriesSet implements storage.SeriesSet

func (*SimpleSeriesSet) At

func (s *SimpleSeriesSet) At() storage.Series

func (*SimpleSeriesSet) Err

func (s *SimpleSeriesSet) Err() error

func (*SimpleSeriesSet) Next

func (s *SimpleSeriesSet) Next() bool

func (*SimpleSeriesSet) Warnings

func (s *SimpleSeriesSet) Warnings() annotations.Annotations

type SimpleStorage

type SimpleStorage struct {
	Metrics     map[string][]MetricSample
	MetricsHelp map[string]string // metric name -> help text
}

SimpleStorage holds metrics in a simple format for querying

func NewSimpleStorage

func NewSimpleStorage() *SimpleStorage

NewSimpleStorage creates a new simple storage

func (*SimpleStorage) AddSample

func (s *SimpleStorage) AddSample(labels map[string]string, value float64, timestampMillis int64)

AddSample appends a single sample to the in-memory store.

func (*SimpleStorage) LoadFromReader

func (s *SimpleStorage) LoadFromReader(reader io.Reader) error

LoadFromReader loads Prometheus exposition format data using the official Prometheus parser

func (*SimpleStorage) LoadFromReaderWithFilter

func (s *SimpleStorage) LoadFromReaderWithFilter(reader io.Reader, filter func(name string) bool) error

LoadFromReaderWithFilter loads metrics and applies a metric-name filter function. Only metric families for which filter(name) returns true are loaded.

func (*SimpleStorage) Querier

func (s *SimpleStorage) Querier(mint, maxt int64) (storage.Querier, error)

Queryable implementation for SimpleStorage

func (*SimpleStorage) RenameMetric

func (s *SimpleStorage) RenameMetric(oldName, newName string) error

RenameMetric renames all series with oldName to newName

func (*SimpleStorage) SaveToWriter

func (s *SimpleStorage) SaveToWriter(w io.Writer) error

SaveToWriter writes the store content in Prometheus text exposition (line) format. For determinism, metrics and samples are sorted.

func (*SimpleStorage) SaveToWriterWithOptions

func (s *SimpleStorage) SaveToWriterWithOptions(w io.Writer, opts SaveOptions) error

SaveToWriterWithOptions writes the store content with additional formatting options.

Jump to

Keyboard shortcuts

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