Skip to main content

Postgresql

Causely provides native integration with Postgresql.

Step 1: Create a user

Create a user for your Postgresql database server.

Step 2: Enable pg_stat_statements

AWS RDS PostgreSQL

Steps:

  1. Go to RDS Console → Parameter Groups
  2. Edit your parameter group
  3. Set shared_preload_libraries to include pg_stat_statements
  4. Restart your instance
  5. Connect and run: CREATE EXTENSION IF NOT EXISTS pg_stat_statements;

Azure Database for PostgreSQL

Steps:

  1. Go to Azure Portal → PostgreSQL server
  2. Select "Server parameters"
  3. Set shared_preload_libraries to include pg_stat_statements
  4. Restart the server
  5. Connect and run: CREATE EXTENSION IF NOT EXISTS pg_stat_statements;

Google Cloud SQL for PostgreSQL

Steps:

  1. Go to Cloud Console → Cloud SQL
  2. Edit your instance
  3. Add database flag: shared_preload_libraries=pg_stat_statements
  4. Restart the instance
  5. Connect and run: CREATE EXTENSION IF NOT EXISTS pg_stat_statements;

Step 3: Create a Kubernetes Secret for the user

After creating the user create a Kubernetes Secret:

kubectl create secret generic \
--namespace causely postgres-credentials \
--from-literal=username="..." \
--from-literal=password='...' \
--from-literal=host="..." \
--from-literal=port=5432 \
--from-literal=database="..." \
--from-literal=sslmode="..."

The host must be the FQDN of your DB, or IP address if there's no DNS entry set up. It must match the FQDN/IP Causely would discover either from the K8s Server (if it's running in your K8s Cluster) or your Cloud providers API. Examples:

  • Kubernetes: host=my-postgres.namespace.service.cluster.local
  • AWS: host=myinstance.rds.amazonaws.com

If you are leveraging a proxy to connect to your database, like it's common on GCP, host must be the FQDN/IP of your proxy and additionally host_overwrite should be the IP/FQDN of the actual database service: Examples:

  • GCP: host=localhost (assuming proxy runs on the same host / Pod). host_overwrite=1.2.3.4 (the IP of your GCP Cloud SQL instance as shown in the GCP Console)

Step 4: Update Causely Configuration

Once the Secret is created, update the Causely configuration to enable scraping for the new database. Below is an example configuration:

scrapers:
postgresql:
enabled: true
instances:
- secretName: postgres-credentials
namespace: causely

Alternative: Enable Credentials Autodiscovery

Causely also supports credentials autodiscovery. This feature allows you to add new scraping targets without updating the Causely configuration. Simply label the Kubernetes Secret to enable autodiscovery for the corresponding scraper.

Example: Labeling Secrets for Autodiscovery

kubectl --namespace causely label secret postgres-credentials "causely.ai/scraper=Postgresql"

With these steps, you can seamlessly integrate Causely with Postgresql and configure it to monitor your desired resources.