# Datadog Agent for PostgreSQL Logs and Metrics

Kloudfuse can ingest metrics and logs from a self-managed PostgreSQL deployments through the Datadog agent.

## Prerequisites

For the collector to scrape data from postgres, follow the steps documented by Datadog to ensure smooth integration between the Datadog Agent and PostgreSQL, [Before you begin](https://docs.datadoghq.com/database_monitoring/setup_postgres/selfhosted/?tab=postgres10#before-you-begin).

## Annotate the PostgreSQL Instance

1. Add the following `podAnnotations` to the `postgresql.conf` file:

```yaml
   postgresql:
        primary:
          podAnnotations:
            ad.datadoghq.com/postgresql.check_names: '[
   "postgres"
   ]'
            ad.datadoghq.com/postgresql.init_configs: '[{}]'
            ad.datadoghq.com/postgresql.instances: '[{"host": "%%host%%", "port":5432, "username": "<user-you-created>", "password" : "<password-you-chose>", "tags" : []}]'
        readReplicas:
          podAnnotations:
            ad.datadoghq.com/postgresql.check_names: '[
   "postgres"
   ]'
            ad.datadoghq.com/postgresql.init_configs: '[{}]'
            ad.datadoghq.com/postgresql.instances: '[{"host": "%%host%%", "port":5432, "username": "<user-you-created>", "password" : "<password-you-chose>", "tags" : []}]'
   ```

2. Restart PostgreSQL instance after saving these changes.
