Metrics
The Cennso Database extension uses the Prometheus PostgreSQL exporterOpens in a new tab to collect and expose metrics from deployed PostgreSQL database instances.
The postgres_exporter provides different metric collectors, each responsible for gathering specific categories of data. By default, the following collectors are enabled by the exporter:
database- collects database sizesdatabase_wraparound- collects the transaction ID age of each databaseextensions- collects information about the installed extensionslocks- collects the number of locks per database and lock modepostmaster- collects the start time of the PostgreSQL serverreplication- collects replication lag and role informationreplication_slot- collects replication slot status and WAL positionsstat_bgwriter- collects background writer and checkpoint statisticsstat_database- collects database-wide statistics, such as transactions, block reads, and tuple operationsstat_user_tables- collects table statistics, such as scans, tuple operations, and vacuum runsstatio_user_tables- collects table I/O statistics
In addition to the collectors enabled by the exporter, the postmaster collector is enabled by the Cennso Database extension. The Grafana dashboard uses it to show the uptime of the PostgreSQL instances. The other collectors are enabled by default in postgres_exporter.
Note
The postgres_exporter connects to the postgres database, so the stat_user_tables and statio_user_tables collectors report only the tables of the postgres database.
The stat_statements collector requires the pg_stat_statements extension and creates metrics for every distinct statement. Use the statements by type metrics instead.
You can enable or disable any collector using the spec.metricsExporter.collectors configuration option, for example replication_slot: false. The collectors that you do not set keep their default state. The Grafana dashboard requires the following collectrs:
databasedatabase_wraparoundlockspostmasterreplicationstat_bgwriterstat_database
Disabling any of these collectors leaves some dashboard panels empty.
For a complete list of available collectors and their descriptions, see the flags documentationOpens in a new tab in the postgres_exporter repository.
For more information on how to enable and configure the metrics collector, see the Enable metrics collector deployment guide.
Statements by type
If the pg_stat_statements extension is enabled with the spec.postgresql.extensions.pgStatStatements.enabled configuration option, the postgres_exporter exposes the following metrics:
Each metric has the command label with the statement type, which is the first word of the statement in lowercase, for example select, insert, update, delete, begin, or commit. The metrics cover the statements of all databases of the PostgreSQL instance. Statements executed inside functions are not counted separately.
These metrics are not shown in the Grafana dashboard. You can add them to the dashboard using the following promqlOpens in a new tab queries:
-
Statements per second:
promql -
Rows per second:
promql -
Execution time per second. A value of
2means that, on average, two statements of this type were running at any moment:promql
For more information about the limitations of these metrics, see the PostgreSQL extensions section.
Grafana dashboard
The Cennso Database extension provides a default Grafana dashboard that visualizes the collected metrics. For more information about the available dashboard panels and their interpretation, see the Grafana dashboard document.