Using TimescaleDB to store Prometheus data

You can persist prometheus metrics into timescaledb with promscale.

You can use postgres as the remote storage database used by the Prometheus backend.

While this is not the recommended behavior, it is a good opportunity to understand how the Pigsty deployment system is used.

Preparing the Postgres database

vi pigsty.yml # Uncomment DB/User definition: dbuser_prometheus prometheus

pg_databases:                           # define business users/roles on this cluster, array of user definition
  - { name: prometheus, owner: dbuser_prometheus , revokeconn: true, comment: prometheus primary database }
pg_users:                           # define business users/roles on this cluster, array of user definition
  - {name: dbuser_prometheus , password: DBUser.Prometheus ,pgbouncer: true , createrole: true,  roles: [dbrole_admin], comment: admin user for prometheus database }

Create a Prometheus business database with business users.

bin/createuser  pg-meta  dbuser_prometheus
bin/createdb    pg-meta  prometheus

Check database availability and create extensions。

psql postgres://dbuser_prometheus:DBUser.Prometheus@ -c 'CREATE EXTENSION timescaledb;'

Configure Promscale

Install promscale by executing the following command on the meta node

yum install -y promscale 

If not available in the default package, you can directly download it.

sudo rpm -ivh promscale_0.6.1_Linux_x86_64.rpm

Edit the promscale config file /etc/sysconfig/promscale.conf.


Finally start promscale, which will access the database instance with timescaledb installed and create the required schema.

# launch 
cat /usr/lib/systemd/system/promscale.service
systemctl start promscale && systemctl status promscale

Configure Prometheus

Prometheus can use Remote Write/ Remote Read via Promscale, using Postgres as remote storage.

Edit Prometheus config file.

vi /etc/prometheus/prometheus.yml

Add the following record.

  - url: ""
  - url: ""

After restarting Prometheus, the monitoring data can be placed in Postgres.

systemctl restart prometheus

Last modified 2022-06-03: add scaffold for en docs (6a6eded)