{"id":19236865,"url":"https://github.com/crunchydata/postgresql-prometheus-adapter","last_synced_at":"2026-03-08T23:31:11.941Z","repository":{"id":38823120,"uuid":"204086611","full_name":"CrunchyData/postgresql-prometheus-adapter","owner":"CrunchyData","description":"Remote storage adapter enabling Prometheus to use PostgreSQL as a long-term store for time-series metrics.","archived":false,"fork":false,"pushed_at":"2024-01-22T11:14:40.000Z","size":24,"stargazers_count":82,"open_issues_count":7,"forks_count":22,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-01T10:35:50.844Z","etag":null,"topics":["postgresql","prometheus","timeseries"],"latest_commit_sha":null,"homepage":"https://www.crunchydata.com/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CrunchyData.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-24T00:11:49.000Z","updated_at":"2025-01-12T02:17:59.000Z","dependencies_parsed_at":"2024-06-18T22:48:57.997Z","dependency_job_id":"d6ee2cb5-0891-4028-8555-2fd13259129c","html_url":"https://github.com/CrunchyData/postgresql-prometheus-adapter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrunchyData%2Fpostgresql-prometheus-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrunchyData%2Fpostgresql-prometheus-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrunchyData%2Fpostgresql-prometheus-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrunchyData%2Fpostgresql-prometheus-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CrunchyData","download_url":"https://codeload.github.com/CrunchyData/postgresql-prometheus-adapter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250002305,"owners_count":21359091,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["postgresql","prometheus","timeseries"],"created_at":"2024-11-09T16:23:45.769Z","updated_at":"2026-03-08T23:31:11.882Z","avatar_url":"https://github.com/CrunchyData.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PostgreSQL Prometheus Adapter\n\nRemote storage adapter enabling Prometheus to use PostgreSQL as a long-term store for time-series metrics. Code is based on [Prometheus - Remote storage adapter](https://github.com/prometheus/prometheus/tree/master/documentation/examples/remote_storage/remote_storage_adapter).\n\nThe PostgreSQL Prometheus Adapter is designed to utilize native partitioning enhancements available in recent versions of core PostgreSQL to efficiently store Prometheus time series data in a PostgreSQL database, and is not dependent on external PostgreSQL extensions.\n\nThe design is based on partitioning and threads. Incoming data is processed by one or more threads and one or more writer threads will store data in PostgreSQL daily or hourly partitions. Partitions will be auto-created by the adapter based on the timestamp of incoming data.\n\nThe PostgreSQL Prometheus Adapter accepts Prometheus remote read/write requests, and sends them to PostgreSQL.\n\nAdditional information regarding the adapter and getting started is provided below and available in this [blog post introducing the PostgreSQL Prometheus Adapter](https://info.crunchydata.com/blog/using-postgres-to-back-prometheus-for-your-postgresql-monitoring-1).\n\n## PostgreSQL Version Support\n\nPostgreSQL Prometheus Adapter supports:\n\n* PostgreSQL 14\n* PostgreSQL 13\n* PostgreSQL 12\n* PostgreSQL 11\n\n## Building\n\n### Compile\n\n```shell\nmake\n```\n\n### Make a container (optional)\n\n```shell\nmake container\n```\n\n## Running\n\n### Running adapter\n\n```shell\nexport DATABASE_URL=...\n./postgresql-prometheus-adapter\n```\n\n#### Database Connection\n\nDATABASE_URL environment variable defines PostgreSQL connection string.\n\n```shell\nexport DATABASE_URL=...\n\n```\n\n```shell\nDefault: None\nDescription: Database connection parameters\nEx: “user=\u003c\u003e password=\u003c\u003e host=\u003c\u003e port=\u003c\u003e database=\u003c\u003e”\n```\n\n#### Adapter parameters\n\nFollowing parameters can be used to tweak adapter behavior.\n\n```shell\n./postgresql-prometheus-adapter --help\nusage: postgresql-prometheus-adapter [\u003cflags\u003e]\n\nRemote storage adapter [ PostgreSQL ]\n\nFlags:\n  -h, --help                           Show context-sensitive help (also try --help-long and --help-man).\n      --adapter-send-timeout=30s       The timeout to use when sending samples to the remote storage.\n      --web-listen-address=\":9201\"     Address to listen on for web endpoints.\n      --web-telemetry-path=\"/metrics\"  Address to listen on for web endpoints.\n      --log.level=info                 Only log messages with the given severity or above. One of: [debug, info, warn, error]\n      --log.format=logfmt              Output format of log messages. One of: [logfmt, json]\n      --pg-partition=\"hourly\"          daily or hourly partitions, default: hourly\n      --pg-commit-secs=15              Write data to database every N seconds\n      --pg-commit-rows=20000           Write data to database every N Rows\n      --pg-threads=1                   Writer DB threads to run 1-10\n      --parser-threads=5               parser threads to run per DB writer 1-10\n```\n:point_right: Note: pg_commit_secs and pg_commit_rows controls when data rows will be flushed to database. First one to reach threshold will trigger the flush.\n\n### Container\n\n#### Run container\n\n```shell\npodman run --rm \\\n  --name postgresql-prometheus-adapter \\\n  -p 9201:9201 \\\n  -e DATABASE_URL=\"user=testuser password=test123 host=192.168.12.36 port=5432 database=testdb\" \\\n  --detach \\\n  crunchydata/postgresql-prometheus-adapterl:latest\n  ```\n\n#### Stop container\n\n```shell\npodman stop postgresql-prometheus-adapter\n```\n\n#### Adapter ENV\n\nFollowing `-e NAME:VALUE` can be used to tweak adapter behavior.\n\n```shell\nadapter_send_timeout=30s       The timeout to use when sending samples to the remote storage.\nweb_listen_address=\":9201\"     Address to listen on for web endpoints.\nweb_telemetry_path=\"/metrics\"  Address to listen on for web endpoints.\nlog_level=info                 Only log messages with the given severity or above. One of: [debug, info, warn, error]\nlog_format=logfmt              Output format of log messages. One of: [logfmt, json]\npg_partition=\"hourly\"          daily or hourly partitions, default: hourly\npg_commit_secs=15              Write data to database every N seconds\npg_commit_rows=20000           Write data to database every N Rows\npg_threads=1                   Writer DB threads to run 1-10\nparser_threads=5               parser threads to run per DB writer 1-10\n```\n:point_right: Note: pg_commit_secs and pg_commit_rows controls when data rows will be flushed to database. First one to reach threshold will trigger the flush.\n\n## Prometheus Configuration\n\nAdd the following to your prometheus.yml:\n\n```yaml\nremote_write:\n    - url: \"http://\u003cip address\u003e:9201/write\"\nremote_read:\n    - url: \"http://\u003cip address\u003e:9201/read\"\n ```\n\n## Maintainers\n\nThe PostgreSQL Prometheus Adapter is maintained by the team at [Crunchy Data](https://www.crunchydata.com/).\n\n## Contributing to the Project\n\nWant to contribute to the PostgreSQL Prometheus Adapter? Great! Please use GitHub to submit an issue for the PostgreSQL Prometheus Adapter project.  If you would like to work the issue, please add that information in the issue so that we can confirm we are not already working no need to duplicate efforts.\n\n## License\n\nThe PostgreSQL Prometheus Adapter is available under the Apache 2.0 license. See [LICENSE](https://github.com/CrunchyData/postgresql-prometheus-adapter/blob/master/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrunchydata%2Fpostgresql-prometheus-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrunchydata%2Fpostgresql-prometheus-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrunchydata%2Fpostgresql-prometheus-adapter/lists"}