Skip to main content

PostgreSQL

Description

Monitors performance and operational metrics for a PostgreSQL database.

database linux windows

Target

Typical platform: PostgreSQL

Operating systems: Microsoft Windows, Linux

Prerequisites

Leverages: PostgreSQL Database version 17 or higher

Technology and protocols: SQL/JDBC

Examples

CLI

metricshub HOSTNAME -t win -c +PostgreSQL --jdbc -u USER --jdbc-url URL

metricshub.yaml

resourceGroups:
<RESOURCE_GROUP>:
resources:
<HOSTNAME-ID>:
attributes:
host.name: <HOSTNAME> # Change with actual host name
host.type: win
connectors: [ +PostgreSQL ] # Optional, to load only this connector
protocols:
jdbc:
port: <PORT>
database: <DB_NAME>
type: <type>
url: <URL>
username: <USERNAME> # Change with actual credentials
password: <PASSWORD> # Encrypted using metricshub-encrypt

Connector Activation Criteria

The PostgreSQL connector will be automatically activated, and its status will be reported as OK if all the below criteria are met:

  • The SQL query below succeeds:
    • Query: SELECT (LOWER(version()) LIKE '%postgresql%')::int AS is_postgresql;
    • Result contains: 1 (regex)

Metrics

TypeCollected MetricsSpecific Attributes
postgresqldb.server.cache.operations{db.io.direction="write", db.cache.state="miss", db.postgresql.cache.type="wal_buffer"}
db.server.cache.size{db.postgresql.cache.type="shared_buffer"}
db.server.connections
db.server.connections.limit
db.server.current_connections{db.connection.state="active"}
db.server.current_connections{db.connection.state="idle"}
db.server.postgresql.bgwriter.buffers{db.buffer.state="allocated"}
db.server.postgresql.bgwriter.buffers{db.buffer.state="clean"}
db.server.postgresql.bgwriter.clean_stops
db.server.postgresql.checkpointer.buffers
db.server.postgresql.checkpointer.operations{db.operation.trigger_type="requested"}
db.server.postgresql.checkpointer.operations{db.operation.trigger_type="scheduled"}
db.server.postgresql.checkpointer.sync_time
db.server.postgresql.checkpointer.write_time
db.server.postgresql.wal.io{db.io.direction="write"}
db.server.uptime
db.namespace
db.server.port
db.system
db.version
id
postgresql_databasedb.server.cache.io{db.io.direction="read", db.cache.state="hit", db.postgresql.cache.type="shared_buffer"}
db.server.cache.io{db.io.direction="read", db.cache.state="miss", db.postgresql.cache.type="shared_buffer"}
db.server.commits
db.server.current_connections
db.server.errors{error.type="deadlocks"}
db.server.errors{error.type="session_abandoned"}
db.server.errors{error.type="session_fatal_error"}
db.server.errors{error.type="session_killed"}
db.server.operation_time{db.operation.type="sql"}
db.server.postgresql.index.row_operations{db.row_operation.type="fetch"}
db.server.postgresql.session_time
db.server.postgresql.transaction_time{db.transaction.state="idle"}
db.server.rollbacks
db.server.row_operations{db.row_operation.type="delete"}
db.server.row_operations{db.row_operation.type="insert"}
db.server.row_operations{db.row_operation.type="read"}
db.server.row_operations{db.row_operation.type="update"}
db.server.sessions
db.server.size
db.namespace
db.server.port
db.system
postgresql_lockdb.server.locksdb.namespace
db.server.lock.relation
db.server.lock.type
db.server.port
db.system
replicationdb.server.postgresql.replication.flush_lag.time
db.server.postgresql.replication.lag
db.server.postgresql.replication.replay_lag.time
db.server.postgresql.replication.status{state="backup|catchup|startup|stopping|streaming"}
db.server.postgresql.replication.write_lag.time
db.replication.host.id
db.replication.host.name
db.server.application_name
db.server.port
db.system
db.user.name