Skip to main content

PostgreSQL Integration

Connect PostgreSQL to enable the AI agent to query logs, metrics, and operational data stored in your PostgreSQL databases during investigations.

Capabilities

Once connected, the AI agent can:

CapabilityDescription
SQL QueriesExecute read-only SELECT queries against your databases
Log AnalysisSearch and analyze log data stored in PostgreSQL
Schema ExplorationBrowse databases, tables, columns, and indexes
Metrics RetrievalQuery operational metrics and time-series data
note

Read-only access: This integration only executes SELECT queries. UPDATE, DELETE, INSERT, and other data-modifying commands are blocked at the query level.

Prerequisites

  • A PostgreSQL instance (version 12 or later recommended)
  • A PostgreSQL user account with read permissions
  • Network connectivity between Autoheal and your PostgreSQL instance

Setup

1
Create a Read-Only User
  1. Connect to your PostgreSQL instance
  2. Create a dedicated user for Autoheal:
CREATE ROLE autoheal_reader WITH LOGIN PASSWORD 'your_secure_password';
GRANT CONNECT ON DATABASE your_database TO autoheal_reader;
GRANT USAGE ON SCHEMA public TO autoheal_reader;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO autoheal_reader;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO autoheal_reader;
2
Add Integration in Autoheal
  1. Go to Integrations in Autoheal
  2. Click PostgreSQL
  3. Enter a name (e.g., "Production PostgreSQL")
3
Configure Credentials

Enter the following:

  • Host: PostgreSQL hostname or IP address (e.g., postgres.example.com)
  • Port: PostgreSQL port (default: 5432)
  • Database: Database name to connect to
  • Username: PostgreSQL username
  • Password: PostgreSQL password
  • SSL Mode: SSL connection mode
4
Test and Save

Click Test Connection to verify, then Save.

Required Permissions

The PostgreSQL user should have at least these permissions:

PermissionWhy It's Needed
CONNECTConnect to the database
USAGE on schemaAccess schema objects
SELECT on tablesRead data from tables
tip

Create a dedicated role for Autoheal with only SELECT permissions. Use ALTER DEFAULT PRIVILEGES to automatically grant read access on new tables.

SSL Modes

Select the appropriate SSL mode for your environment:

ModeDescription
disableNo SSL (not recommended)
requireRequire SSL but skip certificate verification (default)
verify-caRequire SSL and verify the server certificate CA
verify-fullRequire SSL and verify the server certificate and hostname
warning

Use verify-ca or verify-full in production environments for maximum security. The require mode encrypts the connection but does not verify the server identity.

Example Queries

Once connected, you can ask the AI agent questions like:

Show me errors from the application_logs table in the last hour
Query the events table for failed payments today
What tables exist in the public schema?
Show me the slowest queries from the pg_stat_statements view

Troubleshooting

Connection Refused
  • Verify the host and port are correct
  • Check that PostgreSQL is running and accepting connections
  • Ensure pg_hba.conf allows connections from Autoheal
  • Verify firewall rules allow connections on the specified port
Authentication Failed
  • Verify the username and password are correct
  • Check that the user has LOGIN privilege
  • Ensure pg_hba.conf allows the authentication method being used
SSL Errors
  • Try changing the SSL mode (e.g., from verify-full to require)
  • Verify the server certificate is valid if using verify-ca or verify-full
  • Check that the server supports SSL connections
Permission Denied
  • Verify the user has SELECT permission on the target tables
  • Check that USAGE permission is granted on the schema
  • Ensure CONNECT permission is granted on the database