> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trace0hq.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PostgreSQL Metrics

> Monitor PostgreSQL metrics including latency, error rates and usage per table and operation, as well as connection pool metrics.


### Introduction

Trace0 provides detailed metrics for [PostgreSQL](https://www.postgresql.org/), a powerful, object-relational database system.

Metrics are based on the [OpenTelemetry semantic conventions for PostgreSQL client operations](https://opentelemetry.io/docs/specs/semconv/db/postgresql).

To view metrics for PostgreSQL for a service, click into the [Metrics](https://app.trace0hq.com/metrics) section, click the `View more` link for your service, then click the `PostgreSQL` toggle.

<img className="block dark:hidden" alt="PostgreSQL Request Metrics Light" src="https://mintcdn.com/trace0/qgOLYXLDkBHaw0YG/images/postgres-requests-metrics-light.png?fit=max&auto=format&n=qgOLYXLDkBHaw0YG&q=85&s=c0536855a2388195da6475148ee37138" width="2876" height="1502" data-path="images/postgres-requests-metrics-light.png" />

<img className="hidden dark:block" alt="PostgreSQL Request Metrics Dark" src="https://mintcdn.com/trace0/qgOLYXLDkBHaw0YG/images/postgres-requests-metrics-dark.png?fit=max&auto=format&n=qgOLYXLDkBHaw0YG&q=85&s=ba9c55eddab310d4c26ebbf6066179ee" width="2872" height="1506" data-path="images/postgres-requests-metrics-dark.png" />

<p />

<img className="block dark:hidden" alt="PostgreSQL Connection Pool Metrics Light" src="https://mintcdn.com/trace0/qgOLYXLDkBHaw0YG/images/postgres-connection-pool-metrics-light.png?fit=max&auto=format&n=qgOLYXLDkBHaw0YG&q=85&s=0713dbf6f5b6482c1cf416ae6c57185f" width="2880" height="1350" data-path="images/postgres-connection-pool-metrics-light.png" />

<img className="hidden dark:block" alt="PostgreSQL Connection Pool Metrics Dark" src="https://mintcdn.com/trace0/qgOLYXLDkBHaw0YG/images/postgres-connection-pool-metrics-dark.png?fit=max&auto=format&n=qgOLYXLDkBHaw0YG&q=85&s=6dc0345b90b0a00677d4c5b751bcd514" width="2874" height="1354" data-path="images/postgres-connection-pool-metrics-dark.png" />

### Displayed Metrics

We currently display the following PostgreSQL metrics, broken into `Requests` and `Connection Pools` sections.

The metrics are displayed either as a single value or as a chart.

<Tabs>
  <Tab title="Requests">
    **Single Value**

    | Metric | Unit |
    | - | - |
    | Request Count | Number |
    | Requests per Second | Number |
    | Request Latency P99 | Time (ms, s) |
    | Error Rate | Percentage |

    **Chart**

    | Metric | Description | Chart Type |
    | - | - | - |
    | Request Count by Table | Number of database requests grouped by table | Horizontal Bar chart |
    | P99 Latency by Table | P99 request latency grouped by table | Horizontal Bar chart |
    | Request Count by Operation | Number of database requests grouped by operation | Horizontal Bar chart |
    | P99 Latency by Operation | P99 request latency grouped by operation | Horizontal Bar chart |
    | Request Count Over Time | Number of database requests over time | Vertical Bar chart |
    | Latency Over Time | P50, P75, P90, P95, and P99 request latency over time | Line chart |

    <Note>
      SQL commands containing multiple statements are not attributed to a specific table or operation and are therefore excluded from request count and latency metrics for individual tables and operations.
    </Note>
  </Tab>

  <Tab title="Connection Pools">
    **Chart**

    | Metric | Description | Chart Type |
    | - | - | - |
    | Connection Count | Number of used and idle connections over time for each connection pool | Line chart |
  </Tab>
</Tabs>

## Examples

See our example apps for working services that uses PostgreSQL with Trace0 installed:

| Example | Environment |
| - | - |
| [Java Docker PostgreSQL example app](https://github.com/Trace0-HQ/trace0-examples/blob/main/java-postgres-docker) | Docker (local) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.