Skip to main content

Aiven for PostgreSQL

Aiven for PostgreSQL agent setup

For an overview of how the DBtune agent works, see agent overview.

Prerequisites

Before starting the DBtune agent, ensure you have completed the database setup steps and agent prerequisites.

For information about common environment variables (DBT_DBTUNE_*), see agent overview - common environment variables.

Aiven-specific environment variables

Note

Ensure the Aiven API token’s validity is long enough to run the DBtune agent.

VariableDescriptionFind at
DBT_POSTGRESQL_CONNECTION_URLPostgreSQL connection URLGo to the Aiven console > select Projects in the top bar > Go to your PostgreSQL specific project > Services > PostgreSQL service > Copy Service URI
DBT_AIVEN_API_TOKENAPI token generated from the Aiven console, used by DBtune to authenticate and collect metrics from the Aiven serviceGo to the Aiven console > User information (top right profile menu) > Tokens > Generate token
DBT_AIVEN_PROJECT_NAMEName of the Aiven project where the target PostgreSQL service is deployedGo to the Aiven console > select Projects in the top bar > View all projects > Find the PostgreSQL project and copy the project name
DBT_AIVEN_SERVICE_NAMEName of the PostgreSQL service within the specified Aiven projectGo to the Aiven console > select Projects in the top bar > Go to your PostgreSQL specific project > Services

Setting up the agent

Run the DBtune agent using Docker with Aiven-specific configuration:

docker run --restart always \
-e DBT_POSTGRESQL_CONNECTION_URL="postgresql://..." \
-e DBT_AIVEN_API_TOKEN=your-api-token \
-e DBT_AIVEN_PROJECT_NAME=your-project-name \
-e DBT_AIVEN_SERVICE_NAME=your-service-name \
-e DBT_DBTUNE_SERVER_URL=https://app.dbtune.com \
-e DBT_DBTUNE_API_KEY=your-dbtune-api-key \
-e DBT_DBTUNE_DATABASE_ID=your-dbtune-database-id \
public.ecr.aws/dbtune/dbtune/agent:latest

Parameters tuned

DBtune supports multiple tuning modes that determine which parameters can be optimized. For a detailed explanation of tuning modes, see tuning modes.

note

More parameters will be tuned by DBtune when Aiven opens them through their APIs. Check this page regularly for updates.

Reload-only tuning mode

The following parameters are tuned in reload-only mode:

  1. work_mem
  2. bgwriter_delay
  3. bgwriter_lru_maxpages
  4. max_parallel_workers
  5. max_parallel_workers_per_gather

Restart tuning mode

The following parameter is tuned in restart mode, in addition to all reload-only parameters:

  1. shared_buffers
note

We use the Aiven API to modify parameters, which limits the set of available parameters that we would normally tune for restart tuning mode.

Aiven-specific monitoring details

Metrics are collected every 30 seconds, rather than the standard 5 seconds. This is due to Aiven's API limitations. DBtune gathers these metrics by reading from system tables, as well as calling the Aiven API.

DBtune queries system metrics to ensure production safety. For up-to-date details, you can refer to the open-source agent.