Documentation
¶
Overview ¶
Package simple_storage provides an in-memory time series storage implementation for PromQL.
Index ¶
- Constants
- type MetricSample
- type SaveOptions
- type SimpleIterator
- func (it *SimpleIterator) At() (int64, float64)
- func (it *SimpleIterator) AtFloatHistogram(*histogram.FloatHistogram) (int64, *histogram.FloatHistogram)
- func (it *SimpleIterator) AtHistogram(*histogram.Histogram) (int64, *histogram.Histogram)
- func (it *SimpleIterator) AtT() int64
- func (it *SimpleIterator) Err() error
- func (it *SimpleIterator) Next() chunkenc.ValueType
- func (it *SimpleIterator) Seek(t int64) chunkenc.ValueType
- type SimpleQuerier
- func (q *SimpleQuerier) Close() error
- func (q *SimpleQuerier) LabelNames(_ context.Context, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error)
- func (q *SimpleQuerier) LabelValues(_ context.Context, name string, hints *storage.LabelHints, ...) ([]string, annotations.Annotations, error)
- func (q *SimpleQuerier) Select(_ context.Context, sortSeries bool, hints *storage.SelectHints, ...) storage.SeriesSet
- type SimpleSeries
- type SimpleSeriesSet
- type SimpleStorage
- func (s *SimpleStorage) AddSample(labels map[string]string, value float64, timestampMillis int64)
- func (s *SimpleStorage) LoadFromReader(reader io.Reader) error
- func (s *SimpleStorage) LoadFromReaderWithFilter(reader io.Reader, filter func(name string) bool) error
- func (s *SimpleStorage) Querier(mint, maxt int64) (storage.Querier, error)
- func (s *SimpleStorage) RenameMetric(oldName, newName string) error
- func (s *SimpleStorage) SaveToWriter(w io.Writer) error
- func (s *SimpleStorage) SaveToWriterWithOptions(w io.Writer, opts SaveOptions) error
Constants ¶
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 ¶
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 (it *SimpleIterator) AtFloatHistogram(*histogram.FloatHistogram) (int64, *histogram.FloatHistogram)
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
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)
type SimpleSeries ¶
type SimpleSeries struct {
// contains filtered or unexported fields
}
SimpleSeries implements storage.Series
func (*SimpleSeries) Iterator ¶
func (s *SimpleSeries) Iterator(_ chunkenc.Iterator) chunkenc.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.