Интеграция с PostgresPro Enterprise Manager

PostgresPro Enterprise Manager (далее PPEM) поддерживает интеграцию с коллектором и способен принимать метрики и журналы.

Настройка метрик

Для отправки метрик в 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.

Настройка журналов

Для отправки журналов в 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

Пример конфигурации

Ниже приведен пример конфигурации коллектора с отправкой метрик и журналов (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
      archiver:
        enabled: true
      bgwriter:
        enabled: true
      bloat_indexes:
        enabled: true
      bloat_tables:
        enabled: true
      cache:
        enabled: true
      databases:
        enabled: true
      functions:
        enabled: true
      indexes:
        enabled: true
      io:
        enabled: true
      locks:
        enabled: true
      replication:
        enabled: true
      replication_slots:
        enabled: true
      tables:
        enabled: true
      tablespaces:
        enabled: true
      version:
        enabled: true
      wal:
        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: ale-lessqq1-manager-1.l.postgrespro.ru: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