1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
|
plugin_name: go.d.plugin
modules:
- meta:
id: collector-go.d.plugin-postgres
plugin_name: go.d.plugin
module_name: postgres
monitored_instance:
name: PostgreSQL
link: https://www.postgresql.org/
categories:
- data-collection.database-servers
icon_filename: postgres.svg
related_resources:
integrations:
list:
- plugin_name: apps.plugin
module_name: apps
- plugin_name: cgroups.plugin
module_name: cgroups
alternative_monitored_instances: []
info_provided_to_referring_integrations:
description: ""
keywords:
- db
- database
- postgres
- postgresql
- sql
most_popular: true
overview:
multi_instance: true
data_collection:
metrics_description: |
This collector monitors the activity and performance of Postgres servers, collects replication statistics, metrics for each database, table and index, and more.
method_description: |
It establishes a connection to the Postgres instance via a TCP or UNIX socket.
To collect metrics for database tables and indexes, it establishes an additional connection for each discovered database.
default_behavior:
auto_detection:
description: |
By default, it detects instances running on localhost by trying to connect as root and netdata using known PostgreSQL TCP and UNIX sockets:
- 127.0.0.1:5432
- /var/run/postgresql/
limits:
description: |
Table and index metrics are not collected for databases with more than 50 tables or 250 indexes.
These limits can be changed in the configuration file.
performance_impact:
description: ""
additional_permissions:
description: ""
supported_platforms:
include: []
exclude: []
setup:
prerequisites:
list:
- title: Create netdata user
description: |
Create a user with granted `pg_monitor`
or `pg_read_all_stat` [built-in role](https://www.postgresql.org/docs/current/predefined-roles.html).
To create the `netdata` user with these permissions, execute the following in the psql session, as a user with CREATEROLE privileges:
```postgresql
CREATE USER netdata;
GRANT pg_monitor TO netdata;
```
After creating the new user, restart the Netdata agent with `sudo systemctl restart netdata`, or
the [appropriate method](/docs/netdata-agent/start-stop-restart.md) for your
system.
configuration:
file:
name: go.d/postgres.conf
options:
description: |
The following options can be defined globally: update_every, autodetection_retry.
folding:
title: Config options
enabled: true
list:
- name: update_every
description: Data collection frequency.
default_value: 5
required: false
- name: autodetection_retry
description: Recheck interval in seconds. Zero means no recheck will be scheduled.
default_value: 0
required: false
- name: dsn
description: Postgres server DSN (Data Source Name). See [DSN syntax](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING).
default_value: postgres://postgres:postgres@127.0.0.1:5432/postgres
required: true
- name: timeout
description: Query timeout in seconds.
default_value: 2
required: false
- name: collect_databases_matching
description: Databases selector. Determines which database metrics will be collected. Syntax is [simple patterns](https://github.com/netdata/netdata/tree/master/src/go/plugin/go.d/pkg/matcher#simple-patterns-matcher).
default_value: ""
required: false
- name: max_db_tables
description: Maximum number of tables in the database. Table metrics will not be collected for databases that have more tables than max_db_tables. 0 means no limit.
default_value: 50
required: false
- name: max_db_indexes
description: Maximum number of indexes in the database. Index metrics will not be collected for databases that have more indexes than max_db_indexes. 0 means no limit.
default_value: 250
required: false
examples:
folding:
title: Config
enabled: true
list:
- name: TCP socket
description: An example configuration.
folding:
enabled: false
config: |
jobs:
- name: local
dsn: 'postgresql://netdata@127.0.0.1:5432/postgres'
- name: Unix socket
description: An example configuration.
config: |
jobs:
- name: local
dsn: 'host=/var/run/postgresql dbname=postgres user=netdata'
- name: Multi-instance
description: |
> **Note**: When you define multiple jobs, their names must be unique.
Local and remote instances.
config: |
jobs:
- name: local
dsn: 'postgresql://netdata@127.0.0.1:5432/postgres'
- name: remote
dsn: 'postgresql://netdata@203.0.113.0:5432/postgres'
troubleshooting:
problems:
list: []
alerts:
- name: postgres_total_connection_utilization
metric: postgres.connections_utilization
info: average total connection utilization over the last minute
link: https://github.com/netdata/netdata/blob/master/src/health/health.d/postgres.conf
- name: postgres_acquired_locks_utilization
metric: postgres.locks_utilization
info: average acquired locks utilization over the last minute
link: https://github.com/netdata/netdata/blob/master/src/health/health.d/postgres.conf
- name: postgres_txid_exhaustion_perc
metric: postgres.txid_exhaustion_perc
info: percent towards TXID wraparound
link: https://github.com/netdata/netdata/blob/master/src/health/health.d/postgres.conf
- name: postgres_db_cache_io_ratio
metric: postgres.db_cache_io_ratio
info: average cache hit ratio in db ${label:database} over the last minute
link: https://github.com/netdata/netdata/blob/master/src/health/health.d/postgres.conf
- name: postgres_db_transactions_rollback_ratio
metric: postgres.db_cache_io_ratio
info: average aborted transactions percentage in db ${label:database} over the last five minutes
link: https://github.com/netdata/netdata/blob/master/src/health/health.d/postgres.conf
- name: postgres_db_deadlocks_rate
metric: postgres.db_deadlocks_rate
info: number of deadlocks detected in db ${label:database} in the last minute
link: https://github.com/netdata/netdata/blob/master/src/health/health.d/postgres.conf
- name: postgres_table_cache_io_ratio
metric: postgres.table_cache_io_ratio
info: average cache hit ratio in db ${label:database} table ${label:table} over the last minute
link: https://github.com/netdata/netdata/blob/master/src/health/health.d/postgres.conf
- name: postgres_table_index_cache_io_ratio
metric: postgres.table_index_cache_io_ratio
info: average index cache hit ratio in db ${label:database} table ${label:table} over the last minute
link: https://github.com/netdata/netdata/blob/master/src/health/health.d/postgres.conf
- name: postgres_table_toast_cache_io_ratio
metric: postgres.table_toast_cache_io_ratio
info: average TOAST hit ratio in db ${label:database} table ${label:table} over the last minute
link: https://github.com/netdata/netdata/blob/master/src/health/health.d/postgres.conf
- name: postgres_table_toast_index_cache_io_ratio
metric: postgres.table_toast_index_cache_io_ratio
info: average index TOAST hit ratio in db ${label:database} table ${label:table} over the last minute
link: https://github.com/netdata/netdata/blob/master/src/health/health.d/postgres.conf
- name: postgres_table_bloat_size_perc
metric: postgres.table_bloat_size_perc
info: bloat size percentage in db ${label:database} table ${label:table}
link: https://github.com/netdata/netdata/blob/master/src/health/health.d/postgres.conf
- name: postgres_table_last_autovacuum_time
metric: postgres.table_autovacuum_since_time
info: time elapsed since db ${label:database} table ${label:table} was vacuumed by the autovacuum daemon
link: https://github.com/netdata/netdata/blob/master/src/health/health.d/postgres.conf
- name: postgres_table_last_autoanalyze_time
metric: postgres.table_autoanalyze_since_time
info: time elapsed since db ${label:database} table ${label:table} was analyzed by the autovacuum daemon
link: https://github.com/netdata/netdata/blob/master/src/health/health.d/postgres.conf
- name: postgres_index_bloat_size_perc
metric: postgres.index_bloat_size_perc
info: bloat size percentage in db ${label:database} table ${label:table} index ${label:index}
link: https://github.com/netdata/netdata/blob/master/src/health/health.d/postgres.conf
metrics:
folding:
title: Metrics
enabled: false
description: ""
availability: []
scopes:
- name: global
description: These metrics refer to the entire monitored application.
labels: []
metrics:
- name: postgres.connections_utilization
description: Connections utilization
unit: percentage
chart_type: line
dimensions:
- name: used
- name: postgres.connections_usage
description: Connections usage
unit: connections
chart_type: stacked
dimensions:
- name: available
- name: used
- name: postgres.connections_state_count
description: Connections in each state
unit: connections
chart_type: stacked
dimensions:
- name: active
- name: idle
- name: idle_in_transaction
- name: idle_in_transaction_aborted
- name: disabled
- name: postgres.transactions_duration
description: Observed transactions time
unit: transactions/s
chart_type: stacked
dimensions:
- name: a dimension per bucket
- name: postgres.queries_duration
description: Observed active queries time
unit: queries/s
chart_type: stacked
dimensions:
- name: a dimension per bucket
- name: postgres.locks_utilization
description: Acquired locks utilization
unit: percentage
chart_type: line
dimensions:
- name: used
- name: postgres.checkpoints_rate
description: Checkpoints
unit: checkpoints/s
chart_type: stacked
dimensions:
- name: scheduled
- name: requested
- name: postgres.checkpoints_time
description: Checkpoint time
unit: milliseconds
chart_type: stacked
dimensions:
- name: write
- name: sync
- name: postgres.bgwriter_halts_rate
description: Background writer scan halts
unit: events/s
chart_type: line
dimensions:
- name: maxwritten
- name: postgres.buffers_io_rate
description: Buffers written rate
unit: B/s
chart_type: area
dimensions:
- name: checkpoint
- name: backend
- name: bgwriter
- name: postgres.buffers_backend_fsync_rate
description: Backend fsync calls
unit: calls/s
chart_type: line
dimensions:
- name: fsync
- name: postgres.buffers_allocated_rate
description: Buffers allocated
unit: B/s
chart_type: line
dimensions:
- name: allocated
- name: postgres.wal_io_rate
description: Write-Ahead Log writes
unit: B/s
chart_type: line
dimensions:
- name: write
- name: postgres.wal_files_count
description: Write-Ahead Log files
unit: files
chart_type: stacked
dimensions:
- name: written
- name: recycled
- name: postgres.wal_archiving_files_count
description: Write-Ahead Log archived files
unit: files/s
chart_type: stacked
dimensions:
- name: ready
- name: done
- name: postgres.autovacuum_workers_count
description: Autovacuum workers
unit: workers
chart_type: line
dimensions:
- name: analyze
- name: vacuum_analyze
- name: vacuum
- name: vacuum_freeze
- name: brin_summarize
- name: postgres.txid_exhaustion_towards_autovacuum_perc
description: Percent towards emergency autovacuum
unit: percentage
chart_type: line
dimensions:
- name: emergency_autovacuum
- name: postgres.txid_exhaustion_perc
description: Percent towards transaction ID wraparound
unit: percentage
chart_type: line
dimensions:
- name: txid_exhaustion
- name: postgres.txid_exhaustion_oldest_txid_num
description: Oldest transaction XID
chart_type: line
unit: xid
dimensions:
- name: xid
- name: postgres.catalog_relations_count
description: Relation count
unit: relations
chart_type: stacked
dimensions:
- name: ordinary_table
- name: index
- name: sequence
- name: toast_table
- name: view
- name: materialized_view
- name: composite_type
- name: foreign_table
- name: partitioned_table
- name: partitioned_index
- name: postgres.catalog_relations_size
description: Relation size
unit: B
chart_type: stacked
dimensions:
- name: ordinary_table
- name: index
- name: sequence
- name: toast_table
- name: view
- name: materialized_view
- name: composite_type
- name: foreign_table
- name: partitioned_table
- name: partitioned_index
- name: postgres.uptime
description: Uptime
unit: seconds
chart_type: line
dimensions:
- name: uptime
- name: postgres.databases_count
description: Number of databases
unit: databases
chart_type: line
dimensions:
- name: databases
- name: repl application
description: These metrics refer to the replication application.
labels:
- name: application
description: application name
metrics:
- name: postgres.replication_app_wal_lag_size
description: Standby application WAL lag size
unit: B
chart_type: line
dimensions:
- name: sent_lag
- name: write_lag
- name: flush_lag
- name: replay_lag
- name: postgres.replication_app_wal_lag_time
description: Standby application WAL lag time
unit: seconds
chart_type: line
dimensions:
- name: write_lag
- name: flush_lag
- name: replay_lag
- name: repl slot
description: These metrics refer to the replication slot.
labels:
- name: slot
description: replication slot name
metrics:
- name: postgres.replication_slot_files_count
description: Replication slot files
unit: files
chart_type: line
dimensions:
- name: wal_keep
- name: pg_replslot_files
- name: database
description: These metrics refer to the database.
labels:
- name: database
description: database name
metrics:
- name: postgres.db_transactions_ratio
description: Database transactions ratio
unit: percentage
chart_type: line
dimensions:
- name: committed
- name: rollback
- name: postgres.db_transactions_rate
description: Database transactions
unit: transactions/s
chart_type: line
dimensions:
- name: committed
- name: rollback
- name: postgres.db_connections_utilization
description: Database connections utilization
unit: percentage
chart_type: line
dimensions:
- name: used
- name: postgres.db_connections_count
description: Database connections
unit: connections
chart_type: line
dimensions:
- name: connections
- name: postgres.db_cache_io_ratio
description: Database buffer cache miss ratio
unit: percentage
chart_type: line
dimensions:
- name: miss
- name: postgres.db_io_rate
description: Database reads
unit: B/s
chart_type: line
dimensions:
- name: memory
- name: disk
- name: postgres.db_ops_fetched_rows_ratio
description: Database rows fetched ratio
unit: percentage
chart_type: line
dimensions:
- name: fetched
- name: postgres.db_ops_read_rows_rate
description: Database rows read
unit: rows/s
chart_type: line
dimensions:
- name: returned
- name: fetched
- name: postgres.db_ops_write_rows_rate
description: Database rows written
unit: rows/s
chart_type: line
dimensions:
- name: inserted
- name: deleted
- name: updated
- name: postgres.db_conflicts_rate
description: Database canceled queries
unit: queries/s
chart_type: line
dimensions:
- name: conflicts
- name: postgres.db_conflicts_reason_rate
description: Database canceled queries by reason
unit: queries/s
chart_type: line
dimensions:
- name: tablespace
- name: lock
- name: snapshot
- name: bufferpin
- name: deadlock
- name: postgres.db_deadlocks_rate
description: Database deadlocks
unit: deadlocks/s
chart_type: line
dimensions:
- name: deadlocks
- name: postgres.db_locks_held_count
description: Database locks held
unit: locks
chart_type: stacked
dimensions:
- name: access_share
- name: row_share
- name: row_exclusive
- name: share_update
- name: share
- name: share_row_exclusive
- name: exclusive
- name: access_exclusive
- name: postgres.db_locks_awaited_count
description: Database locks awaited
unit: locks
chart_type: stacked
dimensions:
- name: access_share
- name: row_share
- name: row_exclusive
- name: share_update
- name: share
- name: share_row_exclusive
- name: exclusive
- name: access_exclusive
- name: postgres.db_temp_files_created_rate
description: Database created temporary files
unit: files/s
chart_type: line
dimensions:
- name: created
- name: postgres.db_temp_files_io_rate
description: Database temporary files data written to disk
unit: B/s
chart_type: line
dimensions:
- name: written
- name: postgres.db_size
description: Database size
unit: B
chart_type: line
dimensions:
- name: size
- name: table
description: These metrics refer to the database table.
labels:
- name: database
description: database name
- name: schema
description: schema name
- name: table
description: table name
- name: parent_table
description: parent table name
metrics:
- name: postgres.table_rows_dead_ratio
description: Table dead rows
unit: percentage
chart_type: line
dimensions:
- name: dead
- name: postgres.table_rows_count
description: Table total rows
unit: rows
chart_type: line
dimensions:
- name: live
- name: dead
- name: postgres.table_ops_rows_rate
description: Table throughput
unit: rows/s
chart_type: line
dimensions:
- name: inserted
- name: deleted
- name: updated
- name: postgres.table_ops_rows_hot_ratio
description: Table HOT updates ratio
unit: percentage
chart_type: line
dimensions:
- name: hot
- name: postgres.table_ops_rows_hot_rate
description: Table HOT updates
unit: rows/s
chart_type: line
dimensions:
- name: hot
- name: postgres.table_cache_io_ratio
description: Table I/O cache miss ratio
unit: percentage
chart_type: line
dimensions:
- name: miss
- name: postgres.table_io_rate
description: Table I/O
unit: B/s
chart_type: line
dimensions:
- name: memory
- name: disk
- name: postgres.table_index_cache_io_ratio
description: Table index I/O cache miss ratio
unit: percentage
chart_type: line
dimensions:
- name: miss
- name: postgres.table_index_io_rate
description: Table index I/O
unit: B/s
chart_type: line
dimensions:
- name: memory
- name: disk
- name: postgres.table_toast_cache_io_ratio
description: Table TOAST I/O cache miss ratio
unit: percentage
chart_type: line
dimensions:
- name: miss
- name: postgres.table_toast_io_rate
description: Table TOAST I/O
unit: B/s
chart_type: line
dimensions:
- name: memory
- name: disk
- name: postgres.table_toast_index_cache_io_ratio
description: Table TOAST index I/O cache miss ratio
unit: percentage
chart_type: line
dimensions:
- name: miss
- name: postgres.table_toast_index_io_rate
description: Table TOAST index I/O
unit: B/s
chart_type: line
dimensions:
- name: memory
- name: disk
- name: postgres.table_scans_rate
description: Table scans
unit: scans/s
chart_type: line
dimensions:
- name: index
- name: sequential
- name: postgres.table_scans_rows_rate
description: Table live rows fetched by scans
unit: rows/s
chart_type: line
dimensions:
- name: index
- name: sequential
- name: postgres.table_autovacuum_since_time
description: Table time since last auto VACUUM
unit: seconds
chart_type: line
dimensions:
- name: time
- name: postgres.table_vacuum_since_time
description: Table time since last manual VACUUM
unit: seconds
chart_type: line
dimensions:
- name: time
- name: postgres.table_autoanalyze_since_time
description: Table time since last auto ANALYZE
unit: seconds
chart_type: line
dimensions:
- name: time
- name: postgres.table_analyze_since_time
description: Table time since last manual ANALYZE
unit: seconds
chart_type: line
dimensions:
- name: time
- name: postgres.table_null_columns
description: Table null columns
unit: columns
chart_type: line
dimensions:
- name: "null"
- name: postgres.table_size
description: Table total size
unit: B
chart_type: line
dimensions:
- name: size
- name: postgres.table_bloat_size_perc
description: Table bloat size percentage
unit: percentage
chart_type: line
dimensions:
- name: bloat
- name: postgres.table_bloat_size
description: Table bloat size
unit: B
chart_type: line
dimensions:
- name: bloat
- name: index
description: These metrics refer to the table index.
labels:
- name: database
description: database name
- name: schema
description: schema name
- name: table
description: table name
- name: parent_table
description: parent table name
- name: index
description: index name
metrics:
- name: postgres.index_size
description: Index size
unit: B
chart_type: line
dimensions:
- name: size
- name: postgres.index_bloat_size_perc
description: Index bloat size percentage
unit: percentage
chart_type: line
dimensions:
- name: bloat
- name: postgres.index_bloat_size
description: Index bloat size
unit: B
chart_type: line
dimensions:
- name: bloat
- name: postgres.index_usage_status
description: Index usage status
unit: status
chart_type: line
dimensions:
- name: used
- name: unused
|