pgpro-otel-collector (Postgres Pro OpenTelemetry
Collector) is an independent utility designed to collect and process
statistical data from database instances, such as metrics and activity
logs, and deliver it to monitoring systems compatible with OpenTelemetry. It functions as an
agent or middleware between the database and the monitoring system.
A single instance of Postgres Pro generates a significant amount of statistical data, which is stored in system views, tables, and catalogs. Another source of data is activity logs (error logs, slow query logs, etc.), stored as files. To utilize this data, it must be extracted and sent to monitoring systems equipped with advanced tools such as visualization charts, dashboards, alerting tools, reports, and anomaly detection.
After collecting the data, pgpro-otel-collector converts
it into a format compatible with various monitoring systems. Depending
on the data transfer model, the converted data is either published on
the collector side (pull model), or sent to a particular monitoring
system (push model). Once stored in the monitoring system, the data
becomes available for further analysis and visualization.
pgpro-otel-collector can be used as an alternative to
traditional PostgreSQL monitoring agents, such as Postgres Exporter, or
Zabbix Agent.
pgpro-otel-collector is based on the OpenTelemetry
Collector and consists of several components that work together in a
pipeline:
Receivers: The primary components responsible
for collecting data from databases. pgpro-otel-collector
supports the following receivers:
postgrespro: The central component of
the collector, which contains the main implementation (built-in plugins)
for collecting data from a database instance.filelog: An auxiliary receiver
responsible for collecting information from database activity logs.hostmetrics: An auxiliary receiver
that collects information from the operating system; may require root
access.Processors: Receive data from receivers and process it.
Exporters: Receive processed data from
processors and deliver it to external consumers.
pgpro-otel-collector supports the following exporters:
otlphttp: Exports and sends
information over the OTLP protocol (the standard OpenTelemetry protocol
used by many monitoring system vendors) with the help of the HTTP
protocol.prometheus: Exports metrics over the
built-in HTTP server and publishes them on the /metrics
page in the format of Prometheus monitoring system.
prometheus is used by default because it does not require
additional configuration.Plugins are internal components of a receiver responsible for
collecting various types of statistical data. Each plugin is designed to
collect specific information, which is then converted into metric
groups. pgpro-otel-collector provides metric groups that
describe various subsystems, events, and processes within the database
management system (DBMS), such as table and index usage, background
processes, resource usage by queries, and more.
The amount of statistical data may vary depending on the Postgres Pro
version and edition. This adds up to variability and complexity of
collection methods. Another important role of
pgpro-otel-collector is to abstract these differences from
monitoring systems while providing comprehensive information about the
database.
The postgrespro receiver includes the following
plugins:
pg_buffercache extension).pg_wait_sampling
extension).Each of these plugins can provide dozens of types of metrics.
Depending on the number of objects in the instance, there may be
thousands of metrics. However, some metrics or even metric groups may
not be needed. Therefore, pgpro-otel-collector allows for
the disabling of selected plugins, enabling control over the amount and
quality of collected data.
For pgpro-otel-collector to operate correctly, the
following requirements should be met:
pgpro-otel-collector must be able to connect to a
Postgres Pro instance. Connection settings are defined in the
configuration file and can be modified as needed.procfs file system may
be required for operating system metric collection.Note that at the moment, a single instance of
pgpro-otel-collector supports data collection from a single
database instance only.
pgpro-otel-collector supports the following PostgreSQL
and Postgres Pro versions and editions:
pgpro-otel-collector is installed from the Postgres Pro
software repository. To install the repository, download and run the
script pgpro-repo-add.sh.pgpro-otel-collector package.Example for Debian/Ubuntu Linux 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
pgpro-otel-collector is installed, ensure that
the configuration file /etc/pgpro-otel-collector/basic.yml
contains valid connection parameters and the required set of plugins.
Then start pgpro-otel-collector:# systemctl start pgpro-otel-collector
pgpro-otel-collector will automatically start collecting
and sending data according to the settings in the configuration
file.
The main configuration file is located in
/etc/pgpro-otel-collector/basic.yml and is used by default.
The file contains settings for pgpro-otel-collector
internal components and a minimal set of plugins. It is assumed that
with this minimal set, pgpro-otel-collector will always be
able to collect information from any supported version of Postgres Pro.
In the directory
/usr/share/doc/pgpro-otel-collector/examples, you can find
additional configuration files to enable other plugins. Before enabling
any plugins, ensure that statistics are available on the database
instance side. Note that enabling extra plugins can lead to high
overhead (data collection costs) and should be considered carefully.
The postgrespro receiver settings can be divided into
the following groups:
pgpro-otel-collector uses the address
localhost:5432, the database postgres and the
user postgres to connect. If necessary, these connection
parameters can be overridden.The otlphttp exporter is not used by default, because it
requires additional configuration like specifying the monitoring system
address where the information should be sent.
Services are the internal parts of pgpro-otel-collector
responsible for its internal functions.
pgpro-otel-collector uses the following services:
telemetry: The telemetry services track
pgpro-otel-collector activity, including logging and
publishing internal metrics using the built-in HTTP server.pipelines: The pipeline services are responsible for
data processing. Their task is to build chains of receivers and
exporters, where receivers will collect data and transfer it to
exporters, who will then provide the data to external consumers.Use the below commands to display system details.
pgpro-otel-collector status:# systemctl status pgpro-otel-collector
pgpro-otel-collector activity logs:# journalctl -u pgpro-otel-collector
Logging level can be controlled by the
service.telemetry.logs.level parameter and can take the
following values: debug, info (default),
warn, error.