metricsdb

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type DegradedAlert

type DegradedAlert struct {
	ID        int64
	TenantID  string
	MonitorID string
	ChannelID string
	Status    string
	SinceMs   int64
	SentMs    int64
	Outcome   string
	Reachable int64
	Total     int64
	Reporters string
	Reported  int64
}

type DeleteHeartbeatParams

type DeleteHeartbeatParams struct {
	NodeID      string
	Incarnation string
	Seq         int64
}

type DeleteHeartbeatsBeforeParams

type DeleteHeartbeatsBeforeParams struct {
	BeforeMs  int64
	BatchSize int64
}

type DeleteMinutesOfSeriesBeforeParams

type DeleteMinutesOfSeriesBeforeParams struct {
	SeriesID int64
	BeforeMs int64
	RowLimit int64
}

type DeleteRollupsOfSeriesBeforeParams

type DeleteRollupsOfSeriesBeforeParams struct {
	SeriesID int64
	BucketMs int64
	BeforeMs int64
	RowLimit int64
}

type GetSeriesParams

type GetSeriesParams struct {
	TenantID  string
	MonitorID string
	NodeID    string
}

type GetStreamPositionParams

type GetStreamPositionParams struct {
	NodeID      string
	Incarnation string
}

type Heartbeat

type Heartbeat struct {
	NodeID      string
	Incarnation string
	Seq         int64
	TenantID    string
	MonitorID   string
	TsMs        int64
	Status      int64
	LatencyMs   int64
	ErrorClass  string
	Message     string
	DetailsJson string
}

type InsertDegradedAlertParams

type InsertDegradedAlertParams struct {
	TenantID  string
	MonitorID string
	ChannelID string
	Status    string
	SinceMs   int64
	SentMs    int64
	Outcome   string
	Reachable int64
	Total     int64
	Reporters string
}

type InsertHeartbeatParams

type InsertHeartbeatParams struct {
	NodeID      string
	Incarnation string
	Seq         int64
	TenantID    string
	MonitorID   string
	TsMs        int64
	Status      int64
	LatencyMs   int64
	ErrorClass  string
	Message     string
	DetailsJson string
}

type InsertLatencyMinuteParams

type InsertLatencyMinuteParams struct {
	SeriesID int64
	MinuteMs int64
	MinMs    int64
	MaxMs    int64
	AvgUs    int64
	P95Us    int64
	OkCount  int64
	ErrCount int64
}

type InsertMetaParams

type InsertMetaParams struct {
	Key   string
	Value string
}

type InsertSeriesParams

type InsertSeriesParams struct {
	TenantID  string
	MonitorID string
	NodeID    string
}

type LastSeqParams

type LastSeqParams struct {
	NodeID      string
	Incarnation string
}

type LatestHeartbeatsParams

type LatestHeartbeatsParams struct {
	TenantID  string
	MonitorID string
	NodeID    string
	RowLimit  int64
}

type ListHeartbeatsParams

type ListHeartbeatsParams struct {
	TenantID  string
	MonitorID string
	NodeID    string
	ToMs      int64
	AfterTs   int64
	AfterNode string
	AfterInc  string
	AfterSeq  int64
	RowLimit  int64
}

type ListRollupsBatchParams

type ListRollupsBatchParams struct {
	TenantID   string
	NodeID     string
	BucketMs   int64
	FromMs     int64
	ToMs       int64
	MonitorIds []string
}

type ListRollupsBatchRow

type ListRollupsBatchRow struct {
	TenantID     string
	MonitorID    string
	NodeID       string
	BucketMs     int64
	StartMs      int64
	UpMs         int64
	DownMs       int64
	MaintMs      int64
	UnknownMs    int64
	LatencyCount int64
	LatencyAvgUs int64
	LatencyP95Us int64
}

type ListRollupsParams

type ListRollupsParams struct {
	TenantID  string
	MonitorID string
	AllNodes  int64
	NodeID    string
	BucketMs  int64
	FromMs    int64
	ToMs      int64
}

type ListRollupsRow

type ListRollupsRow struct {
	TenantID     string
	MonitorID    string
	NodeID       string
	BucketMs     int64
	StartMs      int64
	UpMs         int64
	DownMs       int64
	MaintMs      int64
	UnknownMs    int64
	LatencyCount int64
	LatencyAvgUs int64
	LatencyP95Us int64
}

type ListSeriesIDsAfterParams

type ListSeriesIDsAfterParams struct {
	AfterID  int64
	RowLimit int64
}

type ListSeriesIDsOfTenantAfterParams

type ListSeriesIDsOfTenantAfterParams struct {
	TenantID string
	AfterID  int64
	RowLimit int64
}

type ListStreamHeartbeatsAfterParams

type ListStreamHeartbeatsAfterParams struct {
	NodeID      string
	Incarnation string
	AfterSeq    int64
	UntilSeq    int64
	RowLimit    int64
}

type ListStreamSeqsAfterParams

type ListStreamSeqsAfterParams struct {
	NodeID      string
	Incarnation string
	AfterSeq    int64
	RowLimit    int64
}

type Meta

type Meta struct {
	Key   string
	Value string
}

type Minute

type Minute struct {
	SeriesID int64
	MinuteMs int64
	MinMs    int64
	MaxMs    int64
	AvgUs    int64
	P95Us    int64
	OkCount  int64
	ErrCount int64
}

type PurgeDegradedAlertsOfTenantParams

type PurgeDegradedAlertsOfTenantParams struct {
	TenantID string
	RowLimit int64
}

type PurgeHeartbeatsOfTenantParams

type PurgeHeartbeatsOfTenantParams struct {
	TenantID string
	RowLimit int64
}

type PurgeMinutesOfSeriesParams

type PurgeMinutesOfSeriesParams struct {
	SeriesID int64
	RowLimit int64
}

type PurgeRollupsOfSeriesParams

type PurgeRollupsOfSeriesParams struct {
	SeriesID int64
	RowLimit int64
}

type PurgeSeriesOfTenantParams

type PurgeSeriesOfTenantParams struct {
	TenantID string
	RowLimit int64
}

type PurgedTenant

type PurgedTenant struct {
	TenantID string
	PurgedMs int64
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) DeleteHeartbeat

func (q *Queries) DeleteHeartbeat(ctx context.Context, arg DeleteHeartbeatParams) error

func (*Queries) DeleteHeartbeatsBefore

func (q *Queries) DeleteHeartbeatsBefore(ctx context.Context, arg DeleteHeartbeatsBeforeParams) (int64, error)

One retention batch; short write transactions keep the writer responsive (FA-UPT-06).

func (*Queries) DeleteMinutesOfSeriesBefore

func (q *Queries) DeleteMinutesOfSeriesBefore(ctx context.Context, arg DeleteMinutesOfSeriesBeforeParams) (int64, error)

One series: the primary key prefix series_id drives the subquery and the delete.

func (*Queries) DeleteRollupsOfSeriesBefore

func (q *Queries) DeleteRollupsOfSeriesBefore(ctx context.Context, arg DeleteRollupsOfSeriesBeforeParams) (int64, error)

One series, one bucket size: the primary key prefix (series_id, bucket_ms) drives both the subquery and the delete, so no statement scans the table. The subquery bounds the batch to row_limit rows.

func (*Queries) GetMeta

func (q *Queries) GetMeta(ctx context.Context, key string) (string, error)

func (*Queries) GetSeries

func (q *Queries) GetSeries(ctx context.Context, arg GetSeriesParams) (int64, error)

Series are resolved with the tenant: a monitor and node of another tenant never match (ADR 0016).

func (*Queries) GetStreamPosition

func (q *Queries) GetStreamPosition(ctx context.Context, arg GetStreamPositionParams) (int64, error)

func (*Queries) InsertDegradedAlert

func (q *Queries) InsertDegradedAlert(ctx context.Context, arg InsertDegradedAlertParams) (int64, error)

func (*Queries) InsertHeartbeat

func (q *Queries) InsertHeartbeat(ctx context.Context, arg InsertHeartbeatParams) (int64, error)

func (*Queries) InsertLatencyMinute

func (q *Queries) InsertLatencyMinute(ctx context.Context, arg InsertLatencyMinuteParams) error

Latencies are microseconds. Existing minutes are kept (FA-UPT-04).

func (*Queries) InsertMeta

func (q *Queries) InsertMeta(ctx context.Context, arg InsertMetaParams) error

func (*Queries) InsertSeries

func (q *Queries) InsertSeries(ctx context.Context, arg InsertSeriesParams) (int64, error)

func (*Queries) LastSeq

func (q *Queries) LastSeq(ctx context.Context, arg LastSeqParams) (int64, error)

func (*Queries) LatestHeartbeats

func (q *Queries) LatestHeartbeats(ctx context.Context, arg LatestHeartbeatsParams) ([]Heartbeat, error)

Newest heartbeats of a monitor, optionally of one node.

func (*Queries) ListHeartbeats

func (q *Queries) ListHeartbeats(ctx context.Context, arg ListHeartbeatsParams) ([]Heartbeat, error)

Keyset pagination ordered by (ts_ms, node_id, incarnation, seq).

func (*Queries) ListPurgedTenants

func (q *Queries) ListPurgedTenants(ctx context.Context) ([]string, error)

func (*Queries) ListRollups

func (q *Queries) ListRollups(ctx context.Context, arg ListRollupsParams) ([]ListRollupsRow, error)

Joins series and filters by tenant in SQL: the tenant boundary never depends on the series cache (ADR 0016, FA-TEN-01).

func (*Queries) ListRollupsBatch

func (q *Queries) ListRollupsBatch(ctx context.Context, arg ListRollupsBatchParams) ([]ListRollupsBatchRow, error)

Rollups of several monitors of one node (node_id ” is the consensus) and bucket size. Joins series and filters by tenant in SQL (ADR 0016).

func (*Queries) ListSeriesIDsAfter

func (q *Queries) ListSeriesIDsAfter(ctx context.Context, arg ListSeriesIDsAfterParams) ([]int64, error)

Pages through the series in ID order for the per-series retention batches.

func (*Queries) ListSeriesIDsOfTenantAfter

func (q *Queries) ListSeriesIDsOfTenantAfter(ctx context.Context, arg ListSeriesIDsOfTenantAfterParams) ([]int64, error)

Pages through the series of one tenant in ID order.

func (*Queries) ListStreamHeartbeatsAfter

func (q *Queries) ListStreamHeartbeatsAfter(ctx context.Context, arg ListStreamHeartbeatsAfterParams) ([]Heartbeat, error)

One stream in seq order, afterSeq < seq <= untilSeq.

func (*Queries) ListStreamPositions

func (q *Queries) ListStreamPositions(ctx context.Context) ([]StreamPosition, error)

func (*Queries) ListStreamSeqsAfter

func (q *Queries) ListStreamSeqsAfter(ctx context.Context, arg ListStreamSeqsAfterParams) ([]int64, error)

Seqs only, to find the contiguous run above a position; the heartbeats primary key serves the range.

func (*Queries) ListUnreportedDegradedAlerts

func (q *Queries) ListUnreportedDegradedAlerts(ctx context.Context, rowLimit int64) ([]DegradedAlert, error)

func (*Queries) MarkDegradedAlertReported

func (q *Queries) MarkDegradedAlertReported(ctx context.Context, id int64) error

func (*Queries) PruneDegradedAlerts

func (q *Queries) PruneDegradedAlerts(ctx context.Context, sentMs int64) (int64, error)

func (*Queries) PurgeDegradedAlertsOfTenant

func (q *Queries) PurgeDegradedAlertsOfTenant(ctx context.Context, arg PurgeDegradedAlertsOfTenantParams) (int64, error)

func (*Queries) PurgeHeartbeatsOfTenant

func (q *Queries) PurgeHeartbeatsOfTenant(ctx context.Context, arg PurgeHeartbeatsOfTenantParams) (int64, error)

One purge batch of a tenant (ADR 0029); the tenant has no index here, so each batch scans heartbeats until it has found row_limit rows of the tenant.

func (*Queries) PurgeMinutesOfSeries

func (q *Queries) PurgeMinutesOfSeries(ctx context.Context, arg PurgeMinutesOfSeriesParams) (int64, error)

One series: the primary key prefix series_id drives the subquery and the delete.

func (*Queries) PurgeRollupsOfSeries

func (q *Queries) PurgeRollupsOfSeries(ctx context.Context, arg PurgeRollupsOfSeriesParams) (int64, error)

One series: the primary key prefix series_id drives the subquery and the delete.

func (*Queries) PurgeSeriesOfTenant

func (q *Queries) PurgeSeriesOfTenant(ctx context.Context, arg PurgeSeriesOfTenantParams) (int64, error)

Removes series only once no rollup or latency minute references them.

func (*Queries) UpsertMeta

func (q *Queries) UpsertMeta(ctx context.Context, arg UpsertMetaParams) error

func (*Queries) UpsertPurgedTenant

func (q *Queries) UpsertPurgedTenant(ctx context.Context, arg UpsertPurgedTenantParams) error

func (*Queries) UpsertRollup

func (q *Queries) UpsertRollup(ctx context.Context, arg UpsertRollupParams) error

Values are written by series ID; the caller resolves it inside the write transaction (ADR 0016). Latencies are microseconds.

func (*Queries) UpsertStreamPosition

func (q *Queries) UpsertStreamPosition(ctx context.Context, arg UpsertStreamPositionParams) error

Positions never move backwards: a lower seq leaves the stored one.

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type Rollup

type Rollup struct {
	SeriesID     int64
	BucketMs     int64
	StartMs      int64
	UpMs         int64
	DownMs       int64
	MaintMs      int64
	UnknownMs    int64
	LatencyCount int64
	LatencyAvgUs int64
	LatencyP95Us int64
}

type Series

type Series struct {
	ID        int64
	TenantID  string
	MonitorID string
	NodeID    string
}

type StreamPosition

type StreamPosition struct {
	NodeID      string
	Incarnation string
	Seq         int64
}

type UpsertMetaParams

type UpsertMetaParams struct {
	Key   string
	Value string
}

type UpsertPurgedTenantParams

type UpsertPurgedTenantParams struct {
	TenantID string
	PurgedMs int64
}

type UpsertRollupParams

type UpsertRollupParams struct {
	SeriesID     int64
	BucketMs     int64
	StartMs      int64
	UpMs         int64
	DownMs       int64
	MaintMs      int64
	UnknownMs    int64
	LatencyCount int64
	LatencyAvgUs int64
	LatencyP95Us int64
}

type UpsertStreamPositionParams

type UpsertStreamPositionParams struct {
	NodeID      string
	Incarnation string
	Seq         int64
}

Jump to

Keyboard shortcuts

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