PostgreSQL Metrics Source
The Vector postgresql_metrics
source
postgreSQL PostgreSQL is a powerful, open source
object-relational database system with over 30 years of active development that
has earned it a strong reputation for reliability, feature robustness, and
performance.
Requirements
Configuration
- Common
- Advanced
- vector.toml
- vector.yaml
- vector.json
[sources.my_source_id]type = "postgresql_metrics" # requiredendpoints = ["postgresql://postgres:vector@localhost:5432/postgres"] # requiredscrape_interval_secs = 15 # optional, default, seconds
- commonrequired[string]
endpoints
PostgreSQL server endpoint in libpq-style connection strings.
- View examples
- optional[string]
exclude_databases
A list of databases to match (by using POSIX Regular Expressions) against the
datname
column for which you don't want to collect metrics from. Specifying""
will include metrics wheredatname
isNULL
. This can be used in conjunction withinclude_databases
.- View examples
- optional[string]
include_databases
A list of databases to match (by using POSIX Regular Expressions) against the
datname
column for which you want to collect metrics from. If not set, metrics will be collected from all databases. Specifying""
will include metrics wheredatname
isNULL
. This can be used in conjunction withexclude_databases
.- View examples
- optionalstring
namespace
The namespace of metrics. Disabled if empty.
- Syntax:
literal
- Default:
"postgresql"
- Syntax:
- commonoptionaluint
scrape_interval_secs
The interval between scrapes.
- Default:
15
(seconds)
- Default:
- optionaltable
tls
TLS options to connect to the PostgreSQL Server.
- commonrequiredstring
ca_file
Path to CA certificate file.
- Syntax:
literal
- View examples
- Syntax:
Output
This component outputs the following metric events:
- gauge
up
Whether the PostgreSQL server is up or not. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.
- gauge
pg_stat_database_datid
OID of this database, or 0 for objects belonging to a shared relation. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- gauge
pg_stat_database_numbackends
Number of backends currently connected to this database, or 0 for shared objects. This is the only column in this view that returns a value reflecting current state; all other columns return the accumulated values since the last reset. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_xact_commit_total
Number of transactions in this database that have been committed. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_xact_rollback_total
Number of transactions in this database that have been rolled back. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_blks_read_total
Number of disk blocks read in this database. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_blks_hit_total
Number of times disk blocks were found already in the buffer cache, so that a read was not necessary (this only includes hits in the PostgreSQL buffer cache, not the operating system's file system cache). This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_tup_returned_total
Number of rows returned by queries in this database. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_tup_fetched_total
Number of rows fetched by queries in this database. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_tup_inserted_total
Number of rows inserted by queries in this database. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_tup_updated_total
Number of rows updated by queries in this database. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_tup_deleted_total
Number of rows deleted by queries in this database. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_conflicts_total
Number of queries canceled due to conflicts with recovery in this database. (Conflicts occur only on standby servers; see
pg_stat_database_conflicts
for details.) This metric includes the following tags:endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_temp_files_total
Number of temporary files created by queries in this database. All temporary files are counted, regardless of why the temporary file was created (e.g., sorting or hashing), and regardless of the
log_temp_files
setting. This metric includes the following tags:endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_temp_bytes_total
Total amount of data written to temporary files by queries in this database. All temporary files are counted, regardless of why the temporary file was created, and regardless of the
log_temp_files
setting. This metric includes the following tags:endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_deadlocks_total
Number of deadlocks detected in this database. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_checksum_failures_total
Number of data page checksum failures detected in this database (or on a shared object), or 0 if data checksums are not enabled. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- gauge
pg_stat_database_checksum_last_failure
Time at which the last data page checksum failure was detected in this database (or on a shared object), or 0 if data checksums are not enabled. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_blk_read_time_seconds_total
Time spent reading data file blocks by backends in this database, in milliseconds (if
track_io_timing
is enabled, otherwise zero). This metric includes the following tags:endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_blk_write_time_seconds_total
Time spent writing data file blocks by backends in this database, in milliseconds (if
track_io_timing
is enabled, otherwise zero). This metric includes the following tags:endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- gauge
pg_stat_database_stats_reset
Time at which these statistics were last reset. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_conflicts_confl_tablespace_total
Number of queries in this database that have been canceled due to dropped tablespaces. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_conflicts_confl_lock_total
Number of queries in this database that have been canceled due to lock timeouts. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_conflicts_confl_snapshot_total
Number of queries in this database that have been canceled due to old snapshots. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_conflicts_confl_bufferpin_total
Number of queries in this database that have been canceled due to pinned buffers. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_database_conflicts_confl_deadlock_total
Number of queries in this database that have been canceled due to deadlocks. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.type
- Database name.
- counter
pg_stat_bgwriter_checkpoints_timed_total
Number of scheduled checkpoints that have been performed. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.
- counter
pg_stat_bgwriter_checkpoints_req_total
Number of requested checkpoints that have been performed. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.
- counter
pg_stat_bgwriter_checkpoint_write_time_seconds_total
Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.
- counter
pg_stat_bgwriter_checkpoint_sync_time_seconds_total
Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.
- counter
pg_stat_bgwriter_buffers_checkpoint_total
Number of buffers written during checkpoints. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.
- counter
pg_stat_bgwriter_buffers_clean_total
Number of buffers written by the background writer. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.
- counter
pg_stat_bgwriter_maxwritten_clean_total
Number of times the background writer stopped a cleaning scan because it had written too many buffers. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.
- counter
pg_stat_bgwriter_buffers_backend_total
Number of buffers written directly by a backend. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.
- counter
pg_stat_bgwriter_buffers_backend_fsync_total
Number of times a backend had to execute its own fsync call (normally the background writer handles those even when the backend does its own write). This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.
- counter
pg_stat_bgwriter_buffers_alloc_total
Number of buffers allocated. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.
- gauge
pg_stat_bgwriter_stats_reset
Time at which these statistics were last reset. This metric includes the following tags:
endpoint
- PostgreSQL endpoint.host
- The hostname of the PostgreSQL server.
Telemetry
This component provides the following metrics that can be retrieved through
the internal_metrics
source. See the
metrics section in the
monitoring page for more info.
- counter
collect_completed_total
The total number of metrics collections completed for this component. This metric includes the following tags:
instance
- The Vector instance identified by host and port.job
- The name of the job producing Vector metrics.
- histogram
collect_duration_nanoseconds
The duration spent collecting of metrics for this component. This metric includes the following tags:
instance
- The Vector instance identified by host and port.job
- The name of the job producing Vector metrics.
- counter
events_out_total
The total number of events emitted by this component. This metric includes the following tags:
component_kind
- The Vector component kind.component_name
- The Vector component ID.component_type
- The Vector component type.instance
- The Vector instance identified by host and port.job
- The name of the job producing Vector metrics.
- counter
request_errors_total
The total number of requests errors for this component. This metric includes the following tags:
instance
- The Vector instance identified by host and port.job
- The name of the job producing Vector metrics.
How It Works
Context
By default, the postgresql_metrics
source will augment events with helpful
context keys as shown in the "Output" section.
Required Privileges
PostgreSQL Metrics component collects metrics by making queries to the configured PostgreSQL server. Ensure the configured user is allowed to make the select queries against the following views:
State
This component is stateless, meaning its behavior is consistent across each input.