Documentation
¶
Overview ¶
Package tsdb embeds Prometheus' on-disk TSDB so Glouton can persist metrics locally without running a separate process.
Index ¶
- type Options
- type Store
- func (s *Store) Close() error
- func (s *Store) DiagnosticArchive(_ context.Context, archive types.ArchiveWriter) error
- func (s *Store) OldestPointMs() int64
- func (s *Store) Path() string
- func (s *Store) PushPoints(ctx context.Context, points []types.MetricPoint)
- func (s *Store) Querier(mint, maxt int64) (storage.Querier, error)
- func (s *Store) Retention() time.Duration
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 ¶
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 ¶
Close flushes the head block and releases the on-disk lock. After Close, Querier and PushPoints become no-ops.
func (*Store) DiagnosticArchive ¶
DiagnosticArchive writes a short status file for support archives.
func (*Store) OldestPointMs ¶
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) 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).