#prometheus #exporter #metrics #pgx


Rust extension for exporting prometheus metrics

1 unstable release

0.0.1-alpha Feb 6, 2023

#875 in HTTP server

MIT license

139 lines

Postgres Extension to Export Promtheus Metrics


Developer Setup

If you have not already ran this on your machine, run it now:

cargo pgx init

Enable autoloading of the extension. Note, data-14 refers to the configuration for Postgres version 14. If you are using a different version, replace data-14 with the appropriate configuration name, e.g. data-13 for Postgres 13.

echo "shared_preload_libraries = 'prometheus_exporter.so'" >> ~/.pgx/data-14/postgresql.conf

Compile and run the extension on Postgres 14. This will start Postgres on port 28814. A metrics server will be running on localhost:8080.

cargo pgx run pg14

Scrape Prometheus metrics:

curl localhost:8080/metrics
# HELP pg_uptime Postgres server uptime.
# TYPE pg_uptime gauge
pg_uptime{} 57


Runs tests:

cargo pgx test


~1M SLoC