collector

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: BSD-3-Clause Imports: 32 Imported by: 0

Documentation

Overview

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Package collector is a pgSCV collectors

Index

Constants

View Source
const (
	// Postgres server versions numeric representations.
	PostgresV95 = 90500
	PostgresV96 = 90600
	PostgresV10 = 100000
	PostgresV11 = 110000
	PostgresV12 = 120000
	PostgresV13 = 130000
	PostgresV14 = 140000
	PostgresV15 = 150000
	PostgresV16 = 160000
	PostgresV17 = 170000
	PostgresV18 = 180000

	// Minimal required version is 9.5
	PostgresVMinNum = PostgresV95
	PostgresVMinStr = "9.5"
)

Postgres server versions

Variables

This section is empty.

Functions

func GetIsAwsAurora added in v0.15.0

func GetIsAwsAurora(db *store.DB) (bool, error)

GetIsAwsAurora returns true if connected to Amazon Aurora, and false otherwise.

func GetIsCitus added in v0.15.0

func GetIsCitus(db *store.DB) (bool, error)

GetIsCitus returns true if connected to Citus, and false otherwise.

Types

type Collector

type Collector interface {
	// Update does collecting new metrics and expose them via prometheus registry.
	Update(config Config, ch chan<- prometheus.Metric) error
}

Collector is the interface a collector has to implement.

func NewCPUCollector

func NewCPUCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewCPUCollector returns a new Collector exposing kernel/system statistics.

func NewDiskstatsCollector

func NewDiskstatsCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewDiskstatsCollector returns a new Collector exposing disk device stats. Docs from https://www.kernel.org/doc/Documentation/iostats.txt and https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats

func NewFilesystemCollector

func NewFilesystemCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewFilesystemCollector returns a new Collector exposing filesystem stats.

func NewLoadAverageCollector

func NewLoadAverageCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewLoadAverageCollector returns a new Collector exposing load average statistics.

func NewMeminfoCollector

func NewMeminfoCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewMeminfoCollector returns a new Collector exposing memory stats.

func NewNetdevCollector

func NewNetdevCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewNetdevCollector returns a new Collector exposing network interfaces stats.

func NewNetworkCollector

func NewNetworkCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewNetworkCollector returns a new Collector exposing network interfaces addresses.

func NewPatroniCommonCollector added in v0.8.2

func NewPatroniCommonCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPatroniCommonCollector returns a new Collector exposing Patroni common info. For details see https://patroni.readthedocs.io/en/latest/rest_api.html#monitoring-endpoint

func NewPgbouncerPoolsCollector

func NewPgbouncerPoolsCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPgbouncerPoolsCollector returns a new Collector exposing pgbouncer pools connections usage stats. For details see https://www.pgbouncer.org/usage.html#show-pools.

func NewPgbouncerSettingsCollector

func NewPgbouncerSettingsCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPgbouncerSettingsCollector returns a new Collector exposing pgbouncer configuration. For details see https://www.pgbouncer.org/usage.html#show-config.

func NewPgbouncerStatsCollector

func NewPgbouncerStatsCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPgbouncerStatsCollector returns a new Collector exposing pgbouncer pools usage stats (except averages). For details see https://www.pgbouncer.org/usage.html#show-stats.

func NewPgscvServicesCollector

func NewPgscvServicesCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPgscvServicesCollector creates new collector.

func NewPostgresActivityCollector

func NewPostgresActivityCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresActivityCollector returns a new Collector exposing postgres activity stats. For details see:

  1. https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW
  2. https://www.postgresql.org/docs/current/view-pg-prepared-xacts.html

func NewPostgresBgwriterCollector

func NewPostgresBgwriterCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresBgwriterCollector returns a new Collector exposing postgres bgwriter and checkpointer stats. For details see https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW

func NewPostgresConflictsCollector

func NewPostgresConflictsCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresConflictsCollector returns a new Collector exposing postgres databases recovery conflicts stats. For details see https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-CONFLICTS-VIEW

func NewPostgresCustomCollector

func NewPostgresCustomCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresCustomCollector returns a new Collector that expose user-defined postgres metrics.

func NewPostgresDatabasesCollector

func NewPostgresDatabasesCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresDatabasesCollector returns a new Collector exposing postgres databases stats. For details see https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW

func NewPostgresFunctionsCollector

func NewPostgresFunctionsCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresFunctionsCollector returns a new Collector exposing postgres SQL functions stats. For details see https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-USER-FUNCTIONS-VIEW

func NewPostgresIndexesCollector

func NewPostgresIndexesCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresIndexesCollector returns a new Collector exposing postgres indexes stats. For details see https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ALL-INDEXES-VIEW https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-INDEXES-VIEW

func NewPostgresLocksCollector

func NewPostgresLocksCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresLocksCollector creates new postgresLocksCollector.

func NewPostgresLogsCollector

func NewPostgresLogsCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresLogsCollector creates new collector for Postgres log messages.

func NewPostgresReplicationCollector

func NewPostgresReplicationCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresReplicationCollector returns a new Collector exposing postgres replication stats. For details see https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-REPLICATION-VIEW

func NewPostgresReplicationSlotsCollector

func NewPostgresReplicationSlotsCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresReplicationSlotsCollector returns a new Collector exposing postgres replication slots stats. For details see https://www.postgresql.org/docs/current/view-pg-replication-slots.html

func NewPostgresSchemasCollector

func NewPostgresSchemasCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresSchemasCollector returns a new Collector exposing postgres schema stats. Stats are based on different sources inside system catalog.

func NewPostgresSettingsCollector

func NewPostgresSettingsCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresSettingsCollector returns a new Collector exposing postgres settings stats. For details see https://www.postgresql.org/docs/current/view-pg-settings.html and https://www.postgresql.org/docs/current/view-pg-file-settings.html

func NewPostgresStatIOCollector added in v0.11.0

func NewPostgresStatIOCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresStatIOCollector returns a new Collector exposing postgres pg_stat_io stats.

func NewPostgresStatSlruCollector added in v0.12.0

func NewPostgresStatSlruCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresStatSlruCollector returns a new Collector exposing postgres pg_stat_slru stats.

func NewPostgresStatSslCollector added in v0.14.0

func NewPostgresStatSslCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresStatSslCollector returns a new Collector exposing postgres pg_stat_ssl stats. For details see https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-SSL-VIEW

func NewPostgresStatSubscriptionCollector added in v0.14.0

func NewPostgresStatSubscriptionCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresStatSubscriptionCollector returns a new Collector exposing postgres pg_stat_subscription stats. For details see https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-SUBSCRIPTION

func NewPostgresStatementsCollector

func NewPostgresStatementsCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresStatementsCollector returns a new Collector exposing postgres statements stats. For details see https://www.postgresql.org/docs/current/pgstatstatements.html

func NewPostgresStorageCollector

func NewPostgresStorageCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresStorageCollector returns a new Collector exposing various stats related to Postgres storage layer. This stats observed using different stats sources.

func NewPostgresSubscriptionRelCollector added in v0.15.1

func NewPostgresSubscriptionRelCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresSubscriptionRelCollector returns a new Collector exposing postgres pg_subscription_rel stats. For details see https://www.postgresql.org/docs/17/catalog-pg-subscription-rel.html#CATALOG-PG-SUBSCRIPTION-REL

func NewPostgresTablesCollector

func NewPostgresTablesCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresTablesCollector returns a new Collector exposing postgres tables stats. For details see https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ALL-TABLES-VIEW https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-TABLES-VIEW

func NewPostgresWalArchivingCollector

func NewPostgresWalArchivingCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresWalArchivingCollector returns a new Collector exposing postgres WAL archiving stats. For details see https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ARCHIVER-VIEW

func NewPostgresWalCollector

func NewPostgresWalCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewPostgresWalCollector returns a new Collector exposing postgres WAL stats. For details see https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-WAL-VIEW

func NewSysInfoCollector

func NewSysInfoCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewSysInfoCollector returns a new Collector exposing system info.

func NewSysconfigCollector

func NewSysconfigCollector(constLabels labels, settings model.CollectorSettings) (Collector, error)

NewSysconfigCollector returns a new Collector exposing system-wide stats.

type Config

type Config struct {
	// ServiceType defines the type of discovered service. Depending on the type there should be different settings or
	// settings-specifics metric collection usecases.
	ServiceType string
	// ConnString defines a connection string used to connecting to the service
	ConnString string
	// BaseURL defines a URL string for connecting to HTTP service
	BaseURL string
	// NoTrackMode controls collector to gather and send sensitive information, such as queries texts.
	NoTrackMode bool

	// DatabasesRE defines regexp with databases from which builtin metrics should be collected.
	DatabasesRE *regexp.Regexp
	// Settings defines collectors settings propagated from main YAML configuration.
	Settings         model.CollectorsSettings
	CollectTopTable  int
	CollectTopIndex  int
	CollectTopQuery  int
	ConstLabels      *map[string]string
	TargetLabels     *map[string]string
	ConnTimeout      int // in seconds
	ConcurrencyLimit *int
	// contains filtered or unexported fields
}

Config defines collector's global configuration.

func (*Config) FillPostgresServiceConfig added in v0.10.0

func (cfg *Config) FillPostgresServiceConfig(connTimeout int) error

FillPostgresServiceConfig defines new config for Postgres-based collectors.

func (*Config) FlushServiceConfig added in v0.15.2

func (cfg *Config) FlushServiceConfig()

FlushServiceConfig postgresql service config

type Factories

type Factories map[string]func(labels, model.CollectorSettings) (Collector, error)

Factories defines collector functions which used for collecting metrics.

func (Factories) RegisterPatroniCollectors added in v0.8.2

func (f Factories) RegisterPatroniCollectors(disabled []string)

RegisterPatroniCollectors unions all patroni-related collectors and registers them in single place.

func (Factories) RegisterPgbouncerCollectors

func (f Factories) RegisterPgbouncerCollectors(disabled []string)

RegisterPgbouncerCollectors unions all pgbouncer-related collectors and registers them in single place.

func (Factories) RegisterPostgresCollectors

func (f Factories) RegisterPostgresCollectors(disabled []string)

RegisterPostgresCollectors unions all postgres-related collectors and registers them in single place.

func (Factories) RegisterSystemCollectors

func (f Factories) RegisterSystemCollectors(disabled []string)

RegisterSystemCollectors unions all system-related collectors and registers them in single place.

type PgscvCollector

type PgscvCollector struct {
	Config     Config
	Collectors map[string]Collector
	// contains filtered or unexported fields
}

PgscvCollector implements the prometheus.Collector interface.

func NewPgscvCollector

func NewPgscvCollector(serviceID string, factories Factories, config Config) (*PgscvCollector, error)

NewPgscvCollector accepts Factories and creates per-service instance of Collector.

func (PgscvCollector) Collect

func (n PgscvCollector) Collect(out chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (PgscvCollector) Describe

func (n PgscvCollector) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

func (PgscvCollector) FlushServiceConfig added in v0.15.2

func (n PgscvCollector) FlushServiceConfig()

FlushServiceConfig postgresql service config

type PostgresVersion added in v0.15.0

type PostgresVersion struct {
	Full    string `json:"full"`    // e.g. "PostgreSQL 16.9 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit"
	Short   string `json:"short"`   // e.g. "16.9.0"
	Numeric int    `json:"numeric"` // e.g. 160009

	// For collectors use only, to avoid calling functions that don't work
	IsAwsAurora bool // Amazon Aurora
	IsCitus     bool // Citus extension (e.g. with Azure CosmosDB for PostgreSQL)
	IsEPAS      bool // EnterpriseDB Advanced Server
	IsYandex    bool // Yandex.Cloud Managed Service for PostgreSQL
	IsPGPRO     bool // Postgres Professional
}

PostgresVersion - Identifying information about the PostgreSQL server version and build details

Jump to

Keyboard shortcuts

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