Chapter 5. Installation and Minimal Setup

pgpro-otel-collector is installed from the Postgres Pro software repository. Follow the steps below for a minimal setup.

  1. Add the Repository and Install the Package

    Add the Postgres Pro repository by running the pgpro-repo-add.sh script, update the package manager metadata, and install the pgpro-otel-collector package.

    For Debian/Ubuntu distributions:

    # wget https://repo.postgrespro.ru/otelcol/otelcol/keys/pgpro-repo-add.sh
    # sh ./pgpro-repo-add.sh
    # apt update
    # apt install pgpro-otel-collector
    
  2. Configure the Collector

    The main configuration file is /etc/pgpro-otel-collector/basic.yml. Edit this file to suit your environment.

    1. Set the Database Connection Parameters

      Locate the receivers:postgrespro section and ensure the connection details are correct. The password can be set via an environment variable.

      receivers:
          postgrespro:
              endpoint: &endpoint localhost:5432       # The address of the Postgres Pro server
              database: postgres                       # The database name for connection
              username: postgres                       # The user for connection
              password: ${env:POSTGRESQL_PASSWORD}     # The connection password
      
    2. (Optional) Adjust the Performance Settings

      You can modify the collection interval and how metrics are batched for sending. For example:

      receivers:
          postgrespro:
              collection_interval: 60s # Time interval for metrics collection
      processors:
        batch/metrics:
          send_batch_size: 8192        # Batch size threshold for sending
          timeout: 10s                 # Timeout for sending batches
      
    3. Enable and Configure Plugins

      Configure which plugins will be active. collection_interval can also be overridden for each specific plugin.

      receivers:
          postgrespro:
              plugins:
                  activity:
                      enabled: true
                      # collection_interval: 60s
                  bgwriter:
                      enabled: true
                  locks:
                      enabled: true
                  version:
                      enabled: true
                  wal:
                      enabled: true
                  cache:
                      enabled: true
      

      For more information on plugins, refer to Chapter 7.

  3. Start pgpro-otel-collector

    Run the following command to start pgpro-otel-collector:

    # systemctl start pgpro-otel-collector
    

    pgpro-otel-collector will automatically start collecting and sending data according to the parameters in the configuration file.

By default, the collected metrics are available in the Prometheus format at localhost:8889/metrics.

To view the collector logs, use the following command:

# sudo journalctl -u pgpro-otel-collector