tsdb

package
v0.0.0-...-4e37ce3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package tsdb embeds Prometheus' on-disk TSDB so Glouton can persist metrics locally without running a separate process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Path is the directory where TSDB blocks are stored.
	// It must exist and be writable.
	Path string
	// Retention controls how long data is kept on disk.
	// A zero value falls back to Prometheus' default (15d).
	Retention time.Duration
}

Options configures a Store.

type Store

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

Store wraps a prometheus/tsdb.DB so it can be used as a Glouton types.PointPusher and as a storage.Queryable for the local API.

func Open

func Open(opts Options) (*Store, error)

Open opens (or creates) a TSDB at opts.Path. Open is expensive (it replays the WAL) so callers should keep the returned Store across agent reloads.

func (*Store) Close

func (s *Store) Close() error

Close flushes the head block and releases the on-disk lock. After Close, Querier and PushPoints become no-ops.

func (*Store) DiagnosticArchive

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

DiagnosticArchive writes a short status file for support archives.

func (*Store) OldestPointMs

func (s *Store) OldestPointMs() int64

OldestPointMs returns the timestamp (in ms since epoch) of the oldest point that can still be queried, looking at on-disk blocks first and falling back to the head block. Returns 0 if the store is empty or closed.

func (*Store) Path

func (s *Store) Path() string

Path returns the on-disk location of the TSDB.

func (*Store) PushPoints

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

PushPoints implements types.PointPusher. It writes the given points into a single appender and commits. Points with NaN values are silently skipped (Prometheus' staleness convention is encoded elsewhere; we don't want to commit unmappable values here).

func (*Store) Querier

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

Querier returns a storage.Querier for the [mint, maxt] window (milliseconds since epoch).

func (*Store) Retention

func (s *Store) Retention() time.Duration

Retention returns the configured retention duration.

Jump to

Keyboard shortcuts

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