Глава 5. Установка и минимальная настройка
Установить pgpro-otel-collector можно из репозитория программного обеспечения Postgres Pro. Для минимальной настройки выполните шаги ниже.
Подключите репозиторий и установите пакет
Подключите репозиторий Postgres Pro скриптом
pgpro-repo-add.sh, обновите метаданные пакетного менеджера и установите пакет pgpro-otel-collector.Для дистрибутивов Debian/Ubuntu:
# wget https://repo.postgrespro.ru/otelcol/otelcol/keys/pgpro-repo-add.sh # sh ./pgpro-repo-add.sh # apt update # apt install pgpro-otel-collector
Настройте коллектор
Основной файл конфигурации —
/etc/pgpro-otel-collector/basic.yml. Настройте его под ваше окружение.Задайте параметры подключения к базе данных
Найдите раздел
receivers:postgresproи убедитесь, что параметры подключения указаны верно. Пароль может быть задан через переменную окружения.receivers: postgrespro: endpoint: &endpoint localhost:5432 # Адрес сервера Postgres Pro database: postgres # Имя базы данных для подключения username: postgres # Пользователь для подключения password: ${env:POSTGRESQL_PASSWORD} # Пароль подключения(Необязательно) Отрегулируйте параметры производительности
Интервал сбора и способ пакетной отправки метрик можно изменять. Например:
receivers: postgrespro: collection_interval: 60s # Интервал сбора метрик processors: batch/metrics: send_batch_size: 8192 # Пороговый размер пакета для отправки timeout: 10s # Тайм-аут для отправки пакетовВключите и настройте плагины
Определите, какие плагины будут активны.
collection_intervalтакже можно переопределить для каждого конкретного плагина.receivers: postgrespro: plugins: activity: enabled: true # collection_interval: 60s bgwriter: enabled: true locks: enabled: true version: enabled: true wal: enabled: true cache: enabled: trueЗа подробной информацией о плагинах обратитесь к Главе 7.
Запустите pgpro-otel-collector
Выполните следующую команду для запуска pgpro-otel-collector:
# systemctl start pgpro-otel-collector
pgpro-otel-collector автоматически перейдёт в режим сбора и передачи данных в соответствии с параметрами в файле конфигурации.
По умолчанию собранные метрики доступны в формате Prometheus по адресу localhost:8889/metrics.
Для просмотра журналов коллектора используйте следующую команду:
# sudo journalctl -u pgpro-otel-collector
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.
Add the Repository and Install the Package
Add the Postgres Pro repository by running the
pgpro-repo-add.shscript, 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
Configure the Collector
The main configuration file is
/etc/pgpro-otel-collector/basic.yml. Edit this file to suit your environment.Set the Database Connection Parameters
Locate the
receivers:postgresprosection 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(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 batchesEnable and Configure Plugins
Configure which plugins will be active.
collection_intervalcan 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: trueFor more information on plugins, refer to Chapter 7.
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