timescale / prometheus-postgresql-adapter

Use PostgreSQL as a remote storage database for Prometheus
Apache License 2.0
335 stars 66 forks source link

How can read metrics data from timescaledb(pg_prometheus) and pass it to prometheus via prometheus-postgresql-adapter #81

Open keshav1git opened 5 years ago

keshav1git commented 5 years ago
+--------------------+                  +----------------------+                    +------------------+
|                    |                  |      prometheus      |                    |     pg_prometheus|
|      prometheus    |   <-----------+  |      postgres        |  <-------------+   |                  |
|                    |                  |      adapter         |                    |                  |
|                    |                  +----------------------+                    +------------------+
+--------------------+

reference : link

spolcyn commented 5 years ago

You can either make queries in Prometheus using PromQL (the adapter handles pulling extra data from pg_prometheus to Prometheus, if necessary), or you can make queries in SQL directly on pg_prometheus using a tool like psql. Does that help?

ctwyw commented 5 years ago

@spolcyn It only works on write . But when do some PromQL, I can`t find any read query in prometheus_postgresql_adapter. Is there a mistake in setting it? Both of them were in the docker

remote_write:
    - url: "http://prometheus_postgresql_adapter:9201/write"
remote_read:
    - url: "http://prometheus_postgresql_adapter:9201/read"
spolcyn commented 5 years ago

To confirm, you see data in pg_prometheus that you can query locally using SQL, but when you use the Prometheus web interface and PromQL, no results come up?

bboule commented 5 years ago

So I think I can help here... You can query your metrics in the TimescaleDB instance using standard SQL and connecting to PostgreSQL host where you have both the pg_prometheus extension running and timescaledb the data is forwarded to the timescale instance through the adapter, making the data available in the PostgreSQL database, this would be your long term storage. If you wanted to run a PromQL query you would run that against the Prometheus server (by default this server will retain 15 days of data). Let us know if that helps?