6.7. Интеграция с Postgres Pro Enterprise Manager #
Postgres Pro Enterprise Manager (PPEM) поддерживает интеграцию с pgpro-otel-collector и способен принимать метрики и журналы.
6.7.1. Настройка метрик #
Для отправки метрик в PPEM выполните следующие действия:
Включите и настройте нужные ресиверы метрик (как обычно).
Включите и настройте экспортёр
otlphttp
.Укажите URL подключения к PPEM.
В заголовке
X-Ppem-Source-Agent-Name
укажите имя агента, который управляет экземпляром базы данных (см.ppem-agent.yml
).В заголовке
X-Ppem-Source-Instance-Port
укажите номер порта экземпляра СУБД (см.postgresql.conf
).Настройте конвейер (как обычно).
receivers: hostmetrics: # ... postgrespro: # ... exporters: otlphttp/ppem_metrics: compression: '' endpoint: "https://ppem.example.org" headers: X-Ppem-Source-Agent-Name: "dbserver01" X-Ppem-Source-Instance-Port: "5432" service: extensions: [] pipelines: metrics: receivers: - postgrespro - hostmetrics processors: exporters: - otlphttp/ppem_metrics
Важно указать правильные значения в заголовках HTTP — эти заголовки используются для ассоциации метрик с экземплярами в PPEM.
6.7.2. Настройка журналов #
Для отправки журналов в PPEM выполните следующие действия:
Включите и настройте ресиверы
filelog
с учётом формата журналирования экземпляра СУБД (csvlog
илиjsonlog
).Включите и настройте процессор
attributes/convert
с учётом формата журналирования экземпляра СУБД (csvlog
илиjsonlog
).Включите и настройте экспортёр
otlphttp
.Укажите URL подключения к PPEM.
В заголовке
X-Ppem-Source-Agent-Name
укажите имя агента, который управляет экземпляром СУБД (см.ppem-agent.yml
).В заголовке
X-Ppem-Source-Instance-Port
укажите номер порта экземпляра СУБД (см.postgresql.conf
).Настройте конвейер (как обычно).
receivers: filelog: # ... processors: attributes/convert: # ... exporters: otlphttp/ppem_logs: compression: '' endpoint: "https://ppem.example.org" headers: X-Ppem-Source-Agent-Name: "dbserver01" X-Ppem-Source-Instance-Port: '5432' service: extensions: [] pipelines: logs: receivers: - filelog processors: - attributes/convert exporters: - otlphttp/ppem_logs
6.7.3. Пример конфигурации #
Ниже приведён пример конфигурации коллектора для отправки метрик и журналов (CSV) в PPEM.
receivers: filelog: include: - /var/log/postgresql/*.csv multiline: line_start_pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2} operators: - header: timestamp,user,dbname,pid,connection_from,session_id,line_num,ps,session_start,vxid,txid,error_severity,state_code,message,detail,hint,internal_query,internal_position,context,statement,cursor_position,func_name,application_name,backend_type,leader_pid,query_id timestamp: layout: '%Y-%m-%d %H:%M:%S.%L %Z' layout_type: strptime parse_from: attributes.timestamp type: csv_parser - field: attributes.timestamp type: remove retry_on_failure: enabled: true initial_interval: 1s max_elapsed_time: 5m max_interval: 30s start_at: end hostmetrics: collection_interval: 60s initial_delay: 1s scrapers: cpu: metrics: system.cpu.utilization: enabled: true disk: null load: null memory: null network: null postgrespro: max_threads: 3 initial_delay: 1s collection_interval: 60s transport: tcp endpoint: localhost:5432 database: postgres username: postgres password: ${env:POSTGRESQL_PASSWORD} metrics: null plugins: activity: enabled: true bgwriter: enabled: true locks: enabled: true versions: enabled: true wal: enabled: true cache: enabled: true processors: attributes/convert: actions: - action: convert converted_type: int key: pid - action: convert converted_type: int key: line_num - action: convert converted_type: int key: txid - action: convert converted_type: int key: remote_port - action: convert converted_type: int key: cursor_position - action: convert converted_type: int key: internal_position - action: convert converted_type: int key: leader_pid batch: send_batch_size: 8192 timeout: 10s resource: attributes: - action: upsert key: service.name value: postgresql - action: upsert key: service.instance.id value: dbserver-01.example.org:5432 exporters: otlphttp/ppem_logs: endpoint: 'https://ppem.example.org' headers: X-Ppem-Source-Agent-Name: 'dbserver-01.example.org' X-Ppem-Source-Instance-Port: '5432' otlphttp/ppem_metrics: endpoint: 'https://ppem.example.org' headers: X-Ppem-Source-Agent-Name: 'dbserver-01.example.org' X-Ppem-Source-Instance-Port: '5432' service: extensions: [] pipelines: logs: receivers: - filelog processors: - resource - attributes/convert - batch exporters: - otlphttp/ppem_logs metrics: receivers: - postgrespro - hostmetrics processors: - batch exporters: - otlphttp/ppem_metrics