store

package
v0.0.0-...-d79780e Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package store implement a Metric/MetricPoint store.

currently the storage in only in-memory and not persisted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilteredStore

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

FilteredStore is a store wrapper that intercepts all call to pushPoints and execute filters on points.

func NewFilteredStore

func NewFilteredStore(store store, fc func([]types.MetricPoint) []types.MetricPoint, fmc func([]types.Metric) []types.Metric) *FilteredStore

NewFilteredStore initializes a new filtered store.

func (*FilteredStore) AddNotifiee

func (s *FilteredStore) AddNotifiee(fc func([]types.MetricPoint)) int

func (*FilteredStore) DropMetrics

func (s *FilteredStore) DropMetrics(labelsList []map[string]string)

func (*FilteredStore) Metrics

func (s *FilteredStore) Metrics(filters map[string]string) (result []types.Metric, err error)

func (*FilteredStore) MetricsCount

func (s *FilteredStore) MetricsCount() int

func (*FilteredStore) PushPoints

func (s *FilteredStore) PushPoints(ctx context.Context, points []types.MetricPoint)

PushPoints wraps the store PushPoints function. It precedes the call with filterCallback.

func (*FilteredStore) RemoveNotifiee

func (s *FilteredStore) RemoveNotifiee(v int)

type Store

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

Store implement an interface to retrieve metrics and metric points.

See methods GetMetrics and GetMetricPoints.

func New

func New(maxPointsAge time.Duration, maxMetricsAge time.Duration) *Store

New create a return a store. Store should be Close()d before leaving.

func (*Store) AddNotifiee

func (s *Store) AddNotifiee(cb func([]types.MetricPoint)) int

AddNotifiee add a callback that will be notified of all points received Note: AddNotifiee should not be called while in the callback.

func (*Store) Appender

func (s *Store) Appender(ctx context.Context) storage.Appender

Appender returns a prometheus appender wrapping the in memory store.

func (*Store) DiagnosticArchive

func (s *Store) DiagnosticArchive(_ context.Context, archive types.ArchiveWriter) error

func (*Store) DropAllMetrics

func (s *Store) DropAllMetrics()

DropAllMetrics clear the full content of the store.

func (*Store) DropMetrics

func (s *Store) DropMetrics(labelsList []map[string]string)

DropMetrics delete metrics and they points. The provided labels list is an exact match (e.g. {"__name__": "disk_used"} won't delete the metrics for all disk. You need to specify all labels).

func (*Store) InternalSetNowAndRunOnce

func (s *Store) InternalSetNowAndRunOnce(nowFunc func() time.Time)

InternalSetNowAndRunOnce is used for testing. It will set the Now() function used by the store and will call one loop of Run() method which does purge of older metrics.

func (*Store) LastAnnotationChange

func (s *Store) LastAnnotationChange() time.Time

func (*Store) Metrics

func (s *Store) Metrics(filters map[string]string) (result []types.Metric, err error)

Metrics return a list of Metric matching given labels filter.

func (*Store) MetricsCount

func (s *Store) MetricsCount() int

MetricsCount return the count of metrics stored.

func (*Store) PushPoints

func (s *Store) PushPoints(_ context.Context, points []types.MetricPoint)

PushPoints append new metric points to the store, creating new metric if needed. The points must not be mutated after this call.

Writing the value StaleNaN is used to mark the metric as inactive.

func (*Store) Querier

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

Querier returns a storage.Querier to read from memory store.

func (*Store) RemoveNotifiee

func (s *Store) RemoveNotifiee(id int)

RemoveNotifiee remove a callback that was notified Note: RemoveNotifiee should not be called while in the callback. Once RemoveNotifiee() returns, the callbacl won't be called anymore.

func (*Store) Run

func (s *Store) Run(ctx context.Context) error

Run will run the store until context is cancelled.

func (*Store) RunOnce

func (s *Store) RunOnce()

RunOnce runs the store once to remove old points and metrics.

func (*Store) SetNewMetricCallback

func (s *Store) SetNewMetricCallback(fc func([]types.LabelsAndAnnotation))

SetNewMetricCallback sets the callback used when a new metrics is seen the first time.

Jump to

Keyboard shortcuts

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