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:
Create a target Timescale Cloud service. You need your connection details to follow this procedure.
This procedure also works for self-hosted TimescaleDB.
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:
Create a user to access telemetry data about your Timescale Cloud service
Connect to your Timescale Cloud service:
For Timescale Cloud, open an SQL editor in Timescale Console. For self-hosted, use
psql
.Create a user named
monitoring
with a secure password:CREATE USER monitoring WITH PASSWORD '<password>';Grant the
pg_read_all_stats
permission to themonitoring
user:GRANT pg_read_all_stats to monitoring;
Import telemetry data about your Timescale Cloud service to PostgreSQL Exporter
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
- Local installation:
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
Configure Prometheus to scrape metrics
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: 15sscrape_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 inInspect
>Networks
for the container running PostgreSQL Exporter.Restart Prometheus.
Check the Prometheus UI at
http://<prometheus-host>:9090/targets
andhttp://<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.