@cryptotaxi247 / netdata-1 / commits / 24874d5fa

Regenerate integrations docs (#21663)

Co-authored-by: ilyam8 <22274335+ilyam8@users.noreply.github.com>

Netdata bot committed Jan 28, 2026 at 18:21 UTC 24874d5fac035bed5b92dee9d89053c9406beeb9
1 file changed +116 -13
src/go/plugin/go.d/collector/postgres/integrations/postgresql.md
+116 -13
@@ -234,14 +234,19 @@ This collector exposes real-time functions for interactive troubleshooting in th
234
235 ### Top Queries
236
237 -Retrieves aggregated SQL query performance metrics from PostgreSQL [pg_stat_statements](https://www.postgresql.org/docs/current/pgstatstatements.html) extension.
237 +Retrieves aggregated SQL query performance metrics from PostgreSQL using either [pg_stat_monitor](https://docs.percona.com/pg-stat-monitor/) (preferred) or [pg_stat_statements](https://www.postgresql.org/docs/current/pgstatstatements.html).
238
239 -This function queries `pg_stat_statements` which tracks execution statistics for all SQL statements. Statistics include execution counts, timing metrics, I/O operations, and resource consumption. Columns are dynamically detected based on your PostgreSQL version.
239 +The collector automatically detects which extension is available:
240 +- **pg_stat_monitor** (Percona): Enhanced statistics with additional columns like application name, client IP, CPU time, error info, and query classification
241 +- **pg_stat_statements** (standard): Core execution statistics available in all PostgreSQL installations
242 +
243 +Statistics include execution counts, timing metrics, I/O operations, and resource consumption. Columns are dynamically detected based on your PostgreSQL version and available extension.
244
245 Use cases:
246 - Identify slow queries consuming the most total execution time
247 - Find queries with high shared block reads for I/O optimization
248 - Analyze temp block usage to detect queries needing memory tuning
249 +- With pg_stat_monitor: Track queries by application, identify error patterns
250
251 Query text is truncated at 4096 characters for display purposes.
252
@@ -250,15 +255,17 @@ Query text is truncated at 4096 characters for display purposes.
255 |:-------|:------------|
256 | Name | `Postgres:top-queries` |
257 | Require Cloud | yes |
253 -| Performance | Queries `pg_stat_statements` which maintains statistics in shared memory:<br/>• On busy servers with many unique queries, the extension may consume significant memory<br/>• Default limit of 500 rows balances usefulness with performance |
258 +| Performance | Queries `pg_stat_statements` or `pg_stat_monitor` which maintain statistics in shared memory:<br/>• On busy servers with many unique queries, the extension may consume significant memory<br/>• Default limit of 500 rows balances usefulness with performance<br/>• pg_stat_monitor uses time-based buckets which may have different memory characteristics |
259 | Security | Query text may contain unmasked literal values including potentially sensitive data:<br/>• Personal information in WHERE clauses or INSERT values<br/>• Business data and internal identifiers<br/>• Access should be restricted to authorized personnel only |
255 -| Availability | Available when:<br/>• The `pg_stat_statements` extension is installed in the database<br/>• The collector has successfully connected to PostgreSQL<br/>• Returns HTTP 503 if extension is not installed (with instructions to install)<br/>• Returns HTTP 500 if the query fails<br/>• Returns HTTP 504 if the query times out |
260 +| Availability | Available when:<br/>• Either `pg_stat_statements` or `pg_stat_monitor` extension is installed<br/>• The collector has successfully connected to PostgreSQL<br/>• Returns HTTP 503 if no query statistics extension is installed<br/>• Returns HTTP 500 if the query fails<br/>• Returns HTTP 504 if the query times out |
261
262 #### Prerequisites
263
259 -##### Enable pg_stat_statements
264 +##### Enable pg_stat_statements or pg_stat_monitor
265 +
266 +Either `pg_stat_statements` (standard) or `pg_stat_monitor` (Percona) must be installed. The collector auto-detects which is available, preferring pg_stat_monitor when both are present.
267
261 -The `pg_stat_statements` extension must be installed and configured.
268 +**Option 1: pg_stat_statements (standard PostgreSQL)**
269
270 1. Add to `postgresql.conf`:
271
@@ -272,18 +279,29 @@ The `pg_stat_statements` extension must be installed and configured.
279 CREATE EXTENSION pg_stat_statements;
280 ```
281
275 -3. Verify the extension is working:
282 +**Option 2: pg_stat_monitor (Percona - recommended)**
283 +
284 +Provides additional columns: application name, client IP, CPU time, error tracking, and query classification.
285 +
286 +1. Install pg_stat_monitor (available in Percona distribution or as separate package)
287 +
288 +2. Add to `postgresql.conf`:
289 +
290 + ```ini
291 + shared_preload_libraries = 'pg_stat_monitor'
292 + ```
293 +
294 +3. Restart PostgreSQL, then create the extension:
295
296 ```sql
278 - SELECT COUNT(*) FROM pg_stat_statements;
297 + CREATE EXTENSION pg_stat_monitor;
298 ```
299
300 :::info
301
283 -- `pg_stat_statements` requires a server restart to load the shared library
284 -- Statistics can be reset with `SELECT pg_stat_statements_reset()`
285 -- The `pg_stat_statements.max` parameter controls maximum tracked statements (default 5000)
286 -- Enable `track_io_timing` for block read/write timing metrics (may add slight overhead)
302 +- Both extensions require a server restart to load the shared library
303 +- Statistics can be reset with `SELECT pg_stat_statements_reset()` or `SELECT pg_stat_monitor_reset()`
304 +- Enable `track_io_timing` for block read/write timing metrics
305
306 :::
307
@@ -297,7 +315,7 @@ The `pg_stat_statements` extension must be installed and configured.
315
316 #### Returns
317
300 -Aggregated query statistics from `pg_stat_statements`. Each row represents a unique query pattern with cumulative metrics across all executions.
318 +Aggregated query statistics from `pg_stat_statements` or `pg_stat_monitor`. Each row represents a unique query pattern with cumulative metrics across all executions.
319
320 | Column | Type | Unit | Visibility | Description |
321 |:-------|:-----|:-----|:-----------|:------------|
@@ -343,6 +361,91 @@ Aggregated query statistics from `pg_stat_statements`. Each row represents a uni
361 | JIT Emission Time | duration | milliseconds | hidden | Time spent emitting JIT code. Available in PostgreSQL 15+. |
362 | Temp Block Read Time | duration | milliseconds | hidden | Time spent reading temp blocks. Available in PostgreSQL 15+. Requires `track_io_timing`. |
363 | Temp Block Write Time | duration | milliseconds | hidden | Time spent writing temp blocks. Available in PostgreSQL 15+. Requires `track_io_timing`. |
364 +| Application Name | string | | | Name of the application that executed the query. Available with pg_stat_monitor only. |
365 +| Client IP | string | | hidden | IP address of the client that executed the query. Available with pg_stat_monitor only. |
366 +| Command Type | string | | | Type of SQL command (SELECT, INSERT, UPDATE, DELETE, etc.). Available with pg_stat_monitor only. |
367 +| Comments | string | | hidden | SQL comments extracted from the query. Available with pg_stat_monitor only. |
368 +| Relations | string | | hidden | Tables/relations involved in the query. Available with pg_stat_monitor only. |
369 +| CPU User Time | duration | milliseconds | hidden | CPU time spent in user mode. Available with pg_stat_monitor only. |
370 +| CPU System Time | duration | milliseconds | hidden | CPU time spent in system/kernel mode. Available with pg_stat_monitor only. |
371 +| Error Level | integer | | hidden | PostgreSQL error level if query produced an error. Available with pg_stat_monitor only. |
372 +| SQL Code | string | | hidden | PostgreSQL SQLSTATE error code if query produced an error. Available with pg_stat_monitor only. |
373 +| Error Message | string | | hidden | Error message if query produced an error. Available with pg_stat_monitor only. |
374 +| Top Level | string | | hidden | Whether this is a top-level statement (true) or nested (false). Available with pg_stat_monitor only. |
375 +| Bucket Start Time | string | | hidden | Start time of the statistics bucket. Available with pg_stat_monitor only. |
376 +
377 +### Running Queries
378 +
379 +Retrieves currently executing queries from PostgreSQL [pg_stat_activity](https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW) system view.
380 +
381 +This function queries `pg_stat_activity` which shows real-time information about each server process including the SQL query being executed, wait events, and session state. Unlike Top Queries which shows aggregated historical statistics, Running Queries shows live snapshots of active queries.
382 +
383 +Use cases:
384 +- Identify long-running queries that may be blocking other operations
385 +- Debug stuck transactions or hanging connections
386 +- Monitor active workload during performance issues
387 +- Investigate wait events and lock contention in real-time
388 +
389 +Query text is truncated at 4096 characters for display purposes.
390 +
391 +
392 +| Aspect | Description |
393 +|:-------|:------------|
394 +| Name | `Postgres:running-queries` |
395 +| Require Cloud | yes |
396 +| Performance | Queries `pg_stat_activity` which is a live system view:<br/>• Very lightweight query, no impact on database performance<br/>• Returns only active queries by default (state = 'active')<br/>• Limited to 500 rows |
397 +| Security | Query text contains actual SQL being executed, which may include:<br/>• Personal information in WHERE clauses or INSERT values<br/>• Business data and internal identifiers<br/>• Access should be restricted to authorized personnel only |
398 +| Availability | Available when:<br/>• The collector has successfully connected to PostgreSQL<br/>• Returns HTTP 503 if collector is still initializing<br/>• Returns HTTP 500 if the query fails<br/>• Returns HTTP 504 if the query times out |
399 +
400 +#### Prerequisites
401 +
402 +##### Database user permissions
403 +
404 +The monitoring user needs `pg_monitor` role to view all sessions:
405 +
406 +```sql
407 +GRANT pg_monitor TO netdata;
408 +```
409 +
410 +Without this role, the user can only see their own sessions.
411 +
412 +
413 +
414 +#### Parameters
415 +
416 +| Parameter | Type | Description | Required | Default | Options |
417 +|:---------|:-----|:------------|:--------:|:--------|:--------|
418 +| Sort By | select | Select the sort column. Defaults to query duration (longest running first). | yes | durationMs | |
419 +
420 +#### Returns
421 +
422 +Live query data from `pg_stat_activity`. Each row represents a currently active backend process.
423 +
424 +| Column | Type | Unit | Visibility | Description |
425 +|:-------|:-----|:-----|:-----------|:------------|
426 +| Duration | duration | milliseconds | | Query duration in milliseconds (since query_start). High values indicate long-running queries. |
427 +| Query | string | | | Query text of the currently executing or most recent query. May be truncated at track_activity_query_size. |
428 +| Database | string | | | Name of the database this backend is connected to. |
429 +| User | string | | | Name of the user logged into this backend. |
430 +| Application Name | string | | | Name of the application connected to this backend. |
431 +| Client Address | string | | | IP address of the client (NULL for Unix socket or internal process). |
432 +| Wait Event | string | | | Specific wait event name if backend is currently waiting. |
433 +| PID | integer | | | Process ID of this backend. Use with pg_terminate_backend() to kill a query. |
434 +| Wait Event Type | string | | hidden | Type of event the backend is waiting for (Activity, BufferPin, Client, Extension, IO, IPC, Lock, LWLock, Timeout). |
435 +| State | string | | hidden | Current state: active, idle, idle in transaction, idle in transaction (aborted), fastpath function call, disabled. |
436 +| Backend Type | string | | hidden | Type of backend: client backend, autovacuum worker, parallel worker, walsender, walreceiver, etc. Available in PostgreSQL 10+. |
437 +| Query Start | timestamp | | hidden | Time when the currently active query was started. |
438 +| Transaction Start | timestamp | | hidden | Time when current transaction started (NULL if no transaction). |
439 +| Backend Start | timestamp | | hidden | Time when this process/connection started. |
440 +| State Change | timestamp | | hidden | Time when state was last changed. |
441 +| Query ID | string | | hidden | Query identifier (requires compute_query_id or extension). Available in PostgreSQL 14+. |
442 +| Leader PID | integer | | hidden | Process ID of parallel group leader (NULL if this is leader or not parallel). Available in PostgreSQL 13+. |
443 +| Database ID | integer | | hidden | OID of the database this backend is connected to. |
444 +| User ID | integer | | hidden | OID of the user logged into this backend. |
445 +| Client Hostname | string | | hidden | Hostname of the client via reverse DNS (only if log_hostname enabled). |
446 +| Client Port | integer | | hidden | TCP port of client (-1 for Unix socket, NULL for internal process). |
447 +| Backend Xid | string | | hidden | Top-level transaction identifier of this backend. |
448 +| Backend Xmin | string | | hidden | Backend's xmin horizon. |
449
450
451