archive

package
v0.0.11-beta.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package archive implements hot/cold storage tiering for Argus. Data older than HOT_RETENTION_DAYS is moved from the relational DB (hot) to zstd-compressed JSONL files on local disk (cold). Cold files are organized as: {cold_path}/{year}/{month}/{day}/{type}.jsonl.zst Each day directory also contains a manifest.json with record counts and checksums.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Maintain

func Maintain(repo *storage.Repository, cfg *config.Config) error

Maintain runs driver-specific DB optimization commands after archival. SQLite: VACUUM + PRAGMA optimize PostgreSQL: VACUUM ANALYZE MySQL: OPTIMIZE TABLE for each Argus table

Types

type Archiver

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

Archiver moves data older than the hot retention window to compressed cold files.

func New

func New(repo *storage.Repository, cfg *config.Config) *Archiver

New creates a new Archiver.

func (*Archiver) LastRun

func (a *Archiver) LastRun() time.Time

LastRun returns the time of the last successful archival.

func (*Archiver) RecordsMoved

func (a *Archiver) RecordsMoved() int64

RecordsMoved returns the total number of records moved to cold storage.

func (*Archiver) RunOnce

func (a *Archiver) RunOnce(ctx context.Context) error

RunOnce performs a single archival pass — useful for testing or manual triggers.

func (*Archiver) SetMetrics

func (a *Archiver) SetMetrics(m *telemetry.Metrics)

SetMetrics wires Prometheus metrics into the archiver.

func (*Archiver) Start

func (a *Archiver) Start(ctx context.Context)

Start runs the archival loop. It fires once at the configured hour each day. Blocks until ctx is cancelled.

type Manifest

type Manifest struct {
	Date        string    `json:"date"`
	ArchivedAt  time.Time `json:"archived_at"`
	TraceCount  int       `json:"trace_count"`
	LogCount    int       `json:"log_count"`
	MetricCount int       `json:"metric_count"`
	TraceBytes  int64     `json:"trace_bytes"`
	LogBytes    int64     `json:"log_bytes"`
	MetricBytes int64     `json:"metric_bytes"`
	TraceHash   string    `json:"trace_sha256"`
	LogHash     string    `json:"log_sha256"`
	MetricHash  string    `json:"metric_sha256"`
}

Manifest describes what was archived in a single day directory.

Jump to

Keyboard shortcuts

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