24.1. Integration with Prometheus and VictoriaMetrics #

Integration with external Prometheus and VictoriaMetrics data sources is used for reading metrics written by pgpro-otel-collector.

Note

This section describes how to configure Prometheus. VictoriaMetrics uses similar interfaces for working with metrics, so it will be mentioned separately only when a configuration step differs from Prometheus.

The components below are required for integration.

pgpro-otel-collector #

The monitoring agent that provides the following functionality:

  • collects statistics from Postgres Pro DBMS instances and converting them to metrics

  • publishes metrics for further collection by the Prometheus or VictoriaMetrics monitoring system

Prometheus or VictoriaMetrics #

The monitoring system that provides the following functionality:

  • collects metrics from pgpro-otel-collector monitoring agents (VictoriaMetrics uses a separate component — vmagent — for this purpose)

  • stores metrics from monitoring agents according to internal storage parameters

  • provides the HTTP interface for receiving metrics

PPEM #

The Postgres Pro Enterprise Manager system that provides the following functionality:

  • accesses the Prometheus monitoring system for receiving DBMS instance metrics

  • provides the user with the monitoring interface in the form of graphs

The integration process includes the following steps:

Additional configuration of the agent is not required.

24.1.1. Configuring pgpro-otel-collector for Prometheus and VictoriaMetrics #

  1. Enable and configure the postgrespro and hostmetrics receivers:

    receivers:
      hostmetrics:
        initial_delay: 1s
        collection_interval: 60s
        scrapers:
          cpu:
            metrics:
              system.cpu.utilization:
                enabled: true
          disk: null
          filesystem: null
          load: null
          memory: null
          network: null
          paging: null
          processes: null
      postgrespro:
        max_threads: 3
        initial_delay: 1s
        collection_interval: 60s
        transport: tcp
        endpoint: localhost:5432
        database: postgres
        username: postgres
        password: ${env:POSTGRESQL_PASSWORD}
        plugins:
          activity:
            enabled: true
          archiver:
            enabled: true
          bgwriter:
            enabled: true
          cache:
            enabled: true
          databases:
            enabled: true
          io:
            enabled: true
          locks:
            enabled: true
          version:
            enabled: true
          wal:
            enabled: true
    
  2. Configure metrics publishing using prometheusexporter and the pipeline.

    PPEM expects the metrics sent by pgpro-otel-collector to have the instance label with the node FQDN and DBMS instance port number separated by a colon, such as postgresql_activity_connections{instance="postgresql-01.example.org:5432"}.

    Configuration example:

    exporters:
      prometheus:
        const_labels:
          instance: postgresql-01.example.org:5432
        endpoint: :8889
        send_timestamps: true
    
    service:
      extensions: []
      pipelines:
        metrics:
          exporters:
          - prometheus
          receivers:
          - postgrespro
          - hostmetrics
    
  3. Start the collector and ensure that metrics are published on its side:

    # systemctl start pgpro-otel-collector
    
    # systemctl status pgpro-otel-collector
    ● pgpro-otel-collector.service - PostgresPro OpenTelemetry Collector
        Loaded: loaded (/lib/systemd/system/pgpro-otel-collector.service; enabled; preset: enabled)
        Active: active (running) since Thu 2025-03-20 01:18:08 MSK; 4h 13min ago
      Main PID: 6991 (pgpro-otel-coll)
        Tasks: 8 (limit: 3512)
        Memory: 119.3M
          CPU: 2min 49.311s
        CGroup: /system.slice/pgpro-otel-collector.service
                └─6991 /usr/bin/pgpro-otel-collector --config /etc/pgpro-otel-collector/basic.yml
    
    Mar 20 01:18:08 postgresql-01.example.org pgpro-otel-collector[6991]: {"level":"info","ts":1742422688.366656,"msg":"Setting up own telemetry..."}
    Mar 20 01:18:08 postgresql-01.example.org pgpro-otel-collector[6991]: {"level":"info","ts":1742422688.367178,"msg":"Skipped telemetry setup."}
    Mar 20 01:18:08 postgresql-01.example.org pgpro-otel-collector[6991]: {"level":"info","ts":1742422688.3679142,"msg":"Development component. May change in the future.","kind":"receiver","name":"postgrespro","data_type":"metrics"}
    Mar 20 01:18:08 postgresql-01.example.org pgpro-otel-collector[6991]: {"level":"warn","ts":1742422688.3494158,"caller":"envprovider@v1.16.0/provider.go:59","msg":"Configuration references unset environment variable","name":"POSTGRESQL_P>
    Mar 20 01:18:08 postgresql-01.example.org pgpro-otel-collector[6991]: {"level":"info","ts":1742422688.4481084,"msg":"Starting pgpro-otel-collector...","Version":"v0.5.0","NumCPU":1}
    Mar 20 01:18:08 postgresql-01.example.org pgpro-otel-collector[6991]: {"level":"info","ts":1742422688.4481149,"msg":"Starting extensions..."}
    Mar 20 01:18:08 postgresql-01.example.org pgpro-otel-collector[6991]: {"level":"warn","ts":1742422688.4483361,"msg":"Using the 0.0.0.0 address exposes this server to every network interface, which may facilitate Denial of Service attack>
    Mar 20 01:18:08 postgresql-01.example.org pgpro-otel-collector[6991]: {"level":"info","ts":1742422688.4515307,"msg":"Starting stanza receiver","kind":"receiver","name":"filelog","data_type":"logs"}
    Mar 20 01:18:08 postgresql-01.example.org pgpro-otel-collector[6991]: {"level":"info","ts":1742422688.451749,"msg":"Everything is ready. Begin running and processing data."}
    
    curl -s 127.0.0.1:8889/metrics |grep -c postgres
    4254
    

24.1.2. Configuring Prometheus and VictoriaMetrics #

You can configure collection of metrics using pgpro-otel-collector on the side of Prometheus or VictoriaMetrics (vmagent) in different ways. One of the ways is collecting using the static configuration:

- job_name: pgpro-otel-collector
  honor_labels: true
  scrape_interval: 1m
  static_configs:
    - targets:
        - postgresql-01.example.org:8889

The scrape_interval value specifying the metrics collection interval must be 1m (1 minute). The honor_labels attribute is necessary to properly obtain the instance metric attribute.

For more information about other collection methods, refer to the official Prometheus or VictoriaMetrics vmagent documentation.

PPEM does not require additional Prometheus or VictoriaMetrics configuration.

24.1.3. Checking for Metrics in Prometheus and VictoriaMetrics #

After configuring metrics collection using pgpro-otel-collector, ensure that metrics are received by the monitoring system.

For this check, you can use the built-in expression browser graphical tool for Prometheus or vmui for VictoriaMetrics. The promtool utility from Prometheus can be used for both monitoring services.

Example check using the promtool utility:

promtool query instant <URL> 'postgresql_activity_connections{instance="postgresql-01.example.org:5432"}'

Where:

  • <URL>: The URL of the monitoring service. For example:

    • https://prometheus.example.org for Prometheus

    • https://vm.example.org for VictoriaMetrics used for a standalone instance

    • https://vm.example.org/select/0/prometheus for VictoriaMetrics used for a cluster

  • postgresql_activity_connections{instance="postgresql-01.example.org:5432"}: The name and labels of the metric.

Response example:

postgresql_activity_connections{database="postgres", instance="postgresql-01.example.org:5432", job="pgpro-otel-collector", state="active", user="postgres"} 5
postgresql_activity_connections{database="postgres", instance="postgresql-01.example.org:5432", job="pgpro-otel-collector", state="idle", user="postgres"} 10

24.1.4. Configuring a Metrics Data Source #

  1. In the navigation panel, go to InfrastructureData sourcesMetrics storages.

  2. In the top-right corner of the page, click Create storage.

  3. Specify the metrics storage parameters (parameters marked with an asterisk are required):

    • Name: The unique name of the metrics storage. For example, Prometheus or VictoriaMetrics.

    • URL: The network address for connecting to the metrics storage. For example, https://prometheus.example.org/select/0/prometheus or https://vm.example.org/select/0/prometheus.

    • User: The unique name of the user if authentication is used.

    • Password: The password of the user if authentication is used.

    • Description: The description of the metrics storage.

    • Make default datasource: Specifies whether the metrics storage is used by default for all metric queries.

  4. Click Save.

24.1.5. Checking the Operation of a Metrics Storage #

  1. In the navigation panel, go to MonitoringMetrics.

  2. In the top-right corner of the page, select the instance for which there are metrics in the storage.

  3. Change the default data source to the internal one and ensure that graphs are displayed without errors.