Prometheus is an open-source monitoring system with a dimensional data model, flexible query language, and a modern alerting approach.

This page shows you how to export your service telemetry to Prometheus using PostgreSQL Exporter.

Before integrating:

To reduce latency and potential data transfer costs, install Prometheus and PostgreSQL Exporter on a machine in the same AWS region as your Timescale Cloud service.

To export your data, do the following:

  1. Create a user to access telemetry data about your Timescale Cloud service

    1. Connect to your Timescale Cloud service:

      For Timescale Cloud, open an SQL editor in Timescale Console. For self-hosted, use psql.

    2. Create a user named monitoring with a secure password:

      CREATE USER monitoring WITH PASSWORD '<password>';
    3. Grant the pg_read_all_stats permission to the monitoring user:

      GRANT pg_read_all_stats to monitoring;
  2. Import telemetry data about your Timescale Cloud service to PostgreSQL Exporter

    1. Connect PostgreSQL Exporter to your Timescale Cloud service:

      Use your connection details to import telemetry data about your Timescale Cloud service. You connect as the monitoring user:

      • Local installation:
        export DATA_SOURCE_NAME="postgres://monitoring:<password>@<host>.tsdb.cloud.timescale.com:<port>/tsdb?sslmode=require"
        ./postgres_exporter
      • Docker:
        docker run -d \
        -e DATA_SOURCE_NAME="postgres://monitoring:<password>@<host>.tsdb.cloud.timescale.com:<port>/tsdb?sslmode=require" \
        -p 9187:9187 \
        prometheuscommunity/postgres-exporter
    2. Check the metrics for your Timescale Cloud service in the Prometheus format:

      • Browser:

        Navigate to http://<exporter-host>:9187/metrics.

      • Command line:

        curl http://<exporter-host>:9187/metrics
  3. Configure Prometheus to scrape metrics

    1. In your Prometheus installation, update prometheus.yml to point to your PostgreSQL Exporter instance as a scrape target. In the following example, you replace <exporter-host> with the hostname or IP address of the PostgreSQL Exporter.

      global:
      scrape_interval: 15s
      scrape_configs:
      - job_name: 'postgresql'
      static_configs:
      - targets: ['<exporter-host>:9187']

      If prometheus.yml has not been created during installation, create it manually. If you are using Docker, you can find the IPAddress in Inspect > Networks for the container running PostgreSQL Exporter.

    2. Restart Prometheus.

    3. Check the Prometheus UI at http://<prometheus-host>:9090/targets and http://<prometheus-host>:9090/tsdb-status.

      You see the PostgreSQL Exporter target and the metrics scraped from it.

You can further visualize your data with Grafana. Use the Grafana PostgreSQL dashboard or create a custom dashboard that suits your needs.

Keywords

Found an issue on this page?Report an issue or Edit this page in GitHub.