Skip to main content
Version Next

PostgreSQL Metrics Exporter Configuration

The PostgreSQL Metrics Exporter collects information such as transactions, query latency, memory usage by processes, database usage statistics, among others. It helps administrators monitor the health and performance of their PostgreSQL instances, facilitating optimizations and adjustments.

This configuration allows defining the port used to expose PostgreSQL metrics for Prometheus collection.

warning

To perform this operation, PgSmart automatically creates the "PgSmart" user on monitored PostgreSQL instances. If preferred, this operation can be performed manually. To do so, follow these steps:

  1. Connect to the desired PostgreSQL instance.

  2. Execute the following command to create the PgSmart user:

    Terminal input
       CREATE USER pgsmart ENCRYPTED PASSWORD 'QWEpgTecSmartnisysRTY';
  3. Execute the following command to grant the pg_monitor role (read and execute monitoring views and functions privileges only) to the pgsmart user:

    Terminal input
       GRANT pg_monitor TO pgsmart;

The PostgreSQL Metrics Exporter can be configured regardless of the PgSmart user’s existence. However, metric exportation will only start once the user exists with proper privileges on the monitored instance.

Prerequisites
Command Syntax
Terminal input
   pgsmart obs exporter config [Flags]

Flags:

  • -a, --agent=<agent> Alias, hostname or IP of the server where the desired PgSmart Agent is installed.
  • -h, --help Help
Non-Interactive Configuration

Non-interactive execution is disabled for this operation.

Interactive Configuration
Terminal input
   pgsmart obs exporter config

PostgreSQL Metrics Exporter Configuration

Manual Creation of Access User

  1. Select the PgSmart Agent or Register a new one.

  2. Select the Exportador de Métricas PostgreSQL option.

  3. Select the instance's Data Directory (PGDATA) (or add the desired Data Directory).

  4. Confirm whether you want PgSmart to create the access user:

    4.1. Enter the PostgreSQL superuser name. 4.2. Enter the PostgreSQL superuser password.

    note

    The provided credentials are not stored by PgSmart. They are used only for the creation of the access user and are handled only in memory.

  5. Set the metrics exposure port and web interface.

  6. Confirm whether you want to add more PostgreSQL instances.

    Figure 1 - PostgreSQL Metrics Exporter Configuration
    Figure 1 - PostgreSQL Metrics Exporter Configuration
    note

    Metrics can be viewed through the console:

    Terminal input
       curl http://192.168.56.235:9100/metrics

    Or through the web interface:

    http://192.168.56.235:9100/metrics