PostgreSQL
Description
Monitors performance and operational metrics for a PostgreSQL database.
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)
- Query:
Metrics
| Type | Collected Metrics | Specific Attributes |
|---|---|---|
| postgresql | db.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.connectionsdb.server.connections.limitdb.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_stopsdb.server.postgresql.checkpointer.buffersdb.server.postgresql.checkpointer.operations{db.operation.trigger_type="requested"}db.server.postgresql.checkpointer.operations{db.operation.trigger_type="scheduled"}db.server.postgresql.checkpointer.sync_timedb.server.postgresql.checkpointer.write_timedb.server.postgresql.wal.io{db.io.direction="write"}db.server.uptime | db.namespacedb.server.portdb.systemdb.versionid |
| postgresql_database | db.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.commitsdb.server.current_connectionsdb.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_timedb.server.postgresql.transaction_time{db.transaction.state="idle"}db.server.rollbacksdb.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.sessionsdb.server.size | db.namespacedb.server.portdb.system |
| postgresql_lock | db.server.locks | db.namespacedb.server.lock.relationdb.server.lock.typedb.server.portdb.system |
| replication | db.server.postgresql.replication.flush_lag.timedb.server.postgresql.replication.lagdb.server.postgresql.replication.replay_lag.timedb.server.postgresql.replication.status{state="backup|catchup|startup|stopping|streaming"}db.server.postgresql.replication.write_lag.time | db.replication.host.iddb.replication.host.namedb.server.application_namedb.server.portdb.systemdb.user.name |