Use PostgreSQL as a remote storage database for Prometheus
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
log
postgresql Fix SQL injection bugs Jan 2, 2019
util Monitor Prometheus liveness when PgAdvisoryLock is used Sep 27, 2018
.gitignore Insert metric labels only if they are not already present to prevent … Oct 17, 2018
.travis.yml Run tests for all packages. Ensure golang/dep is present. Add Travis CI Jul 24, 2018
Dockerfile Add Docker build and Makefile May 17, 2017
Gopkg.lock Insert metric labels only if they are not already present to prevent … Oct 17, 2018
Gopkg.toml Switch to Dep for dependency management Mar 19, 2018
LICENSE Add LICENSE Jul 18, 2017
Makefile Fix test compile issue. Don't run integration tests by default. Aug 8, 2018
README.md Update README.md Sep 5, 2018
main.go Add support for using an adapter with read replica Sep 28, 2018
sample-docker-prometheus.yml Readme changes Jul 18, 2017

README.md

Prometheus remote storage adapter for PostgreSQL

With this remote storage adapter, Prometheus can use PostgreSQL as a long-term store for time-series metrics.

Related packages to install:

Quick start

You can download pre-built binaries here

Docker instructions

A docker image for the prometheus-postgreSQL storage adapter is available on Docker Hub at timescale/prometheus-postgresql-adapter.

The easiest way to use this image is in conjunction with the pg_prometheus docker image provided by Timescale. This image packages PostgreSQL, pg_prometheus, and TimescaleDB together in one docker image.

To run this image use:

docker run --name pg_prometheus -d -p 5432:5432 timescale/pg_prometheus:master postgres \
      -csynchronous_commit=off

Then, start the prometheus-postgreSQL storage adapter using:

 docker run --name prometheus_postgresql_adapter --link pg_prometheus -d -p 9201:9201 \
 timescale/prometheus-postgresql-adapter:master \
 -pg.host=pg_prometheus \
 -pg.prometheus-log-samples

Finally, you can start Prometheus with:

docker run -p 9090:9090 --link prometheus_postgresql_adapter -v /path/to/prometheus.yml:/etc/prometheus/prometheus.yml \
       prom/prometheus

(a sample prometheus.yml file can be found in sample-docker-prometheus.yml in this repository).

Configuring Prometheus to use this remote storage adapter

You must tell prometheus to use this remote storage adapter by adding the following lines to prometheus.yml:

remote_write:
  - url: "http://<adapter-address>:9201/write"
remote_read:
  - url: "http://<adapter-address>:9201/read"

Building

Before building, make sure the following prerequisites are installed:

  • Dep for dependency management.
  • Go

Then build as follows:

# Install dependencies (only required once)
dep ensure

# Build binary
make

Building new Docker images

# Build Docker image
make docker-image

# Push to Docker registry (requires permission)
make docker-push ORGANIZATION=myorg 

Contributing

We welcome contributions to this adaptor, which like TimescaleDB is released under the Apache2 Open Source License. The same Contributors Agreement applies; please sign the Contributor License Agreement (CLA) if you're a new contributor.