Documentation
¶
Index ¶
- Constants
- func BuildPgStatUserIndexesQuery(categoryLimit int) string
- func BuildPgStatUserTablesQuery(categoryLimit int) string
- func CollectDDL(pgPool *pgxpool.Pool, ctx context.Context) (string, error)
- func CollectView[T any](querier func() (pgx.Rows, error), viewName string, scanner *pgxutil.Scanner[T]) ([]T, error)
- func HashDDL(ddl string) string
- type Anyarray
- type AutovacuumCountRow
- type Bigint
- type Boolean
- type CatalogCollector
- func AutovacuumCountCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func ConnectionStatsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func DDLCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func DatabaseSizeCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func NewCollector[T any](pool *pgxpool.Pool, prepareCtx PrepareCtx, name string, interval time.Duration, ...) CatalogCollector
- func PgAttributeCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgClassCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, cfg PgClassConfig) CatalogCollector
- func PgConstraintCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgDatabaseCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgIndexCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgIndexInventoryCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
- func PgLocksCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgPreparedXactsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgReplicationSlotsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgStatActivityCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
- func PgStatArchiverCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgStatBgwriterCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgStatCheckpointerCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
- func PgStatDatabaseCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgStatDatabaseConflictsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgStatIOCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
- func PgStatProgressAnalyzeCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgStatProgressCreateIndexCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgStatProgressVacuumCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgStatRecoveryPrefetchCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
- func PgStatReplicationCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgStatReplicationSlotsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
- func PgStatSlruCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgStatStatementsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, cfg PgStatStatementsConfig) CatalogCollector
- func PgStatSubscriptionCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgStatSubscriptionStatsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
- func PgStatUserFunctionsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgStatUserIndexesCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, cfg PgStatUserIndexesConfig) CatalogCollector
- func PgStatUserTablesCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, cfg PgStatUserTablesConfig) CatalogCollector
- func PgStatWalCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
- func PgStatWalReceiverCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgStatioUserIndexesCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, cfg PgStatioUserIndexesConfig) CatalogCollector
- func PgStatioUserTablesCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func PgStatsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, cfg PgStatsConfig) CatalogCollector
- func PgTypeCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func TransactionCommitsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func UptimeMinutesCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- func WaitEventsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
- type CollectResult
- type CollectorOption
- type ConnectionStatsRow
- type DDLColumn
- type DDLCompositeType
- type DDLConstraint
- type DDLDomainType
- type DDLEnumType
- type DDLForeignKey
- type DDLFunction
- type DDLIdentitySequence
- type DDLIndex
- type DDLMaterializedView
- type DDLPartitionChild
- type DDLRLSEnabled
- type DDLRLSPolicy
- type DDLSequenceRaw
- type DDLSerialSequence
- type DDLTable
- type DDLTrigger
- type DDLView
- type DatabaseSizeRow
- type DoublePrecision
- type Float4Array
- type Inet
- type Integer
- type Interval
- type Name
- type Oid
- type Payload
- type PgAttributeRow
- type PgClassConfig
- type PgClassRow
- type PgConstraintRow
- type PgDatabaseRow
- type PgIndexInventoryRow
- type PgIndexRow
- type PgLocksRow
- type PgLsn
- type PgPreparedXactsRow
- type PgReplicationSlotsRow
- type PgSettingsRow
- type PgStatActivityRow
- type PgStatArchiverRow
- type PgStatBgwriterRow
- type PgStatCheckpointerRow
- type PgStatDatabaseConflictsRow
- type PgStatDatabaseRow
- type PgStatIORow
- type PgStatProgressAnalyzeRow
- type PgStatProgressCreateIndexRow
- type PgStatProgressVacuumRow
- type PgStatRecoveryPrefetchRow
- type PgStatReplicationRow
- type PgStatReplicationSlotsRow
- type PgStatSlruRow
- type PgStatStatementsConfig
- type PgStatStatementsDelta
- type PgStatStatementsExtVersion
- type PgStatStatementsPayload
- type PgStatStatementsRow
- type PgStatSubscriptionRow
- type PgStatSubscriptionStatsRow
- type PgStatUserFunctionsRow
- type PgStatUserIndexesConfig
- type PgStatUserIndexesRow
- type PgStatUserTableRow
- type PgStatUserTablesConfig
- type PgStatWalReceiverRow
- type PgStatWalRow
- type PgStatioUserIndexesConfig
- type PgStatioUserIndexesRow
- type PgStatioUserTablesRow
- type PgStatsConfig
- type PgStatsRow
- type PgTypeRow
- type PrepareCtx
- type Real
- type SeqParams
- type Smallint
- type Text
- type TimestampTZ
- type TransactionCommitsRow
- type UptimeMinutesRow
- type WaitEventRow
- type Xid
Constants ¶
const ( AutovacuumCountName = "autovacuum_count" AutovacuumCountInterval = 5 * time.Second )
const ( ConnectionStatsName = "database_connections" ConnectionStatsInterval = 5 * time.Second )
const ( DatabaseSizeName = "system_db_size" DatabaseSizeInterval = 5 * time.Second )
const ( DDLCollectorName = "ddl" DDLCollectorInterval = 5 * time.Minute )
const ( PgAttributeName = "pg_attribute" PgAttributeInterval = 5 * time.Minute )
const ( PgClassName = "pg_class" PgClassInterval = 1 * time.Minute // PgClassBackfillBatchSize controls how many tables are fetched per tick // during the initial backfill. After all batches are sent, the collector // switches to delta mode using VACUUM/ANALYZE timestamps. PgClassBackfillBatchSize = 500 )
const ( PgConstraintName = "pg_constraint" PgConstraintInterval = 5 * time.Minute )
const ( PgDatabaseName = "pg_database" PgDatabaseInterval = 1 * time.Minute )
const ( PgIndexName = "pg_index" PgIndexInterval = 5 * time.Minute )
const ( PgIndexInventoryName = "pg_index_inventory" PgIndexInventoryInterval = 1 * time.Hour )
const ( PgLocksName = "pg_locks" PgLocksInterval = 30 * time.Second )
const ( PgPreparedXactsName = "pg_prepared_xacts" PgPreparedXactsInterval = 1 * time.Minute )
const ( PgReplicationSlotsName = "pg_replication_slots" PgReplicationSlotsInterval = 1 * time.Minute )
const ( PgStatActivityName = "pg_stat_activity" PgStatActivityInterval = 1 * time.Minute )
const ( PgStatArchiverName = "pg_stat_archiver" PgStatArchiverInterval = 1 * time.Minute )
const ( PgStatBgwriterName = "pg_stat_bgwriter" PgStatBgwriterInterval = 1 * time.Minute )
const ( PgStatCheckpointerName = "pg_stat_checkpointer" PgStatCheckpointerInterval = 1 * time.Minute )
const ( PgStatDatabaseName = "pg_stat_database" PgStatDatabaseInterval = 1 * time.Minute )
const ( PgStatDatabaseConflictsName = "pg_stat_database_conflicts" PgStatDatabaseConflictsInterval = 1 * time.Minute )
const ( PgStatIOName = "pg_stat_io" PgStatIOInterval = 1 * time.Minute )
const ( PgStatProgressAnalyzeName = "pg_stat_progress_analyze" PgStatProgressAnalyzeInterval = 30 * time.Second )
const ( PgStatProgressCreateIndexName = "pg_stat_progress_create_index" PgStatProgressCreateIndexInterval = 30 * time.Second )
const ( PgStatProgressVacuumName = "pg_stat_progress_vacuum" PgStatProgressVacuumInterval = 30 * time.Second )
const ( PgStatRecoveryPrefetchName = "pg_stat_recovery_prefetch" PgStatRecoveryPrefetchInterval = 1 * time.Minute )
const ( PgStatReplicationName = "pg_stat_replication" PgStatReplicationInterval = 1 * time.Minute )
const ( PgStatReplicationSlotsName = "pg_stat_replication_slots" PgStatReplicationSlotsInterval = 1 * time.Minute )
const ( PgStatSlruName = "pg_stat_slru" PgStatSlruInterval = 1 * time.Minute )
const ( PgStatStatementsName = "pg_stat_statements" PgStatStatementsInterval = 5 * time.Second )
const ( PgStatSubscriptionName = "pg_stat_subscription" PgStatSubscriptionInterval = 1 * time.Minute )
const ( PgStatSubscriptionStatsName = "pg_stat_subscription_stats" PgStatSubscriptionStatsInterval = 1 * time.Minute )
const ( PgStatUserFunctionsName = "pg_stat_user_functions" PgStatUserFunctionsInterval = 1 * time.Minute )
const ( PgStatUserIndexesName = "pg_stat_user_indexes" PgStatUserIndexesInterval = 1 * time.Minute // PgStatUserIndexesCategoryLimit caps each activity category in the UNION query. PgStatUserIndexesCategoryLimit = 200 )
const ( PgStatUserTablesName = "pg_stat_user_tables" PgStatUserTablesInterval = 1 * time.Minute // PgStatUserTablesCategoryLimit caps each activity category in the UNION // query. The final result contains at most 3x this value (before dedup). PgStatUserTablesCategoryLimit = 200 )
const ( PgStatWalName = "pg_stat_wal" PgStatWalInterval = 1 * time.Minute )
const ( PgStatWalReceiverName = "pg_stat_wal_receiver" PgStatWalReceiverInterval = 1 * time.Minute )
const ( PgStatioUserIndexesName = "pg_statio_user_indexes" PgStatioUserIndexesInterval = 1 * time.Minute // PgStatioUserIndexesBatchSize controls how many indexes are fetched per // tick. During backfill every row is emitted; during delta only rows with // changed idx_blks_read or idx_blks_hit are sent. PgStatioUserIndexesBatchSize = 2000 )
const ( PgStatioUserTablesName = "pg_statio_user_tables" PgStatioUserTablesInterval = 1 * time.Minute )
const ( PgStatsName = "pg_stats" PgStatsInterval = 1 * time.Minute // PgStatsBackfillBatchSize controls how many tables' statistics are sent per // tick during the initial backfill phase. PgStatsBackfillBatchSize = 200 )
const ( PgTypeName = "pg_type" PgTypeInterval = 5 * time.Minute )
const ( TransactionCommitsName = "database_transactions" TransactionCommitsInterval = 5 * time.Second )
const ( UptimeMinutesName = "server_uptime" UptimeMinutesInterval = 5 * time.Second )
const ( WaitEventsName = "wait_events" WaitEventsInterval = 5 * time.Second )
const DefaultDDLTimeout = 30 * time.Second
DefaultDDLTimeout is the maximum time allowed for the full DDL collection.
const PgStatStatementsDiffLimit = 500
PgStatStatementsDiffLimit is the max number of delta entries to include.
Variables ¶
This section is empty.
Functions ¶
func BuildPgStatUserIndexesQuery ¶ added in v1.1.0
BuildPgStatUserIndexesQuery samples indexes from three perspectives: scan count, rows returned, and unused indexes. UNION deduplicates across categories automatically.
func BuildPgStatUserTablesQuery ¶ added in v1.1.0
BuildPgStatUserTablesQuery samples tables from three perspectives: write activity, read activity, and dead-tuple pressure. UNION deduplicates across categories automatically.
func CollectDDL ¶ added in v1.1.0
CollectDDL queries the PostgreSQL catalog and reconstructs a complete DDL snapshot. The output is ordered:
Pre-data: extensions, schemas, types, sequences, tables (bare),
partitions, serial defaults, identity, sequence ownership,
storage/statistics overrides, views, materialized views,
functions
Post-data: constraints, foreign keys, indexes, triggers, RLS
Functions emit AFTER tables/views, unlike pg_dump's default static priority which puts functions in pre-data before tables. pg_dump relies on its TopologicalSort to pull a function past the tables it depends on; we feed a single SQL stream to PostgreSQL so any `LANGUAGE sql` function whose body references a table that comes later fails at CREATE time with "relation does not exist". Emitting functions after tables sidesteps the cascade.
Trade-off: column DEFAULTs that call a user-defined function will fail to resolve at table-create time. This is rare in practice (most defaults are literals, `now()`, or `nextval()`); if it surfaces, a second pass with stub-then-replace would be the next step.
func CollectView ¶
func CollectView[T any](querier func() (pgx.Rows, error), viewName string, scanner *pgxutil.Scanner[T]) ([]T, error)
CollectView queries a pg catalog view and scans the results into a slice of structs using the provided scanner. The querier function should set a deadline, eg via a context.
Types ¶
type Anyarray ¶
type Anyarray = json.RawMessage
Anyarray and Float4Array remain json.RawMessage — they require special conversion logic in pg_stats.go.
type AutovacuumCountRow ¶ added in v1.1.0
type AutovacuumCountRow struct {
Count Bigint `json:"count" db:"count"`
}
type CatalogCollector ¶
type CatalogCollector struct {
Name string
Interval time.Duration
Collect func(ctx context.Context) (*CollectResult, error)
}
CatalogCollector defines a periodic catalog collection task.
func AutovacuumCountCollector ¶ added in v1.1.0
func AutovacuumCountCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func ConnectionStatsCollector ¶ added in v1.1.0
func ConnectionStatsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func DDLCollector ¶ added in v1.1.0
func DDLCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
DDLCollector emits the full DDL dump plus its hash. Payload is deduplicated via skipTracker so the backend still receives a heartbeat every skipUnchangedMultiplier intervals even when DDL is unchanged.
func DatabaseSizeCollector ¶ added in v1.1.0
func DatabaseSizeCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func NewCollector ¶
func NewCollector[T any]( pool *pgxpool.Pool, prepareCtx PrepareCtx, name string, interval time.Duration, query string, opts ...CollectorOption, ) CatalogCollector
NewCollector creates a CatalogCollector for a catalog view query. JSON is marshaled once per collection; when WithSkipUnchanged is used, an xxhash of the bytes is compared to the previous collection to avoid redundant sends. Even when unchanged, a send is forced every skipUnchangedMultiplier collection intervals to act as a heartbeat.
func PgAttributeCollector ¶ added in v1.1.0
func PgAttributeCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgClassCollector ¶ added in v1.1.0
func PgClassCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, cfg PgClassConfig) CatalogCollector
func PgConstraintCollector ¶ added in v1.1.0
func PgConstraintCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgDatabaseCollector ¶ added in v1.1.0
func PgDatabaseCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgIndexCollector ¶ added in v1.1.0
func PgIndexCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
PgIndexCollector returns a CatalogCollector that emits the full pg_index volatile snapshot every tick.
func PgIndexInventoryCollector ¶ added in v1.1.0
func PgIndexInventoryCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
func PgLocksCollector ¶ added in v1.1.0
func PgLocksCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgPreparedXactsCollector ¶
func PgPreparedXactsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgReplicationSlotsCollector ¶
func PgReplicationSlotsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgStatActivityCollector ¶
func PgStatActivityCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
func PgStatArchiverCollector ¶
func PgStatArchiverCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgStatBgwriterCollector ¶
func PgStatBgwriterCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgStatCheckpointerCollector ¶
func PgStatCheckpointerCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
func PgStatDatabaseCollector ¶
func PgStatDatabaseCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgStatDatabaseConflictsCollector ¶
func PgStatDatabaseConflictsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgStatIOCollector ¶
func PgStatIOCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
func PgStatProgressAnalyzeCollector ¶
func PgStatProgressAnalyzeCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgStatProgressCreateIndexCollector ¶
func PgStatProgressCreateIndexCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgStatProgressVacuumCollector ¶
func PgStatProgressVacuumCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgStatRecoveryPrefetchCollector ¶
func PgStatRecoveryPrefetchCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
func PgStatReplicationCollector ¶
func PgStatReplicationCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgStatReplicationSlotsCollector ¶
func PgStatReplicationSlotsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
func PgStatSlruCollector ¶
func PgStatSlruCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgStatStatementsCollector ¶ added in v1.1.0
func PgStatStatementsCollector( pool *pgxpool.Pool, prepareCtx PrepareCtx, cfg PgStatStatementsConfig, ) CatalogCollector
PgStatStatementsCollector returns a CatalogCollector that queries pg_stat_statements, computes deltas between consecutive snapshots, and emits a structured payload. The query is rebuilt whenever the detected pg_stat_statements extension version changes (e.g. after ALTER EXTENSION pg_stat_statements UPDATE).
func PgStatSubscriptionCollector ¶
func PgStatSubscriptionCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgStatSubscriptionStatsCollector ¶
func PgStatSubscriptionStatsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
func PgStatUserFunctionsCollector ¶ added in v1.1.0
func PgStatUserFunctionsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgStatUserIndexesCollector ¶ added in v1.1.0
func PgStatUserIndexesCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, cfg PgStatUserIndexesConfig) CatalogCollector
func PgStatUserTablesCollector ¶ added in v1.1.0
func PgStatUserTablesCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, cfg PgStatUserTablesConfig) CatalogCollector
func PgStatWalCollector ¶
func PgStatWalCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector
func PgStatWalReceiverCollector ¶
func PgStatWalReceiverCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgStatioUserIndexesCollector ¶ added in v1.1.0
func PgStatioUserIndexesCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, cfg PgStatioUserIndexesConfig) CatalogCollector
func PgStatioUserTablesCollector ¶ added in v1.1.0
func PgStatioUserTablesCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func PgStatsCollector ¶ added in v1.1.0
func PgStatsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, cfg PgStatsConfig) CatalogCollector
func PgTypeCollector ¶ added in v1.1.0
func PgTypeCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func TransactionCommitsCollector ¶ added in v1.1.0
func TransactionCommitsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func UptimeMinutesCollector ¶ added in v1.1.0
func UptimeMinutesCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
func WaitEventsCollector ¶ added in v1.1.0
func WaitEventsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector
type CollectResult ¶
type CollectResult struct {
JSON []byte // Pre-marshaled JSON of the payload
}
CollectResult holds both the typed payload and its pre-marshaled JSON bytes. JSON is marshaled once at collection time so the sending pipeline can reuse the bytes without re-serializing.
func (*CollectResult) Hash ¶
func (r *CollectResult) Hash() string
Hash returns a hex string of the xxhash of the JSON bytes, suitable for sending to the backend as a change-detection token.
type CollectorOption ¶
type CollectorOption func(*collectorOpts)
CollectorOption configures optional behavior for NewCollector.
func WithMinPGVersion ¶
func WithMinPGVersion(pgMajorVersion, minVersion int) CollectorOption
WithMinPGVersion skips collection when pgMajorVersion is below minVersion.
func WithSkipUnchanged ¶
func WithSkipUnchanged() CollectorOption
WithSkipUnchanged marks the collector to skip sending if the JSON payload hash matches the previous collection.
type ConnectionStatsRow ¶ added in v1.1.0
type ConnectionStatsRow struct {
Active Bigint `json:"active_connections" db:"active_connections"`
Idle Bigint `json:"idle_connections" db:"idle_connections"`
IdleInTransaction Bigint `json:"idle_in_transaction_connections" db:"idle_in_transaction_connections"`
IdleInTransactionAbort Bigint `json:"idle_in_transaction_aborted_connections" db:"idle_in_transaction_aborted_connections"`
Total Bigint `json:"total_connections" db:"total_connections"`
}
type DDLColumn ¶ added in v1.1.0
type DDLColumn struct {
TableOID uint32 // c.oid — for grouping with DDLTable
TableName string // quote_ident(c.relname) — for ALTER TABLE statements
AttNum int16 // a.attnum — for ordering
Name string // quote_ident(a.attname)
TypeName string // format_type(a.atttypid, a.atttypmod)
Collation *string // quote_ident(collname) if non-default, nil otherwise
Identity *string // a.attidentity: "a" or "d", nil if not identity
Generated *string // a.attgenerated: "s", nil if not generated
NotNull bool // a.attnotnull
DefaultExpr *string // pg_get_expr(d.adbin, d.adrelid), nil if no default
Storage *string // attstorage if differs from type default, nil otherwise
Statistics *int32 // attstattarget if non-default (>= 0), nil otherwise
}
DDLColumn represents a single column within a table.
type DDLCompositeType ¶ added in v1.1.0
type DDLCompositeType struct {
SchemaName string // quote_ident(tn.nspname)
TypeName string // quote_ident(t.typname)
Attributes string // formatted attribute list: "field1 type1, field2 type2, ..."
}
DDLCompositeType represents a composite type referenced by public-schema tables.
type DDLConstraint ¶ added in v1.1.0
type DDLConstraint struct {
TableName string // c.relname (raw, for grouping)
QuotedTable string // quote_ident(c.relname)
ConName string // con.conname (for ordering)
QuotedConName string // quote_ident(con.conname)
ConType string // con.contype: "p","u","c","x"
ConstraintDef string // pg_get_constraintdef(con.oid)
}
DDLConstraint represents a table constraint (PK, UNIQUE, CHECK, EXCLUDE).
type DDLDomainType ¶ added in v1.1.0
type DDLDomainType struct {
SchemaName string // quote_ident(tn.nspname)
TypeName string // quote_ident(t.typname)
BaseType string // format_type(t.typbasetype, t.typtypmod)
NotNull bool // t.typnotnull
Default *string // t.typdefault (nil = no default)
ConstraintDefs []string // pg_get_constraintdef() for each domain constraint
}
DDLDomainType represents a DOMAIN type referenced by public-schema tables.
type DDLEnumType ¶ added in v1.1.0
type DDLEnumType struct {
SchemaName string // quote_ident(tn.nspname)
TypeName string // quote_ident(t.typname)
Labels []string // ordered enum labels (raw, need quote_literal in formatter)
}
DDLEnumType represents a user-defined ENUM type referenced by public-schema tables.
type DDLForeignKey ¶ added in v1.1.0
type DDLForeignKey struct {
TableName string // quote_ident(c.relname)
ConName string // quote_ident(con.conname)
ConstraintDef string // pg_get_constraintdef(con.oid)
}
DDLForeignKey represents a foreign key constraint emitted as ALTER TABLE.
type DDLFunction ¶ added in v1.1.0
type DDLFunction struct {
OID uint32 // p.oid (for stable ordering)
Name string // p.proname (for stable ordering)
FunctionDef string // pg_get_functiondef(p.oid) — full CREATE FUNCTION text
}
DDLFunction represents a function/procedure in the public schema.
type DDLIdentitySequence ¶ added in v1.1.0
type DDLIdentitySequence struct {
SeqParams
TableName string // owning table (quoted)
ColumnName string // owning column (quoted)
IdentityKind string // 'a' (ALWAYS) or 'd' (BY DEFAULT)
Partitioned bool // true if the owning table is partitioned (relkind = 'p')
}
DDLIdentitySequence represents an identity-backing sequence.
type DDLIndex ¶ added in v1.1.0
type DDLIndex struct {
IndexName string // indexname (for ordering)
IndexDef string // indexdef (full CREATE INDEX statement)
}
DDLIndex represents an index from pg_indexes (excludes constraint-backing indexes).
type DDLMaterializedView ¶ added in v1.1.0
type DDLMaterializedView struct {
Name string // quote_ident(c.relname)
ViewDef string // pg_get_viewdef(c.oid)
RelOptions *string // array_to_string(c.reloptions, ', '), nil if none
Tablespace *string // quote_ident(spcname), nil if default
}
DDLMaterializedView represents a materialized view.
type DDLPartitionChild ¶ added in v1.1.0
type DDLPartitionChild struct {
ChildName string // quote_ident(c.relname)
ParentName string // quote_ident(pc.relname)
BoundExpr string // pg_get_expr(c.relpartbound, c.oid)
}
DDLPartitionChild represents a partition child table.
type DDLRLSEnabled ¶ added in v1.1.0
type DDLRLSEnabled struct {
TableName string // quote_ident(c.relname)
Force bool // c.relforcerowsecurity
}
DDLRLSEnabled represents a table with row-level security enabled.
type DDLRLSPolicy ¶ added in v1.1.0
type DDLRLSPolicy struct {
PolicyName string // quote_ident(pol.polname)
TableName string // quote_ident(c.relname)
Command string // pol.polcmd: "r","a","w","d","*"
Permissive bool // pol.polpermissive
Roles []string // role names from polroles (empty or ["PUBLIC"] = default)
UsingExpr *string // pg_get_expr(pol.polqual, pol.polrelid)
WithCheck *string // pg_get_expr(pol.polwithcheck, pol.polrelid)
}
DDLRLSPolicy represents a row-level security policy.
type DDLSequenceRaw ¶ added in v1.1.0
type DDLSequenceRaw struct {
SeqParams
Kind string // 'standalone', 'serial', or 'identity'
OwnerTable *string // quote_ident(owning table) for serial/identity
OwnerColumn *string // quote_ident(owning column) for serial/identity
IdentityKind *string // 'a' or 'd' for identity sequences
DefaultExpr *string // nextval(...) expression for serial sequences
OwnerRelKind *string // relkind of owning table ('r' or 'p')
}
DDLSequenceRaw is the scan struct for the unified sequence query.
type DDLSerialSequence ¶ added in v1.1.0
type DDLSerialSequence struct {
SeqParams
TableName string // owning table (quoted)
ColumnName string // owning column (quoted)
DefaultExpr string // the nextval(...) expression
}
DDLSerialSequence represents a serial-backing sequence with its owning column.
type DDLTable ¶ added in v1.1.0
type DDLTable struct {
OID uint32
Name string // c.relname (raw, for grouping)
QuotedName string // quote_ident(c.relname)
RelKind string // c.relkind: "r" or "p"
Persistence string // c.relpersistence: "p" (permanent), "u" (unlogged)
RelOptions *string // array_to_string(c.reloptions, ', '), nil if none
Tablespace *string // quote_ident(spcname), nil if default
PartitionKey *string // pg_get_partkeydef(c.oid), nil if not partitioned
InheritsFrom *string // comma-separated quoted parent names, nil if none
}
DDLTable represents a regular table or partitioned parent (relkind 'r' or 'p').
type DDLTrigger ¶ added in v1.1.0
type DDLTrigger struct {
TableName string // c.relname (for ordering)
TrigName string // t.tgname (for ordering)
TriggerDef string // pg_get_triggerdef(t.oid) — full CREATE TRIGGER text
}
DDLTrigger represents a user-defined trigger.
type DDLView ¶ added in v1.1.0
type DDLView struct {
Name string // quote_ident(c.relname)
ViewDef string // pg_get_viewdef(c.oid)
RelOptions *string // array_to_string(c.reloptions, ', '), nil if none
}
DDLView represents a regular view.
type DatabaseSizeRow ¶ added in v1.1.0
type DatabaseSizeRow struct {
TotalSizeBytes Bigint `json:"total_size_bytes" db:"total_size_bytes"`
}
type DoublePrecision ¶
type DoublePrecision float64 // pg: double precision / float8
type Float4Array ¶
type Float4Array = json.RawMessage
type Inet ¶
type Inet string
Inet wraps string for pg inet columns. Implements pgtype.NetipPrefixScanner so InetCodec's binary scan matches.
type Interval ¶
type Interval int64
Interval stores a pg interval as total microseconds. Implements pgtype.IntervalScanner so IntervalCodec's binary scan matches. PostgreSQL intervals have independent months/days/microseconds components; this type normalises them to a single microsecond count using the same conversion factors as PostgreSQL's EXTRACT(EPOCH): 1 month = 30 days, 1 day = 24 hours.
type PgAttributeRow ¶ added in v1.1.0
type PgAttributeRow struct {
AttRelID *Oid `json:"attrelid" db:"attrelid"`
AttName *Name `json:"attname" db:"attname"`
AttTypID *Bigint `json:"atttypid" db:"atttypid"`
AttLen *Smallint `json:"attlen" db:"attlen"`
AttNum *Smallint `json:"attnum" db:"attnum"`
AttStorage *Text `json:"attstorage" db:"attstorage"`
AttCompression *Text `json:"attcompression" db:"attcompression"` // PG14+; nil on older versions (column not in query)
AttNotNull *Boolean `json:"attnotnull" db:"attnotnull"`
AttStatTarget *Integer `json:"attstattarget" db:"attstattarget"`
AttAlign *Text `json:"attalign" db:"attalign"`
AttTypMod *Integer `json:"atttypmod" db:"atttypmod"`
}
PgAttributeRow represents a row from pg_attribute for user-table and index columns.
type PgClassConfig ¶ added in v1.1.0
type PgClassConfig struct {
BackfillBatchSize int `config:"backfill_batch_size" default:"500" min:"0"`
}
PgClassConfig holds configuration for the pg_class collector.
type PgClassRow ¶ added in v1.1.0
type PgClassRow struct {
Oid Oid `json:"oid"`
SchemaName Name `json:"schemaname"`
RelName Name `json:"relname"`
RelKind Text `json:"relkind"`
RelTuples Real `json:"reltuples"`
RelPages Integer `json:"relpages"`
RelFrozenXID Xid `json:"relfrozenxid"`
RelFrozenXIDAge Bigint `json:"relfrozenxid_age" db:"relfrozenxid_age"`
RelMinMXID Xid `json:"relminmxid"`
RelMinMXIDAge Bigint `json:"relminmxid_age" db:"relminmxid_age"`
RelOptions []Text `json:"reloptions"`
AccessMethod *Text `json:"access_method" db:"access_method"`
RelAllVisible Integer `json:"relallvisible"`
RelPersistence Text `json:"relpersistence"`
RelIsPartition Boolean `json:"relispartition"`
RelHasSubClass Boolean `json:"relhassubclass"`
RelToastRelID Oid `json:"reltoastrelid"`
RelTablespace Oid `json:"reltablespace"`
}
PgClassRow represents a single row from pg_class.
type PgConstraintRow ¶ added in v1.1.0
type PgConstraintRow struct {
Oid *Oid `json:"oid" db:"oid"`
ConName *Name `json:"conname" db:"conname"`
ConType *Text `json:"contype" db:"contype"`
ConRelID *Oid `json:"conrelid" db:"conrelid"`
ConIndID *Oid `json:"conindid" db:"conindid"`
ConfRelID *Oid `json:"confrelid" db:"confrelid"`
ConKey []Smallint `json:"conkey" db:"conkey"`
ConfKey []Smallint `json:"confkey" db:"confkey"`
ConDeferrable *Boolean `json:"condeferrable" db:"condeferrable"`
ConDeferred *Boolean `json:"condeferred" db:"condeferred"`
ConValidated *Boolean `json:"convalidated" db:"convalidated"`
}
PgConstraintRow represents a row from pg_constraint for user-schema constraints.
type PgDatabaseRow ¶ added in v1.1.0
type PgDatabaseRow struct {
Oid Oid `json:"oid"`
DatName Name `json:"datname"`
DatIsTemplate Boolean `json:"datistemplate"`
DatFrozenXID Xid `json:"datfrozenxid"`
DatFrozenXIDAge Bigint `json:"datfrozenxid_age" db:"datfrozenxid_age"`
DatMinMXID Xid `json:"datminmxid"`
DatMinMXIDAge Bigint `json:"datminmxid_age" db:"datminmxid_age"`
}
PgDatabaseRow represents a single row from pg_database.
type PgIndexInventoryRow ¶ added in v1.1.0
type PgIndexInventoryRow struct {
SchemaName *Name `json:"schemaname" db:"schemaname"`
TableName *Name `json:"tablename" db:"tablename"`
IndexName *Name `json:"indexname" db:"indexname"`
IndexRelID *Oid `json:"indexrelid" db:"indexrelid"`
IndRelID *Oid `json:"indrelid" db:"indrelid"`
IndNatts *Smallint `json:"indnatts" db:"indnatts"`
IndNKeyAtts *Smallint `json:"indnkeyatts" db:"indnkeyatts"`
IndIsUnique *Boolean `json:"indisunique" db:"indisunique"`
IndNullsNotDistinct *Boolean `json:"indnullsnotdistinct" db:"indnullsnotdistinct"` // PG15+
IndIsPrimary *Boolean `json:"indisprimary" db:"indisprimary"`
IndIsExclusion *Boolean `json:"indisexclusion" db:"indisexclusion"`
IndexDef *Text `json:"indexdef" db:"indexdef"`
IsPartial *Boolean `json:"is_partial" db:"is_partial"`
IndPredSQL *Text `json:"indpred_sql" db:"indpred_sql"`
IndKey []Smallint `json:"indkey" db:"indkey"`
IndOption []Smallint `json:"indoption" db:"indoption"`
IndClass []Oid `json:"indclass" db:"indclass"`
IndCollation []Oid `json:"indcollation" db:"indcollation"`
IndExprsSQL *Text `json:"indexprs_sql" db:"indexprs_sql"`
}
PgIndexInventoryRow carries the slow-moving definitional fields for an index — everything that only changes on DDL. The fast-moving stats and lifecycle bools (reltuples, relpages, indisvalid, indisready, indislive, indimmediate, indisclustered, indisreplident, indcheckxmin) travel via the pg_index hot collector.
type PgIndexRow ¶ added in v1.1.0
type PgIndexRow struct {
SchemaName *Name `json:"schemaname" db:"schemaname"`
IndexName *Name `json:"indexname" db:"indexname"`
RelTuples *Real `json:"reltuples" db:"reltuples"`
RelPages *Integer `json:"relpages" db:"relpages"`
IndIsValid *Boolean `json:"indisvalid" db:"indisvalid"`
IndIsReady *Boolean `json:"indisready" db:"indisready"`
IndIsLive *Boolean `json:"indislive" db:"indislive"`
IndImmediate *Boolean `json:"indimmediate" db:"indimmediate"`
IndIsClustered *Boolean `json:"indisclustered" db:"indisclustered"`
IndIsReplIdent *Boolean `json:"indisreplident" db:"indisreplident"`
IndCheckXmin *Boolean `json:"indcheckxmin" db:"indcheckxmin"`
}
PgIndexRow carries the fast-moving fields per index: stats (reltuples, relpages) and the lifecycle bools that flip during REINDEX, CREATE INDEX CONCURRENTLY, validation, and clustering. Definitional fields (indexdef, indkey, indisunique, etc.) are emitted by the separate pg_index_inventory collector on a slower cadence.
type PgLocksRow ¶ added in v1.1.0
type PgLocksRow struct {
LockType *Text `json:"locktype" db:"locktype"`
Database *Oid `json:"database" db:"database"`
Relation *Oid `json:"relation" db:"relation"`
Page *Integer `json:"page" db:"page"`
Tuple *Smallint `json:"tuple" db:"tuple"`
VirtualXID *Text `json:"virtualxid" db:"virtualxid"`
TransactionID *Xid `json:"transactionid" db:"transactionid"`
TransactionIDAge *Bigint `json:"transactionid_age" db:"transactionid_age"`
ClassID *Oid `json:"classid" db:"classid"`
ObjID *Oid `json:"objid" db:"objid"`
ObjSubID *Smallint `json:"objsubid" db:"objsubid"`
VirtualTransaction *Text `json:"virtualtransaction" db:"virtualtransaction"`
PID *Integer `json:"pid" db:"pid"`
Mode *Text `json:"mode" db:"mode"`
Granted *Boolean `json:"granted" db:"granted"`
FastPath *Boolean `json:"fastpath" db:"fastpath"`
WaitStart *TimestampTZ `json:"waitstart" db:"waitstart"`
}
PgLocksRow represents a filtered row from pg_locks (blocked + blockers only).
type PgPreparedXactsRow ¶
type PgPreparedXactsRow struct {
Transaction *Xid `json:"transaction" db:"transaction"`
TransactionAge *Bigint `json:"transaction_age" db:"transaction_age"`
GID *Text `json:"gid" db:"gid"`
Prepared *TimestampTZ `json:"prepared" db:"prepared"`
Owner *Name `json:"owner" db:"owner"`
Database *Name `json:"database" db:"database"`
}
PgPreparedXactsRow represents a row from pg_prepared_xacts.
type PgReplicationSlotsRow ¶
type PgReplicationSlotsRow struct {
SlotName *Name `json:"slot_name" db:"slot_name"`
Plugin *Name `json:"plugin" db:"plugin"`
SlotType *Text `json:"slot_type" db:"slot_type"`
DatOID *Oid `json:"datoid" db:"datoid"`
Database *Name `json:"database" db:"database"`
Temporary *Boolean `json:"temporary" db:"temporary"`
Active *Boolean `json:"active" db:"active"`
ActivePID *Integer `json:"active_pid" db:"active_pid"`
Xmin *Xid `json:"xmin" db:"xmin"`
XminAge *Bigint `json:"xmin_age" db:"xmin_age"`
CatalogXmin *Xid `json:"catalog_xmin" db:"catalog_xmin"`
CatalogXminAge *Bigint `json:"catalog_xmin_age" db:"catalog_xmin_age"`
RestartLsn *PgLsn `json:"restart_lsn" db:"restart_lsn"`
ConfirmedFlushLsn *PgLsn `json:"confirmed_flush_lsn" db:"confirmed_flush_lsn"`
WalStatus *Text `json:"wal_status" db:"wal_status"`
SafeWalSize *Bigint `json:"safe_wal_size" db:"safe_wal_size"`
TwoPhase *Boolean `json:"two_phase" db:"two_phase"`
Conflicting *Boolean `json:"conflicting" db:"conflicting"`
InvalidationReason *Text `json:"invalidation_reason" db:"invalidation_reason"`
Failover *Boolean `json:"failover" db:"failover"` // PG 17+
Synced *Boolean `json:"synced" db:"synced"` // PG 17+
}
PgReplicationSlotsRow represents a row from pg_replication_slots.
type PgSettingsRow ¶ added in v1.1.0
type PgSettingsRow struct {
Name Text `json:"name" db:"name"`
Setting Text `json:"setting" db:"setting"`
Unit *Text `json:"unit" db:"unit"`
Category Text `json:"category" db:"category"`
ShortDesc Text `json:"short_desc" db:"short_desc"`
ExtraDesc *Text `json:"extra_desc" db:"extra_desc"`
Context Text `json:"context" db:"context"`
Vartype Text `json:"vartype" db:"vartype"`
Source Text `json:"source" db:"source"`
MinVal *Text `json:"min_val" db:"min_val"`
MaxVal *Text `json:"max_val" db:"max_val"`
EnumVals []Text `json:"enumvals" db:"enumvals"`
BootVal *Text `json:"boot_val" db:"boot_val"`
ResetVal *Text `json:"reset_val" db:"reset_val"`
Sourcefile *Text `json:"sourcefile" db:"sourcefile"`
Sourceline *Integer `json:"sourceline" db:"sourceline"`
PendingRestart Boolean `json:"pending_restart" db:"pending_restart"`
}
PgSettingsRow represents a single row from the pg_settings view. All columns are included; nullable columns use pointer types. The Scanner gracefully handles missing or extra columns across PG versions (unknown columns are skipped, missing columns get zero values).
func QueryPgSettings ¶ added in v1.1.0
QueryPgSettings returns all rows from the pg_settings view. This is a shared utility used by the tuning loop (GetActiveConfig) and can later back a catalog collector.
type PgStatActivityRow ¶
type PgStatActivityRow struct {
DatID *Oid `json:"datid" db:"datid"`
DatName *Name `json:"datname" db:"datname"`
PID *Integer `json:"pid" db:"pid"`
LeaderPID *Integer `json:"leader_pid" db:"leader_pid"`
UseSysID *Oid `json:"usesysid" db:"usesysid"`
UseName *Name `json:"usename" db:"usename"`
ApplicationName *Text `json:"application_name" db:"application_name"`
ClientAddr *Inet `json:"client_addr" db:"client_addr"`
ClientHostname *Text `json:"client_hostname" db:"client_hostname"`
ClientPort *Integer `json:"client_port" db:"client_port"`
BackendStart *TimestampTZ `json:"backend_start" db:"backend_start"`
XactStart *TimestampTZ `json:"xact_start" db:"xact_start"`
QueryStart *TimestampTZ `json:"query_start" db:"query_start"`
StateChange *TimestampTZ `json:"state_change" db:"state_change"`
WaitEventType *Text `json:"wait_event_type" db:"wait_event_type"`
WaitEvent *Text `json:"wait_event" db:"wait_event"`
State *Text `json:"state" db:"state"`
BackendXID *Xid `json:"backend_xid" db:"backend_xid"`
BackendXIDAge *Bigint `json:"backend_xid_age" db:"backend_xid_age"`
BackendXmin *Xid `json:"backend_xmin" db:"backend_xmin"`
BackendXminAge *Bigint `json:"backend_xmin_age" db:"backend_xmin_age"`
QueryID *Text `json:"query_id" db:"query_id"` // PG 14+: composite queryid_usesysid_datid (matches pg_stat_statements key)
BackendType *Text `json:"backend_type" db:"backend_type"`
}
PgStatActivityRow represents a row from pg_stat_activity.
type PgStatArchiverRow ¶
type PgStatArchiverRow struct {
ArchivedCount *Bigint `json:"archived_count" db:"archived_count"`
LastArchivedWal *Text `json:"last_archived_wal" db:"last_archived_wal"`
LastArchivedTime *TimestampTZ `json:"last_archived_time" db:"last_archived_time"`
FailedCount *Bigint `json:"failed_count" db:"failed_count"`
LastFailedWal *Text `json:"last_failed_wal" db:"last_failed_wal"`
LastFailedTime *TimestampTZ `json:"last_failed_time" db:"last_failed_time"`
StatsReset *TimestampTZ `json:"stats_reset" db:"stats_reset"`
}
PgStatArchiverRow represents a row from pg_stat_archiver.
type PgStatBgwriterRow ¶
type PgStatBgwriterRow struct {
CheckpointsTimed *Bigint `json:"checkpoints_timed" db:"checkpoints_timed"`
CheckpointsReq *Bigint `json:"checkpoints_req" db:"checkpoints_req"`
CheckpointWriteTime *DoublePrecision `json:"checkpoint_write_time" db:"checkpoint_write_time"`
CheckpointSyncTime *DoublePrecision `json:"checkpoint_sync_time" db:"checkpoint_sync_time"`
BuffersCheckpoint *Bigint `json:"buffers_checkpoint" db:"buffers_checkpoint"`
BuffersClean *Bigint `json:"buffers_clean" db:"buffers_clean"`
MaxwrittenClean *Bigint `json:"maxwritten_clean" db:"maxwritten_clean"`
BuffersBackend *Bigint `json:"buffers_backend" db:"buffers_backend"`
BuffersBackendFsync *Bigint `json:"buffers_backend_fsync" db:"buffers_backend_fsync"`
BuffersAlloc *Bigint `json:"buffers_alloc" db:"buffers_alloc"`
StatsReset *TimestampTZ `json:"stats_reset" db:"stats_reset"`
}
PgStatBgwriterRow represents a row from pg_stat_bgwriter.
type PgStatCheckpointerRow ¶
type PgStatCheckpointerRow struct {
NumTimed *Bigint `json:"num_timed" db:"num_timed"`
NumRequested *Bigint `json:"num_requested" db:"num_requested"`
RestartpointsTimed *Bigint `json:"restartpoints_timed" db:"restartpoints_timed"`
RestartpointsReq *Bigint `json:"restartpoints_req" db:"restartpoints_req"`
RestartpointsDone *Bigint `json:"restartpoints_done" db:"restartpoints_done"`
WriteTime *DoublePrecision `json:"write_time" db:"write_time"`
SyncTime *DoublePrecision `json:"sync_time" db:"sync_time"`
BuffersWritten *Bigint `json:"buffers_written" db:"buffers_written"`
StatsReset *TimestampTZ `json:"stats_reset" db:"stats_reset"`
SlruWritten *Bigint `json:"slru_written" db:"slru_written"`
}
PgStatCheckpointerRow represents a row from pg_stat_checkpointer (PG 17+).
type PgStatDatabaseConflictsRow ¶
type PgStatDatabaseConflictsRow struct {
DatID *Oid `json:"datid" db:"datid"`
DatName *Name `json:"datname" db:"datname"`
ConflTablespace *Bigint `json:"confl_tablespace" db:"confl_tablespace"`
ConflLock *Bigint `json:"confl_lock" db:"confl_lock"`
ConflSnapshot *Bigint `json:"confl_snapshot" db:"confl_snapshot"`
ConflBufferpin *Bigint `json:"confl_bufferpin" db:"confl_bufferpin"`
ConflDeadlock *Bigint `json:"confl_deadlock" db:"confl_deadlock"`
ConflLogicalSlot *Bigint `json:"confl_active_logicalslot" db:"confl_active_logicalslot"`
}
PgStatDatabaseConflictsRow represents a row from pg_stat_database_conflicts.
type PgStatDatabaseRow ¶
type PgStatDatabaseRow struct {
DatID *Oid `json:"datid" db:"datid"`
DatName *Name `json:"datname" db:"datname"`
NumBackends *Integer `json:"numbackends" db:"numbackends"`
XactCommit *Bigint `json:"xact_commit" db:"xact_commit"`
XactRollback *Bigint `json:"xact_rollback" db:"xact_rollback"`
BlksRead *Bigint `json:"blks_read" db:"blks_read"`
BlksHit *Bigint `json:"blks_hit" db:"blks_hit"`
TupReturned *Bigint `json:"tup_returned" db:"tup_returned"`
TupFetched *Bigint `json:"tup_fetched" db:"tup_fetched"`
TupInserted *Bigint `json:"tup_inserted" db:"tup_inserted"`
TupUpdated *Bigint `json:"tup_updated" db:"tup_updated"`
TupDeleted *Bigint `json:"tup_deleted" db:"tup_deleted"`
Conflicts *Bigint `json:"conflicts" db:"conflicts"`
TempFiles *Bigint `json:"temp_files" db:"temp_files"`
TempBytes *Bigint `json:"temp_bytes" db:"temp_bytes"`
Deadlocks *Bigint `json:"deadlocks" db:"deadlocks"`
ChecksumFailures *Bigint `json:"checksum_failures" db:"checksum_failures"`
ChecksumLastFailure *TimestampTZ `json:"checksum_last_failure" db:"checksum_last_failure"`
BlkReadTime *DoublePrecision `json:"blk_read_time" db:"blk_read_time"`
BlkWriteTime *DoublePrecision `json:"blk_write_time" db:"blk_write_time"`
SessionTime *DoublePrecision `json:"session_time" db:"session_time"`
ActiveTime *DoublePrecision `json:"active_time" db:"active_time"`
IdleInTransactionTime *DoublePrecision `json:"idle_in_transaction_time" db:"idle_in_transaction_time"`
Sessions *Bigint `json:"sessions" db:"sessions"`
SessionsAbandoned *Bigint `json:"sessions_abandoned" db:"sessions_abandoned"`
SessionsFatal *Bigint `json:"sessions_fatal" db:"sessions_fatal"`
SessionsKilled *Bigint `json:"sessions_killed" db:"sessions_killed"`
StatsReset *TimestampTZ `json:"stats_reset" db:"stats_reset"`
ParallelWorkers *Bigint `json:"parallel_workers" db:"parallel_workers"`
TempBytesRead *Bigint `json:"temp_bytes_read" db:"temp_bytes_read"`
TempBytesWritten *Bigint `json:"temp_bytes_written" db:"temp_bytes_written"`
TempFilesRead *Bigint `json:"temp_files_read" db:"temp_files_read"`
TempFilesWritten *Bigint `json:"temp_files_written" db:"temp_files_written"`
}
PgStatDatabaseRow represents a row from pg_stat_database.
type PgStatIORow ¶
type PgStatIORow struct {
BackendType *Text `json:"backend_type" db:"backend_type"`
Object *Text `json:"object" db:"object"`
Context *Text `json:"context" db:"context"`
Reads *Bigint `json:"reads" db:"reads"`
ReadTime *DoublePrecision `json:"read_time" db:"read_time"`
Writes *Bigint `json:"writes" db:"writes"`
WriteTime *DoublePrecision `json:"write_time" db:"write_time"`
Writebacks *Bigint `json:"writebacks" db:"writebacks"`
WritebackTime *DoublePrecision `json:"writeback_time" db:"writeback_time"`
Extends *Bigint `json:"extends" db:"extends"`
ExtendTime *DoublePrecision `json:"extend_time" db:"extend_time"`
OpBytes *Bigint `json:"op_bytes" db:"op_bytes"`
Hits *Bigint `json:"hits" db:"hits"`
Evictions *Bigint `json:"evictions" db:"evictions"`
Reuses *Bigint `json:"reuses" db:"reuses"`
Fsyncs *Bigint `json:"fsyncs" db:"fsyncs"`
FsyncTime *DoublePrecision `json:"fsync_time" db:"fsync_time"`
StatsReset *TimestampTZ `json:"stats_reset" db:"stats_reset"`
}
PgStatIORow represents a row from pg_stat_io (PG 16+).
type PgStatProgressAnalyzeRow ¶
type PgStatProgressAnalyzeRow struct {
PID *Integer `json:"pid" db:"pid"`
DatID *Oid `json:"datid" db:"datid"`
DatName *Name `json:"datname" db:"datname"`
RelID *Oid `json:"relid" db:"relid"`
Phase *Text `json:"phase" db:"phase"`
SampleBlksTotal *Bigint `json:"sample_blks_total" db:"sample_blks_total"`
SampleBlksScanned *Bigint `json:"sample_blks_scanned" db:"sample_blks_scanned"`
ExtStatsTotal *Bigint `json:"ext_stats_total" db:"ext_stats_total"`
ExtStatsComputed *Bigint `json:"ext_stats_computed" db:"ext_stats_computed"`
ChildTablesTotal *Bigint `json:"child_tables_total" db:"child_tables_total"`
ChildTablesDone *Bigint `json:"child_tables_done" db:"child_tables_done"`
CurrentChildTableRelID *Oid `json:"current_child_table_relid" db:"current_child_table_relid"`
}
PgStatProgressAnalyzeRow represents a row from pg_stat_progress_analyze (PG 13+).
type PgStatProgressCreateIndexRow ¶
type PgStatProgressCreateIndexRow struct {
PID *Integer `json:"pid" db:"pid"`
DatID *Oid `json:"datid" db:"datid"`
DatName *Name `json:"datname" db:"datname"`
RelID *Oid `json:"relid" db:"relid"`
IndexRelID *Oid `json:"index_relid" db:"index_relid"`
Command *Text `json:"command" db:"command"`
Phase *Text `json:"phase" db:"phase"`
LockersTotal *Bigint `json:"lockers_total" db:"lockers_total"`
LockersDone *Bigint `json:"lockers_done" db:"lockers_done"`
CurrentLockerPID *Bigint `json:"current_locker_pid" db:"current_locker_pid"`
BlocksTotal *Bigint `json:"blocks_total" db:"blocks_total"`
BlocksDone *Bigint `json:"blocks_done" db:"blocks_done"`
TuplesTotal *Bigint `json:"tuples_total" db:"tuples_total"`
TuplesDone *Bigint `json:"tuples_done" db:"tuples_done"`
PartitionsTotal *Bigint `json:"partitions_total" db:"partitions_total"`
PartitionsDone *Bigint `json:"partitions_done" db:"partitions_done"`
}
PgStatProgressCreateIndexRow represents a row from pg_stat_progress_create_index.
type PgStatProgressVacuumRow ¶
type PgStatProgressVacuumRow struct {
PID *Integer `json:"pid" db:"pid"`
DatID *Oid `json:"datid" db:"datid"`
DatName *Name `json:"datname" db:"datname"`
RelID *Oid `json:"relid" db:"relid"`
Phase *Text `json:"phase" db:"phase"`
HeapBlksTotal *Bigint `json:"heap_blks_total" db:"heap_blks_total"`
HeapBlksScanned *Bigint `json:"heap_blks_scanned" db:"heap_blks_scanned"`
HeapBlksVacuumed *Bigint `json:"heap_blks_vacuumed" db:"heap_blks_vacuumed"`
IndexVacuumCount *Bigint `json:"index_vacuum_count" db:"index_vacuum_count"`
MaxDeadTuples *Bigint `json:"max_dead_tuples" db:"max_dead_tuples"`
NumDeadTuples *Bigint `json:"num_dead_tuples" db:"num_dead_tuples"`
}
PgStatProgressVacuumRow represents a row from pg_stat_progress_vacuum.
type PgStatRecoveryPrefetchRow ¶
type PgStatRecoveryPrefetchRow struct {
StatsReset *TimestampTZ `json:"stats_reset" db:"stats_reset"`
Prefetch *Bigint `json:"prefetch" db:"prefetch"`
Hit *Bigint `json:"hit" db:"hit"`
SkipInit *Bigint `json:"skip_init" db:"skip_init"`
SkipNew *Bigint `json:"skip_new" db:"skip_new"`
SkipFpw *Bigint `json:"skip_fpw" db:"skip_fpw"`
SkipRep *Bigint `json:"skip_rep" db:"skip_rep"`
WalDistance *Integer `json:"wal_distance" db:"wal_distance"`
BlockDistance *Integer `json:"block_distance" db:"block_distance"`
IoDepth *Integer `json:"io_depth" db:"io_depth"`
}
PgStatRecoveryPrefetchRow represents a row from pg_stat_recovery_prefetch (PG 15+).
type PgStatReplicationRow ¶
type PgStatReplicationRow struct {
PID *Integer `json:"pid" db:"pid"`
UseSysID *Oid `json:"usesysid" db:"usesysid"`
UseName *Name `json:"usename" db:"usename"`
ApplicationName *Text `json:"application_name" db:"application_name"`
ClientAddr *Inet `json:"client_addr" db:"client_addr"`
ClientHostname *Text `json:"client_hostname" db:"client_hostname"`
ClientPort *Integer `json:"client_port" db:"client_port"`
BackendStart *TimestampTZ `json:"backend_start" db:"backend_start"`
BackendXmin *Xid `json:"backend_xmin" db:"backend_xmin"`
BackendXminAge *Bigint `json:"backend_xmin_age" db:"backend_xmin_age"`
State *Text `json:"state" db:"state"`
SentLsn *PgLsn `json:"sent_lsn" db:"sent_lsn"`
WriteLsn *PgLsn `json:"write_lsn" db:"write_lsn"`
FlushLsn *PgLsn `json:"flush_lsn" db:"flush_lsn"`
ReplayLsn *PgLsn `json:"replay_lsn" db:"replay_lsn"`
WriteLag *Interval `json:"write_lag" db:"write_lag"`
FlushLag *Interval `json:"flush_lag" db:"flush_lag"`
ReplayLag *Interval `json:"replay_lag" db:"replay_lag"`
SyncPriority *Integer `json:"sync_priority" db:"sync_priority"`
SyncState *Text `json:"sync_state" db:"sync_state"`
ReplyTime *TimestampTZ `json:"reply_time" db:"reply_time"`
}
PgStatReplicationRow represents a row from pg_stat_replication.
type PgStatReplicationSlotsRow ¶
type PgStatReplicationSlotsRow struct {
SlotName *Name `json:"slot_name" db:"slot_name"`
SpillTxns *Bigint `json:"spill_txns" db:"spill_txns"`
SpillCount *Bigint `json:"spill_count" db:"spill_count"`
SpillBytes *Bigint `json:"spill_bytes" db:"spill_bytes"`
StreamTxns *Bigint `json:"stream_txns" db:"stream_txns"`
StreamCount *Bigint `json:"stream_count" db:"stream_count"`
StreamBytes *Bigint `json:"stream_bytes" db:"stream_bytes"`
TotalTxns *Bigint `json:"total_txns" db:"total_txns"`
TotalBytes *Bigint `json:"total_bytes" db:"total_bytes"`
StatsReset *TimestampTZ `json:"stats_reset" db:"stats_reset"`
}
PgStatReplicationSlotsRow represents a row from pg_stat_replication_slots (PG 14+).
type PgStatSlruRow ¶
type PgStatSlruRow struct {
Name *Text `json:"name" db:"name"`
BlksZeroed *Bigint `json:"blks_zeroed" db:"blks_zeroed"`
BlksHit *Bigint `json:"blks_hit" db:"blks_hit"`
BlksRead *Bigint `json:"blks_read" db:"blks_read"`
BlksWritten *Bigint `json:"blks_written" db:"blks_written"`
BlksExists *Bigint `json:"blks_exists" db:"blks_exists"`
Flushes *Bigint `json:"flushes" db:"flushes"`
Truncates *Bigint `json:"truncates" db:"truncates"`
StatsReset *TimestampTZ `json:"stats_reset" db:"stats_reset"`
}
PgStatSlruRow represents a row from pg_stat_slru.
type PgStatStatementsConfig ¶ added in v1.1.0
type PgStatStatementsConfig struct {
DiffLimit int `config:"diff_limit" default:"500" min:"0" max:"500"`
IncludeQueries bool `config:"include_queries" default:"true"`
MaxQueryTextLength int `config:"max_query_text_length" default:"8192" min:"0" max:"8192"`
}
PgStatStatementsConfig holds configuration for the pg_stat_statements collector.
type PgStatStatementsDelta ¶ added in v1.1.0
type PgStatStatementsDelta struct {
UserID *Oid `json:"userid" db:"userid"`
DbID *Oid `json:"dbid" db:"dbid"`
QueryID *Bigint `json:"queryid" db:"queryid"`
Calls *Bigint `json:"calls" db:"calls"`
TotalExecTime *DoublePrecision `json:"total_exec_time" db:"total_exec_time"`
}
PgStatStatementsDelta holds the per-query diff between two consecutive snapshots.
type PgStatStatementsExtVersion ¶ added in v1.1.0
PgStatStatementsExtVersion is a parsed pg_stat_statements extension version (e.g. extversion '1.10' -> {Major:1, Minor:10}). The available column set is determined by this extension version, not by the PostgreSQL server major version: a server that has been upgraded (e.g. PG 16 -> 17) keeps the previously-installed extension version until ALTER EXTENSION ... UPDATE is run, so the two move independently. Managed services such as Amazon RDS regularly upgrade the server but leave existing extensions at their old version, producing the realistic "new server / old extension" combination.
References:
- https://www.postgresql.org/docs/current/pgstatstatements.html
- https://www.postgresql.org/docs/current/sql-alterextension.html (ALTER EXTENSION ... UPDATE)
func (PgStatStatementsExtVersion) GTE ¶ added in v1.1.0
func (v PgStatStatementsExtVersion) GTE(major, minor int) bool
GTE reports whether v is at least major.minor.
type PgStatStatementsPayload ¶ added in v1.1.0
type PgStatStatementsPayload struct {
CollectedAt time.Time `json:"collected_at"`
Rows []PgStatStatementsRow `json:"rows"`
Deltas []PgStatStatementsDelta `json:"deltas,omitempty"`
DeltaCount int `json:"delta_count"`
AverageQueryRuntime float64 `json:"average_query_runtime"`
}
PgStatStatementsPayload is the JSON body POSTed to /api/v1/agent/pg_stat_statements.
type PgStatStatementsRow ¶ added in v1.1.0
type PgStatStatementsRow struct {
// Identifiers
UserID *Oid `json:"userid" db:"userid"`
DbID *Oid `json:"dbid" db:"dbid"`
QueryID *Bigint `json:"queryid" db:"queryid"`
// Query text
Query *Text `json:"query,omitempty" db:"query"`
QueryLen *Bigint `json:"query_len,omitempty" db:"query_len"`
// Core counters (all versions)
Calls *Bigint `json:"calls" db:"calls"`
TotalExecTime *DoublePrecision `json:"total_exec_time" db:"total_exec_time"`
MinExecTime *DoublePrecision `json:"min_exec_time" db:"min_exec_time"`
MaxExecTime *DoublePrecision `json:"max_exec_time" db:"max_exec_time"`
MeanExecTime *DoublePrecision `json:"mean_exec_time" db:"mean_exec_time"`
StddevExecTime *DoublePrecision `json:"stddev_exec_time" db:"stddev_exec_time"`
Rows *Bigint `json:"rows" db:"rows"`
// Block I/O (all versions)
LocalBlksHit *Bigint `json:"local_blks_hit" db:"local_blks_hit"`
LocalBlksRead *Bigint `json:"local_blks_read" db:"local_blks_read"`
LocalBlksDirtied *Bigint `json:"local_blks_dirtied" db:"local_blks_dirtied"`
LocalBlksWritten *Bigint `json:"local_blks_written" db:"local_blks_written"`
TempBlksRead *Bigint `json:"temp_blks_read" db:"temp_blks_read"`
TempBlksWritten *Bigint `json:"temp_blks_written" db:"temp_blks_written"`
// Block I/O timing — PG17 renamed blk_read/write_time to shared_blk_read/write_time.
// PG17+: local block I/O timing
LocalBlkReadTime *DoublePrecision `json:"local_blk_read_time,omitempty" db:"local_blk_read_time"`
LocalBlkWriteTime *DoublePrecision `json:"local_blk_write_time,omitempty" db:"local_blk_write_time"`
// PG13+
Plans *Bigint `json:"plans" db:"plans"`
TotalPlanTime *DoublePrecision `json:"total_plan_time" db:"total_plan_time"`
MinPlanTime *DoublePrecision `json:"min_plan_time" db:"min_plan_time"`
MaxPlanTime *DoublePrecision `json:"max_plan_time" db:"max_plan_time"`
MeanPlanTime *DoublePrecision `json:"mean_plan_time" db:"mean_plan_time"`
StddevPlanTime *DoublePrecision `json:"stddev_plan_time" db:"stddev_plan_time"`
WalRecords *Bigint `json:"wal_records" db:"wal_records"`
WalFpi *Bigint `json:"wal_fpi" db:"wal_fpi"`
WalBytes *Bigint `json:"wal_bytes" db:"wal_bytes"`
// PG14+
TopLevel *Boolean `json:"toplevel" db:"toplevel"`
// PG15+
TempBlkReadTime *DoublePrecision `json:"temp_blk_read_time" db:"temp_blk_read_time"`
TempBlkWriteTime *DoublePrecision `json:"temp_blk_write_time" db:"temp_blk_write_time"`
JitFunctions *Bigint `json:"jit_functions" db:"jit_functions"`
JitGenerationTime *DoublePrecision `json:"jit_generation_time" db:"jit_generation_time"`
JitInliningCount *Bigint `json:"jit_inlining_count" db:"jit_inlining_count"`
JitInliningTime *DoublePrecision `json:"jit_inlining_time" db:"jit_inlining_time"`
JitOptimizationCount *Bigint `json:"jit_optimization_count" db:"jit_optimization_count"`
JitOptimizationTime *DoublePrecision `json:"jit_optimization_time" db:"jit_optimization_time"`
JitEmissionCount *Bigint `json:"jit_emission_count" db:"jit_emission_count"`
JitEmissionTime *DoublePrecision `json:"jit_emission_time" db:"jit_emission_time"`
}
PgStatStatementsRow represents a single row from pg_stat_statements.
type PgStatSubscriptionRow ¶
type PgStatSubscriptionRow struct {
SubID *Oid `json:"subid" db:"subid"`
SubName *Name `json:"subname" db:"subname"`
PID *Integer `json:"pid" db:"pid"`
LeaderPID *Integer `json:"leader_pid" db:"leader_pid"`
RelID *Oid `json:"relid" db:"relid"`
ReceivedLsn *PgLsn `json:"received_lsn" db:"received_lsn"`
LastMsgSendTime *TimestampTZ `json:"last_msg_send_time" db:"last_msg_send_time"`
LastMsgReceiptTime *TimestampTZ `json:"last_msg_receipt_time" db:"last_msg_receipt_time"`
LatestEndLsn *PgLsn `json:"latest_end_lsn" db:"latest_end_lsn"`
LatestEndTime *TimestampTZ `json:"latest_end_time" db:"latest_end_time"`
WorkerType *Text `json:"worker_type" db:"worker_type"`
}
PgStatSubscriptionRow represents a row from pg_stat_subscription.
type PgStatSubscriptionStatsRow ¶
type PgStatSubscriptionStatsRow struct {
SubID *Oid `json:"subid" db:"subid"`
SubName *Name `json:"subname" db:"subname"`
ApplyErrorCount *Bigint `json:"apply_error_count" db:"apply_error_count"`
SyncErrorCount *Bigint `json:"sync_error_count" db:"sync_error_count"`
StatsReset *TimestampTZ `json:"stats_reset" db:"stats_reset"`
}
PgStatSubscriptionStatsRow represents a row from pg_stat_subscription_stats (PG 15+).
type PgStatUserFunctionsRow ¶ added in v1.1.0
type PgStatUserFunctionsRow struct {
FuncID *Oid `json:"funcid" db:"funcid"`
SchemaName *Name `json:"schemaname" db:"schemaname"`
FuncName *Name `json:"funcname" db:"funcname"`
Calls *Bigint `json:"calls" db:"calls"`
TotalTime *DoublePrecision `json:"total_time" db:"total_time"`
SelfTime *DoublePrecision `json:"self_time" db:"self_time"`
}
PgStatUserFunctionsRow represents a row from pg_stat_user_functions.
type PgStatUserIndexesConfig ¶ added in v1.1.0
type PgStatUserIndexesConfig struct {
CategoryLimit int `config:"category_limit" default:"200" min:"0"`
}
PgStatUserIndexesConfig holds configuration for the pg_stat_user_indexes collector.
type PgStatUserIndexesRow ¶ added in v1.1.0
type PgStatUserIndexesRow struct {
RelID *Oid `json:"relid" db:"relid"`
IndexRelID *Oid `json:"indexrelid" db:"indexrelid"`
SchemaName *Name `json:"schemaname" db:"schemaname"`
RelName *Name `json:"relname" db:"relname"`
IndexRelName *Name `json:"indexrelname" db:"indexrelname"`
IdxScan *Bigint `json:"idx_scan" db:"idx_scan"`
LastIdxScan *TimestampTZ `json:"last_idx_scan" db:"last_idx_scan"`
IdxTupRead *Bigint `json:"idx_tup_read" db:"idx_tup_read"`
IdxTupFetch *Bigint `json:"idx_tup_fetch" db:"idx_tup_fetch"`
}
PgStatUserIndexesRow represents a row from pg_stat_user_indexes.
type PgStatUserTableRow ¶ added in v1.1.0
type PgStatUserTableRow struct {
RelID *Oid `json:"relid" db:"relid"`
SchemaName Name `json:"schemaname" db:"schemaname"`
RelName Name `json:"relname" db:"relname"`
SeqScan *Bigint `json:"seq_scan" db:"seq_scan"`
LastSeqScan *TimestampTZ `json:"last_seq_scan" db:"last_seq_scan"`
SeqTupRead *Bigint `json:"seq_tup_read" db:"seq_tup_read"`
IdxScan *Bigint `json:"idx_scan" db:"idx_scan"`
LastIdxScan *TimestampTZ `json:"last_idx_scan" db:"last_idx_scan"`
IdxTupFetch *Bigint `json:"idx_tup_fetch" db:"idx_tup_fetch"`
NTupIns *Bigint `json:"n_tup_ins" db:"n_tup_ins"`
NTupUpd *Bigint `json:"n_tup_upd" db:"n_tup_upd"`
NTupDel *Bigint `json:"n_tup_del" db:"n_tup_del"`
NTupHotUpd *Bigint `json:"n_tup_hot_upd" db:"n_tup_hot_upd"`
NTupNewpageUpd *Bigint `json:"n_tup_newpage_upd" db:"n_tup_newpage_upd"`
NLiveTup *Bigint `json:"n_live_tup" db:"n_live_tup"`
NDeadTup *Bigint `json:"n_dead_tup" db:"n_dead_tup"`
NModSinceAnalyze *Bigint `json:"n_mod_since_analyze" db:"n_mod_since_analyze"`
NInsSinceVacuum *Bigint `json:"n_ins_since_vacuum" db:"n_ins_since_vacuum"`
LastVacuum *TimestampTZ `json:"last_vacuum" db:"last_vacuum"`
LastAutovacuum *TimestampTZ `json:"last_autovacuum" db:"last_autovacuum"`
LastAnalyze *TimestampTZ `json:"last_analyze" db:"last_analyze"`
LastAutoanalyze *TimestampTZ `json:"last_autoanalyze" db:"last_autoanalyze"`
VacuumCount *Bigint `json:"vacuum_count" db:"vacuum_count"`
AutovacuumCount *Bigint `json:"autovacuum_count" db:"autovacuum_count"`
AnalyzeCount *Bigint `json:"analyze_count" db:"analyze_count"`
AutoanalyzeCount *Bigint `json:"autoanalyze_count" db:"autoanalyze_count"`
TotalVacuumTime *DoublePrecision `json:"total_vacuum_time" db:"total_vacuum_time"`
TotalAutovacuumTime *DoublePrecision `json:"total_autovacuum_time" db:"total_autovacuum_time"`
TotalAnalyzeTime *DoublePrecision `json:"total_analyze_time" db:"total_analyze_time"`
TotalAutoanalyzeTime *DoublePrecision `json:"total_autoanalyze_time" db:"total_autoanalyze_time"`
}
PgStatUserTableRow represents a single row from pg_stat_user_tables.
type PgStatUserTablesConfig ¶ added in v1.1.0
type PgStatUserTablesConfig struct {
CategoryLimit int `config:"category_limit" default:"200" min:"0"`
}
PgStatUserTablesConfig holds configuration for the pg_stat_user_tables collector.
type PgStatWalReceiverRow ¶
type PgStatWalReceiverRow struct {
PID *Integer `json:"pid" db:"pid"`
Status *Text `json:"status" db:"status"`
ReceiveStartLsn *PgLsn `json:"receive_start_lsn" db:"receive_start_lsn"`
ReceiveStartTli *Integer `json:"receive_start_tli" db:"receive_start_tli"`
WrittenLsn *PgLsn `json:"written_lsn" db:"written_lsn"`
FlushedLsn *PgLsn `json:"flushed_lsn" db:"flushed_lsn"`
ReceivedTli *Integer `json:"received_tli" db:"received_tli"`
LastMsgSendTime *TimestampTZ `json:"last_msg_send_time" db:"last_msg_send_time"`
LastMsgReceiptTime *TimestampTZ `json:"last_msg_receipt_time" db:"last_msg_receipt_time"`
LatestEndLsn *PgLsn `json:"latest_end_lsn" db:"latest_end_lsn"`
LatestEndTime *TimestampTZ `json:"latest_end_time" db:"latest_end_time"`
SlotName *Text `json:"slot_name" db:"slot_name"`
SenderHost *Text `json:"sender_host" db:"sender_host"`
SenderPort *Integer `json:"sender_port" db:"sender_port"`
}
PgStatWalReceiverRow represents a row from pg_stat_wal_receiver (no conninfo).
type PgStatWalRow ¶
type PgStatWalRow struct {
WalRecords *Bigint `json:"wal_records" db:"wal_records"`
WalFpi *Bigint `json:"wal_fpi" db:"wal_fpi"`
WalBytes *Bigint `json:"wal_bytes" db:"wal_bytes"` // pg numeric, but int64 suffices (~9.2 EB max)
WalBuffersFull *Bigint `json:"wal_buffers_full" db:"wal_buffers_full"`
WalWrite *Bigint `json:"wal_write" db:"wal_write"`
WalSync *Bigint `json:"wal_sync" db:"wal_sync"`
WalWriteTime *DoublePrecision `json:"wal_write_time" db:"wal_write_time"`
WalSyncTime *DoublePrecision `json:"wal_sync_time" db:"wal_sync_time"`
StatsReset *TimestampTZ `json:"stats_reset" db:"stats_reset"`
}
PgStatWalRow represents a row from pg_stat_wal (PG 14+).
type PgStatioUserIndexesConfig ¶ added in v1.1.0
type PgStatioUserIndexesConfig struct {
BackfillBatchSize int `config:"backfill_batch_size" default:"2000" min:"0"`
}
PgStatioUserIndexesConfig holds configuration for the pg_statio_user_indexes collector.
type PgStatioUserIndexesRow ¶ added in v1.1.0
type PgStatioUserIndexesRow struct {
RelID *Oid `json:"relid" db:"relid"`
IndexRelID *Oid `json:"indexrelid" db:"indexrelid"`
SchemaName *Name `json:"schemaname" db:"schemaname"`
RelName *Name `json:"relname" db:"relname"`
IndexRelName *Name `json:"indexrelname" db:"indexrelname"`
IdxBlksRead *Bigint `json:"idx_blks_read" db:"idx_blks_read"`
IdxBlksHit *Bigint `json:"idx_blks_hit" db:"idx_blks_hit"`
}
PgStatioUserIndexesRow represents a row from pg_statio_user_indexes.
type PgStatioUserTablesRow ¶ added in v1.1.0
type PgStatioUserTablesRow struct {
RelID *Oid `json:"relid" db:"relid"`
SchemaName *Name `json:"schemaname" db:"schemaname"`
RelName *Name `json:"relname" db:"relname"`
HeapBlksRead *Bigint `json:"heap_blks_read" db:"heap_blks_read"`
HeapBlksHit *Bigint `json:"heap_blks_hit" db:"heap_blks_hit"`
IdxBlksRead *Bigint `json:"idx_blks_read" db:"idx_blks_read"`
IdxBlksHit *Bigint `json:"idx_blks_hit" db:"idx_blks_hit"`
ToastBlksRead *Bigint `json:"toast_blks_read" db:"toast_blks_read"`
ToastBlksHit *Bigint `json:"toast_blks_hit" db:"toast_blks_hit"`
TidxBlksRead *Bigint `json:"tidx_blks_read" db:"tidx_blks_read"`
TidxBlksHit *Bigint `json:"tidx_blks_hit" db:"tidx_blks_hit"`
}
PgStatioUserTablesRow represents a row from pg_statio_user_tables.
type PgStatsConfig ¶ added in v1.1.0
type PgStatsConfig struct {
BackfillBatchSize int `config:"backfill_batch_size" default:"200" min:"0"`
IncludeTableData bool `config:"include_table_data"`
}
PgStatsConfig holds configuration for the pg_stats collector.
type PgStatsRow ¶ added in v1.1.0
type PgStatsRow struct {
SchemaName Name `json:"schemaname"`
TableName Name `json:"tablename"`
AttName Name `json:"attname"`
Inherited Boolean `json:"inherited"`
NullFrac *Real `json:"null_frac"`
AvgWidth *Integer `json:"avg_width"`
NDistinct *Real `json:"n_distinct"`
MostCommonVals Anyarray `json:"most_common_vals"`
MostCommonFreqs Float4Array `json:"most_common_freqs"`
HistogramBounds Anyarray `json:"histogram_bounds"`
Correlation *Real `json:"correlation"`
MostCommonElems Anyarray `json:"most_common_elems"`
MostCommonElemFreqs Float4Array `json:"most_common_elem_freqs"`
ElemCountHistogram Float4Array `json:"elem_count_histogram"`
}
PgStatsRow represents a single row from the pg_stats view.
type PgTypeRow ¶ added in v1.1.0
type PgTypeRow struct {
Oid *Oid `json:"oid" db:"oid"`
TypName *Name `json:"typname" db:"typname"`
TypNamespace *Oid `json:"typnamespace" db:"typnamespace"`
TypLen *Smallint `json:"typlen" db:"typlen"`
TypByVal *Boolean `json:"typbyval" db:"typbyval"`
TypAlign *Text `json:"typalign" db:"typalign"`
TypStorage *Text `json:"typstorage" db:"typstorage"`
TypCategory *Text `json:"typcategory" db:"typcategory"`
TypType *Text `json:"typtype" db:"typtype"`
TypBaseType *Oid `json:"typbasetype" db:"typbasetype"`
TypElem *Oid `json:"typelem" db:"typelem"`
TypRelID *Oid `json:"typrelid" db:"typrelid"`
}
PgTypeRow represents a row from pg_type.
type PrepareCtx ¶
PrepareCtx is a hook called before each catalog query to allow adapters (e.g. CNPG, Patroni) to perform failover checks or replace the context.
type SeqParams ¶ added in v1.1.0
type SeqParams struct {
Name string
DataType string
Start int64
Increment int64
MinValue int64
MaxValue int64
Cache int64
Cycle bool
}
SeqParams holds the common parameters shared by all sequence types.
type TimestampTZ ¶
TimestampTZ wraps time.Time for pg timestamptz columns. Implements pgtype.TimestamptzScanner so TimestamptzCodec's binary scan matches.
func (TimestampTZ) MarshalJSON ¶
func (t TimestampTZ) MarshalJSON() ([]byte, error)
func (*TimestampTZ) ScanTimestamptz ¶
func (t *TimestampTZ) ScanTimestamptz(v pgtype.Timestamptz) error
type TransactionCommitsRow ¶ added in v1.1.0
type UptimeMinutesRow ¶ added in v1.1.0
type UptimeMinutesRow struct {
UptimeMinutes DoublePrecision `json:"uptime_minutes" db:"uptime_minutes"`
}
type WaitEventRow ¶ added in v1.1.0
type WaitEventRow struct {
WaitEventType Text `json:"wait_event_type" db:"wait_event_type"`
CurrentCount Bigint `json:"current_count" db:"current_count"`
}
WaitEventRow represents a row from the wait events aggregation query.
Source Files
¶
- autovacuum_count.go
- collect.go
- connections.go
- database_size.go
- ddl.go
- ddl_collector.go
- ddl_format.go
- ddl_queries.go
- ddl_schema.go
- pg_attribute.go
- pg_class.go
- pg_constraint.go
- pg_database.go
- pg_index.go
- pg_index_inventory.go
- pg_locks.go
- pg_prepared_xacts.go
- pg_replication_slots.go
- pg_settings.go
- pg_stat_activity.go
- pg_stat_archiver.go
- pg_stat_bgwriter.go
- pg_stat_checkpointer.go
- pg_stat_database.go
- pg_stat_database_conflicts.go
- pg_stat_io.go
- pg_stat_progress_analyze.go
- pg_stat_progress_create_index.go
- pg_stat_progress_vacuum.go
- pg_stat_recovery_prefetch.go
- pg_stat_replication.go
- pg_stat_replication_slots.go
- pg_stat_slru.go
- pg_stat_statements.go
- pg_stat_subscription.go
- pg_stat_subscription_stats.go
- pg_stat_user_functions.go
- pg_stat_user_indexes.go
- pg_stat_user_tables.go
- pg_stat_wal.go
- pg_stat_wal_receiver.go
- pg_statio_user_indexes.go
- pg_statio_user_tables.go
- pg_stats.go
- pg_type.go
- pgtypes.go
- transactions.go
- uptime.go
- wait_events.go