Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel,
n'hésitez pas à nous contacter.
Overview
The PostgreSQL receiver allows for collection of PostgreSQL metrics and access to the PostgreSQL Overview and PostgreSQL Metrics dashboards. Configure the receiver according to the specifications of the latest version of the postgresqlreceiver.
For more information, see the OpenTelemetry project documentation for the PostgreSQL receiver.
Setup
To collect PostgreSQL metrics with OpenTelemetry for use with Datadog:
- Configure the PostgreSQL receiver in your OpenTelemetry Collector configuration.
- Optionally, configure the host metrics receiver if your OpenTelemetry Collector is running on the same server as your PostgreSQL database.
- Optionally, configure the file log receiver if your OpenTelemetry Collector is running on the same server as your PostgreSQL database.
- Configure service pipelines.
- Ensure the OpenTelemetry Collector is configured to export to Datadog.
PostgreSQL receiver
receivers:
postgresql/pg-host-1:
endpoint: "<HOST>:<PORT>"
username: "<USERNAME>"
password: "<PASSWORD>"
collection_interval: 15s
metrics:
postgresql.blks_hit:
enabled: true
postgresql.blks_read:
enabled: true
postgresql.database.locks:
enabled: true
postgresql.deadlocks:
enabled: true
postgresql.function.calls:
enabled: true
postgresql.sequential_scans:
enabled: true
postgresql.temp_files:
enabled: true
postgresql.temp.io:
enabled: true
postgresql.tup_deleted:
enabled: true
postgresql.tup_fetched:
enabled: true
postgresql.tup_inserted:
enabled: true
postgresql.tup_returned:
enabled: true
postgresql.tup_updated:
enabled: true
postgresql.wal.delay:
enabled: true
processors:
resource/pg-host-1:
attributes:
- action: insert
key: datadog.host.name
value: <HOST>
cumulativetodelta: {}
deltatorate:
metrics:
- postgresql.tup_returned
- postgresql.tup_fetched
- postgresql.tup_inserted
- postgresql.tup_updated
- postgresql.tup_deleted
- postgresql.operations
- postgresql.commits
- postgresql.rollbacks
- postgresql.blks_hit
- postgresql.blks_read
- postgresql.temp_files
- postgresql.temp.io
- postgresql.function.calls
- postgresql.index.scans
- postgresql.sequential_scans
- postgresql.blocks_read
See the PostgreSQL receiver documentation for detailed configuration options and requirements.
Host metrics receiver
receivers:
hostmetrics:
scrapers:
load:
cpu:
metrics:
system.cpu.utilization:
enabled: true
memory:
network:
File log receiver
This example assumes PostgreSQL 15+ with log_destination = 'jsonlog' configured. If you use the default stderr log format, adjust the operators to match your log_line_prefix.
receivers:
filelog:
include:
- <PATH_TO_YOUR_POSTGRESQL_LOG>
operators:
- type: json_parser
parse_from: body
timestamp:
parse_from: attributes.timestamp
layout: "%Y-%m-%d %H:%M:%S.%L %Z"
processors:
transform/logs:
log_statements:
- context: resource
statements:
- set(attributes["datadog.host.name"], "<HOST>")
- set(attributes["datadog.log.source"], "postgresql")
batch: {}
Service pipelines
service:
pipelines:
metrics/pg-host-1:
receivers: [postgresql/pg-host-1]
processors: [resource/pg-host-1, cumulativetodelta, deltatorate]
exporters: [datadog/exporter]
If you configured the host metrics receiver, add it to a separate metrics pipeline:
metrics/host:
receivers: [hostmetrics]
processors: [cumulativetodelta]
exporters: [datadog/exporter]
If you configured the file log receiver, add a logs pipeline:
logs:
receivers: [filelog]
processors: [transform/logs, batch]
exporters: [datadog/exporter]
Data collected
| OTEL | DESCRIPTION | FILTER |
|---|
| postgresql.backends | The number of backends. | |
| postgresql.bgwriter.buffers.allocated | Number of buffers allocated. | |
| postgresql.bgwriter.buffers.writes | Number of buffers written. | source: backend |
| postgresql.bgwriter.buffers.writes | Number of buffers written. | source: backend_fsync |
| postgresql.bgwriter.buffers.writes | Number of buffers written. | source: checkpoints |
| postgresql.bgwriter.buffers.writes | Number of buffers written. | source: bgwriter |
| postgresql.bgwriter.checkpoint.count | The number of checkpoints performed. | type: scheduled |
| postgresql.bgwriter.checkpoint.count | The number of checkpoints performed. | type: requested |
| postgresql.bgwriter.duration | Total time spent writing and syncing files to disk by checkpoints. | type: sync |
| postgresql.bgwriter.duration | Total time spent writing and syncing files to disk by checkpoints. | type: write |
| postgresql.bgwriter.maxwritten | Number of times the background writer stopped a cleaning scan because it had written too many buffers. | |
| postgresql.blks_hit | Number of times disk blocks were found already in the buffer cache. | |
| postgresql.blks_read | Number of disk blocks read in this database. | |
| postgresql.blocks_read | The number of blocks read. | source: heap_read |
| postgresql.blocks_read | The number of blocks read. | source: heap_hit |
| postgresql.blocks_read | The number of blocks read. | source: idx_read |
| postgresql.blocks_read | The number of blocks read. | source: idx_hit |
| postgresql.blocks_read | The number of blocks read. | source: toast_read |
| postgresql.blocks_read | The number of blocks read. | source: toast_hit |
| postgresql.blocks_read | The number of blocks read. | source: tidx_read |
| postgresql.blocks_read | The number of blocks read. | source: tidx_hit |
| postgresql.commits | The number of commits. | |
| postgresql.connection.max | Configured maximum number of client connections allowed | |
| postgresql.database.count | Number of user databases. | |
| postgresql.database.locks | The number of database locks. | |
| postgresql.db_size | The database disk usage. | |
| postgresql.deadlocks | The number of deadlocks. | |
| postgresql.function.calls | The number of calls made to a function. Requires track_functions=pl|all in Postgres config. | |
| postgresql.index.scans | The number of index scans on a table. | |
| postgresql.index.size | The size of the index on disk. | |
| postgresql.operations | The number of db row operations. | operation: hot_upd |
| postgresql.replication.data_delay | The amount of data delayed in replication. | |
| postgresql.rollbacks | The number of rollbacks. | |
| postgresql.rows | The number of rows in the database. | state: dead |
| postgresql.rows | The number of rows in the database. | state: live |
| postgresql.sequential_scans | The number of sequential scans. | |
| postgresql.table.count | Number of user tables in a database. | |
| postgresql.table.size | Disk space used by a table. | |
| postgresql.table.vacuum.count | Number of times a table has manually been vacuumed. | |
| postgresql.temp.io | Total amount of data written to temporary files by queries. | |
| postgresql.temp_files | The number of temp files. | |
| postgresql.tup_deleted | Number of rows deleted by queries in the database. | |
| postgresql.tup_fetched | Number of rows fetched by queries in the database. | |
| postgresql.tup_inserted | Number of rows inserted by queries in the database. | |
| postgresql.tup_returned | Number of rows returned by queries in the database. | |
| postgresql.tup_updated | Number of rows updated by queries in the database. | |
| postgresql.wal.age | Age of the oldest WAL file. | |
| postgresql.wal.delay | Time between flushing recent WAL locally and receiving notification that the standby server has completed an operation with it. | operation: write |
| postgresql.wal.delay | Time between flushing recent WAL locally and receiving notification that the standby server has completed an operation with it. | operation: flush |
| postgresql.wal.delay | Time between flushing recent WAL locally and receiving notification that the standby server has completed an operation with it. | operation: replay |
For the full mapping between OpenTelemetry and Datadog metric names, see OpenTelemetry Metrics Mapping.
Further reading
Documentation, liens et articles supplémentaires utiles: