# PostgreSQL Receiver

<!-- llms-txt-link: /llms.txt -->

> OpenTelemetry Collector receiver · contrib distribution

This receiver queries the PostgreSQL [statistics collector](https://www.postgresql.org/docs/13/monitoring-stats.html).

- **Component ID**: `contrib-postgresqlreceiver`
- **Name**: `postgresqlreceiver`
- **Type**: receiver
- **Distribution**: contrib
- **Repository**: `opentelemetry-collector-contrib`

## Stability

| Level | Signals |
| --- | --- |
| beta | metrics |
| development | logs |

## Attributes

| Attribute | Type | Description |
| --- | --- | --- |
| `bg_buffer_source` | string | The source of a buffer write. |
| `bg_checkpoint_type` | string | The type of checkpoint state. |
| `bg_duration_type` | string | The type of time spent during the checkpoint. |
| `db.namespace` | string | The namespace or schema of the database where the query is executed. |
| `db.query.text` | string | The text of the database query being executed. |
| `db.system.name` | string | The database management system (DBMS) product as identified by the client instrumentation. |
| `function` | string | The name of the function. |
| `lock_type` | string | Type of the lockable object. |
| `mode` | string | Name of the lock mode held or desired by the process. |
| `network.peer.address` | string | IP address of the client connected to this backend. |
| `network.peer.port` | int | TCP port number that the client is using for communication with this backend. |
| `operation` | string | The database operation. |
| `postgresql.application_name` | string | Name of the application that is connected to this backend. |
| `postgresql.blocking.lock.mode` | string | The lock mode being requested by the blocked session (e.g. RowExclusiveLock, AccessExclusiveLock). Empty string when not blocked. |
| `postgresql.blocking.lock.relation` | string | The name of the relation (table) being waited on. Empty string when not blocked or when lock is not on a relation. |
| `postgresql.blocking.lock.type` | string | The type of lock resource being waited on (e.g. relation, transactionid, tuple). Empty string when not blocked. |
| `postgresql.blocking.pids` | string | Array of PIDs of sessions blocking this session (from pg_blocking_pids). Empty array when not blocked. |
| `postgresql.blocking.start_time` | string | UTC timestamp (RFC3339) when the current lock wait began, derived from pg_locks.waitstart. Empty string when not blocked. |
| `postgresql.blocking.transaction.start_time` | string | UTC timestamp (RFC3339) when the current transaction started. Empty string when no active transaction. |
| `postgresql.blocking.wait_duration` | int | Whole seconds this session has been waiting for a lock, measured from pg_locks.waitstart. 0 when not blocked. |
| `postgresql.calls` | int | Number of times the statement was executed, reported in delta value. |
| `postgresql.client_hostname` | string | Host name of the connected client, as reported by a reverse DNS lookup of client_addr. |
| `postgresql.pid` | int | Process ID of this backend. |
| `postgresql.query_id` | string | Identifier of this backend's most recent query. If state is active this field shows the identifier of the currently executing query. In all other states, it shows the identifier of last query that was executed. |
| `postgresql.query_plan` | string | The execution plan used by PostgreSQL for the query. |
| `postgresql.query_start` | string | Time when the currently active query was started, or if state is not active, when the last query was started. |
| `postgresql.queryid` | string | Hash code to identify identical normalized queries. |
| `postgresql.rolname` | string | The name of the PostgreSQL role that executed the query. |
| `postgresql.rows` | int | Total number of rows retrieved or affected by the statement, reported in delta value. |
| `postgresql.shared_blks_dirtied` | int | Total number of shared blocks dirtied by the statement, reported in delta value. |
| `postgresql.shared_blks_hit` | int | Total number of shared block cache hits by the statement, reported in delta value. |
| `postgresql.shared_blks_read` | int | Total number of shared blocks read by the statement, reported in delta value. |
| `postgresql.shared_blks_written` | int | Total number of shared blocks written by the statement, reported in delta value. |
| `postgresql.state` | string | Current overall state of this backend |
| `postgresql.temp_blks_read` | int | Total number of temp blocks read by the statement, reported in delta value. |
| `postgresql.temp_blks_written` | int | Total number of temp blocks written by the statement, reported in delta value. |
| `postgresql.total_exec_time` | double | Total time spent executing the statement, in delta milliseconds. |
| `postgresql.total_plan_time` | double | Total time spent planning the statement, in delta milliseconds. |
| `postgresql.wait_event` | string | Wait event name if backend is currently waiting, otherwise NULL. |
| `postgresql.wait_event_type` | string | The type of event for which the backend is waiting, if any; otherwise NULL. |
| `relation` | string | OID of the relation targeted by the lock, or null if the target is not a relation or part of a relation. |
| `replication_client` | string | The IP address of the client connected to this backend. If this field is "unix", it indicates either that the client is connected via a Unix socket. |
| `source` | string | The block read source type. |
| `state` | string | The tuple (row) state. |
| `user.name` | string | Name of the user logged into this backend. |
| `wal_operation_lag` | string | The operation which is responsible for the lag. |

## Data

- **JSON**: [/data/collector/components/contrib-postgresqlreceiver/contrib-postgresqlreceiver-a6832fef00e9.json](/data/collector/components/contrib-postgresqlreceiver/contrib-postgresqlreceiver-a6832fef00e9.json)
- **Explore**: [/collector/components/contrib/postgresqlreceiver](/collector/components/contrib/postgresqlreceiver)
