---
updatedAt: 2026-11-09T18:47:45.000Z
agentTools:
  projectIndex: https://docs.getmontecarlo.com/llms.txt
---

# Postgres

## What is Postgres?

Postgres is an advanced open-source relational database management system known for its robustness, extensibility, and standards compliance. It supports complex queries, data integrity, and concurrency control, making it ideal for high-demand applications.

## Why Connect Postgres to Monte Carlo?

Integrating Monte Carlo with your Postgres database allows you to monitor your data and tables. Monte Carlo can detect anomalous volume changes. With the ability to run SQL queries on your tables you can create advanced monitors to analyze the data in your tables. For a full list of supported monitor types see [Monitor Support](https://docs.getmontecarlo.com/docs/postgres#monitor-support).

After connecting Postgres here is what you can expect to see:

**Volume**

Volume is monitored by a [Table monitor](https://docs.getmontecarlo.com/docs/pipeline-observability). Connecting the integration doesn't monitor any tables on its own: create a Table monitor and choose the databases and schemas it covers. By collecting metadata on your tables each hour, Monte Carlo's machine learning algorithm can set automatic thresholds to alert when a table has gone too long without a change in size or when an abnormal amount of rows are added or deleted.

<Image align="center" width="auto" src="https://files.readme.io/aaa3840-Screenshot_2024-06-28_at_11.54.43_AM.png" />

<Image align="center" width="auto" src="https://files.readme.io/ccbada2-Screenshot_2024-06-28_at_11.54.53_AM.png" />

## Monitor & Lineage Support

Below are the monitors & lineage support for the Postgres Integration today. Please reach out to your Monte Carlo representative if you have requirements for additional monitors.

<Table align={["left","left","left"]}>
  <thead>
    <tr>
      <th>
        Category
      </th>

      <th>
        Monitor / Lineage Capabilities
      </th>

      <th>
        Support
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        Table Monitor
      </td>

      <td>
        Freshness
      </td>

      <td>
        ✅ (via opt-in row count\*)
      </td>
    </tr>

    <tr>
      <td>
        Table Monitor
      </td>

      <td>
        Volume
      </td>

      <td>
        ✅ (via opt-in row count\*)
      </td>
    </tr>

    <tr>
      <td>
        Table Monitor
      </td>

      <td>
        Schema Changes
      </td>

      <td>
        :white_check_mark:
      </td>
    </tr>

    <tr>
      <td>
        Metric Monitor
      </td>

      <td>
        Metric
      </td>

      <td>
        ✅
      </td>
    </tr>

    <tr>
      <td>
        Metric Monitor
      </td>

      <td>
        Comparison
      </td>

      <td>
        :white_check_mark:
      </td>
    </tr>

    <tr>
      <td>
        Validation Monitor
      </td>

      <td>
        Custom SQL
      </td>

      <td>
        :white_check_mark:
      </td>
    </tr>

    <tr>
      <td>
        Validation Monitor
      </td>

      <td>
        Validation
      </td>

      <td>
        ✅
      </td>
    </tr>

    <tr>
      <td>
        Job Monitor
      </td>

      <td>
        Query performance
      </td>

      <td>

      </td>
    </tr>

    <tr>
      <td>
        Lineage
      </td>

      <td>
        Lineage
      </td>

      <td>

      </td>
    </tr>
  </tbody>
</Table>

\*freshness and volume monitors are available via user opt-in for each table. These monitors would run count(＊) queries for each table to detect freshness and volume anomalies.

## Connecting to Postgres

Now that we know the value connecting Postgres to Monte Carlo can bring, here are the necessary steps to set up the integration.

> 📘 Prerequisites
>
> To create a service account, you will need admin credentials to your Postgres database.

This guide explains how to create a read-only service account for Monte Carlo in your Postgres database.

To review all steps necessary to integrate a database with Monte Carlo, please see [here](https://docs.getmontecarlo.com/docs/overview-transactional-databases).

<Callout icon="🆕" theme="okay">
  ### Connect end to end with Claude or Terraform

  **Want a guided setup?** With the [Monte Carlo Agent Toolkit](https://docs.getmontecarlo.com/docs/agent-toolkit), run the following command and Claude walks you through every step:

  ```
  /monte-carlo-onboarding connect Postgres
  ```

  See [Providing credentials with Claude](https://docs.getmontecarlo.com/docs/postgres#providing-credentials-with-claude) for details.

  **Want it all as code?** With the Monte Carlo Terraform provider, one `terraform apply` creates the credentials, warehouse and connection. See [Providing credentials with the Terraform provider](https://docs.getmontecarlo.com/docs/postgres#providing-credentials-with-the-terraform-provider) or the [`montecarlo_postgres_credentials`](https://registry.terraform.io/providers/monte-carlo-data/montecarlo/latest/docs/resources/postgres_credentials) resource in the registry.

  **Prefer the UI?** Create the service account below, then provide its credentials in the onboarding wizard.
</Callout>

## Create a read-only service account

Please run the SQL snippet below on your Postgres database to create a read-only service account for Monte Carlo

```sql SQL
CREATE ROLE montecarlo WITH LOGIN PASSWORD '<PASSWORD>';

-- Grant access to all current tables. Repeat for all relevant schemas (e.g. public, etc.)
-- Select permissions are necessary to create custom SQL monitors.
-- To get a list of all schemas available:
---- SELECT schema_name FROM information_schema.schemata;

GRANT USAGE ON SCHEMA <schema> TO montecarlo;
GRANT SELECT ON ALL TABLES IN SCHEMA <schema> TO montecarlo;

-- Grant access to all future tables. Repeat for all relevant users who create tables in each schema.
-- Select permissions are necessary to create custom SQL monitors.
-- To get a list of all users available:
---- SELECT usename FROM pg_catalog.pg_user;

ALTER DEFAULT PRIVILEGES FOR ROLE <creating_user> IN SCHEMA <schema> GRANT SELECT ON TABLES TO montecarlo;
```

## Provide service account credentials to Monte Carlo

In the [settings page](https://getmontecarlo.com/settings/integrations) of the Monte Carlo UI, when using Monte Carlo's onboarding wizard, please provide the details created about to validate and complete the integration:

* **Integration Name**: Friendly name for your new connection, which will be referenced and shown throughout the Monte Carlo UI. For example, `postgres_prod`.
* **User** and **Password**: Please provide the credentials you chose while creating the service account.
* **Host**: The endpoint of your instance.
* **Port**: The port used to networking into your instance.
* **Database**: Please provide the name of the database.

To encrypt the connection with TLS, expand the **Advanced — SSL options** panel before adding the connection. See [Connect using SSL](https://docs.getmontecarlo.com/docs/postgres#connect-using-ssl) below.

Alternatively, we also support onboarding through our CLI:

1. Please follow [this](https://docs.getmontecarlo.com/docs/using-the-cli) guide to install and configure the CLI.
2. Please use the command `montecarlo integrations add-postgres`  to connect. For reference, see help [here](https://clidocs.getmontecarlo.com/#montecarlo-integrations-add-postgres).

```shell Example
montecarlo integrations add-postgres \
	--host example.cluster-123456789.us-east-1.rds.amazonaws.com \
	--user montecarlo \
	--password -1 \
	--database sample \
	--name artemis-dev
```

## Providing credentials with the Terraform provider

<Callout icon="🚧" theme="warn">
  The Terraform provider is in beta. It is versioned `0.x`, so pin its minor version.
</Callout>

The [Terraform provider](https://docs.getmontecarlo.com/docs/terraform-provider) takes the same details as the wizard. `montecarlo_postgres_credentials` holds the connection details and the service account's password, and `montecarlo_warehouse` and `montecarlo_connection` put them on a deployment:

```hcl
resource "montecarlo_warehouse" "postgres" {
  name            = "production-postgres"
  connection_type = "postgres"
  deployment_id   = var.deployment_id
}

resource "montecarlo_postgres_credentials" "postgres" {
  host    = "postgres.example.com"
  port    = 5432
  db_name = "analytics"
  user    = "monte_carlo"

  password_wo         = var.postgres_password
  password_wo_version = 1
}

resource "montecarlo_connection" "postgres" {
  name           = "production-postgres"
  warehouse_id   = montecarlo_warehouse.postgres.id
  credentials_id = montecarlo_postgres_credentials.postgres.id
}
```

`deployment_id` is the deployment the connection runs on: your collection agent's, or the **Cloud** deployment under **Settings > Deployments** if Monte Carlo connects from its cloud. Keep the password in a variable set from an uncommitted `*.tfvars` file or the environment; as a write-only argument it is never stored in the Terraform state or plan, which needs Terraform 1.11 or later. TLS is set with the `ssl_*` arguments; omit them for the defaults. Set `rds_proxy = true` when `host` is an Amazon RDS Proxy. See [`montecarlo_postgres_credentials`](https://registry.terraform.io/providers/monte-carlo-data/montecarlo/latest/docs/resources/postgres_credentials) in the registry for every argument.

## Providing credentials with Claude

With the [Agent Toolkit](https://docs.getmontecarlo.com/docs/agent-toolkit), run `/monte-carlo-onboarding connect Postgres` and Claude does the Monte Carlo steps through the MCP server. The password never passes through the chat: Claude gives you the command or the Terraform, and you run it on your machine. See [Onboard Postgres and Snowflake with self-hosted credentials](https://docs.getmontecarlo.com/docs/onboarding-example-self-hosted-credentials) for a complete run.

## Connect using SSL

Monte Carlo can encrypt the connection to your Postgres database with TLS. You can configure this in the onboarding wizard or through the CLI. Postgres negotiates TLS on the same port as an unencrypted connection (typically `5432`), so there is no separate SSL port to set.

> 📘 Client certificates (mutual TLS)
>
> Monte Carlo verifies the Postgres server using a CA certificate (one-way SSL). Client-certificate authentication (mutual TLS) is not currently supported for Postgres.

### In the onboarding wizard

In the **Provide service account credentials** step, expand the **Advanced — SSL options** panel. It offers:

* **CA certificate (PEM)**: Upload the PEM-formatted certificate authority (CA) certificate for your database. Uploading a CA enables TLS and verifies that the server's certificate is signed by a trusted authority. For AWS RDS and Aurora, use the [Amazon RDS CA bundle](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html).
* **Verify server identity**: Enabled by default once a CA certificate is uploaded. Monte Carlo also checks that the server certificate's hostname matches the host you are connecting to. Turn this off if the certificate is issued to a different name than your connection endpoint — for example, when connecting to an instance through a custom endpoint or IP address.
* **Disable SSL**: Explicitly connect without TLS. Leave the panel untouched to keep your server's default negotiation.

You can enable SSL when first creating a connection, or add or change it later by editing an existing Postgres connection. Stored SSL settings are not shown when editing, so re-upload the CA certificate to change them; leaving the panel blank keeps your existing configuration.

### Using the CLI

The `montecarlo integrations add-postgres` command accepts the following SSL options:

* `--ssl-ca`: Path to a PEM-formatted CA certificate. Providing it enables TLS and verifies the server against the CA, including that the certificate's hostname matches the host.
* `--ssl-disabled`: Set to `true` to explicitly connect without TLS.

```shell Example
montecarlo integrations add-postgres \
	--host example.cluster-123456789.us-east-1.rds.amazonaws.com \
	--user montecarlo \
	--password -1 \
	--database sample \
	--name artemis-dev \
	--ssl-ca /path/to/rds-ca-bundle.pem
```

> 📘 CLI version requirement
>
> If `--ssl-ca` isn't recognized, upgrade to the latest CLI with `pip install -U montecarlodata`.

To skip hostname verification (for example, when connecting through a custom endpoint or IP address), use the onboarding wizard's **Verify server identity** toggle — the CLI performs full verification whenever a CA certificate is provided.

**How can I validate Monte Carlo has access to my assets?**

After completing the Postgres integration setup, your Postgres assets should appear in the Monte Carlo Assets page between a few minutes and one hour. If you don't see your assets after this time period, you can run a validation test to troubleshoot the connection:

1. Navigate to Settings → Integrations
2. Find your Postgres integration and click on it
3. Select the specific connection you want to test
4. Click the Test button from the connection menu

This validation test will help identify any configuration issues that might be preventing your assets from appearing.

When running the validation test, you should see all green checkmarks. If any errors are encountered, the system will provide specific steps to resolve them.

# FAQs

**What is the minimum supported version?**

Monte Carlo's metadata collection supports Postgres 10 and newer. Versions lower than 10 but 9.4+ could also work, although not as thoroughly tested.

For metric monitors, some of the [validity metric types](:white_check_mark:) like SSN (%), USA phone number (%), USA ZIP code (%) and Email (%) use a Postgres function that is supported in Postgres 15 and newer. If you are using a version that predates 15, your metric monitor execution will fail if you use these metric types. You will still be able to create a metric monitor using any of the other metric types.

**Are cloud variants of Postgres like AWS Aurora, GCP Cloud SQL, and Azure Database supported?**

Yes, AWS Aurora, GCP Cloud SQL, and Azure Database for Postgres are all supported.

**Are other forks or variants supported?**

Variants like Greenplum, Supabase or others may work -- contact us.

**What hosting solutions are supported?**\
This integration supports any instance that is reachable from one of our hosting options. Please see the [networking docs](https://docs.getmontecarlo.com/docs/networking) for more detail.

**How do I list all schemas (for setup)?**

Run the following SQL snippet:

```sql
SELECT schema_name FROM information_schema.schemata;
```

**How do I list all users (for setup)?**

Run the following SQL snippet:

```Text SQL
SELECT usename FROM pg_catalog.pg_user;
```