Skip to main content
Version 4.1.0

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, the user "pgsmart_metrics" must exist in the PostgreSQL instances where it will be configured.

  • The user can be created during the Metrics Exporter Configuration process, by providing a superuser for the database instance and its respective access password.

    • It is also possible to create the user manually, through the following commands:

      1. Connect to the desired PostgreSQL instance.

      2. Run the command below to create the user pgsmart_metrics without access privileges to tables and user data:

        Terminal input
           CREATE USER pgsmart_metrics ENCRYPTED PASSWORD <value of the metrics_password parameter>;
      3. Run the command below to grant the pg_monitor role (only privileges to read and execute monitoring views and functions) to the pgsmart_metrics user:

        Terminal input
           GRANT pg_monitor TO pgsmart_metrics;
    • This information will NOT be stored and will only be used during the configuration operation.

  • The PostgreSQL Metrics Exporter will be configured whether or not the pgsmart_metrics user exists. However, metric export will only start once this user exists, with the appropriate privileges, in the monitored PostgreSQL instance.

note

The pgsmart_metrics user password can be changed in PgSmart Web or in PgSmart Cli, using the metrics_password parameter.

important

The instance password will not be changed. It is the responsibility of the DBA/Administrator to change it, since the Agent does not have access credentials to perform this action.

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

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

  2. Select the PostgreSQL Metrics Exporter.

  3. Select the network interface for connection.

  4. Select the Data Directory (PGDATA) of the PostgreSQL instance (or add the desired Data Directory).

  5. Confirm whether you want PgSmart to create the access user.
    5.1. Provide the superuser of the PostgreSQL instance.
    5.2. Provide the password of the PostgreSQL instance superuser.

    note

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

  6. Provide the metrics exposure port and web interface.

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

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

    The exported metrics can be viewed via the console:

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

    Or via the web interface:

    Terminal input
       http://192.168.56.235:9100/metrics