Prometheus Postgres Exporter — scrapes a PostgreSQL server and exposes database, table, and replication metrics for Prometheus. Deployed as a stateless host-networked Nomad service; point it at any reachable Postgres via a DSN. Pairs with the postgres and monitoring packs.
Save as values.hcl, edit, then run:
# The name of the Nomad job.
job_name = "postgres-exporter"
# The Nomad namespace to deploy into.
namespace = "default"
# The datacenters to deploy to.
datacenters = ["*"]
# The Prometheus Postgres Exporter image. Pin a tag in production.
image = "quay.io/prometheuscommunity/postgres-exporter:latest"
# Host port for the exporter (/metrics).
port = 9187
# Postgres DSN the exporter connects to (DATA_SOURCE_NAME). Use a read-only monitoring role in production. With host networking a co-located postgres pack is reachable on 127.0.0.1.
data_source_name = "postgresql://postgres:postgres@127.0.0.1:5432/postgres?sslmode=disable"
# Placement constraints. On a nomploy cluster: attribute = "$${meta.nomploy_control_plane}", operator = "=", value = "true".
constraints = []
# The task resources.
resources = {
cpu = 200
memory = 64
}
| Name | Type | Default | Description |
|---|---|---|---|
| job_name | string | "postgres-exporter" | The name of the Nomad job. |
| namespace | string | "default" | The Nomad namespace to deploy into. |
| datacenters | list | ["*"] | The datacenters to deploy to. |
| image | string | "quay.io/prometheuscommunity/postgres-exporter:latest" | The Prometheus Postgres Exporter image. Pin a tag in production. |
| port | number | 9187 | Host port for the exporter (/metrics). |
| data_source_name | string | "postgresql://postgres:postgres@127.0.0.1:5432/postgres?sslmode=disable" | Postgres DSN the exporter connects to (DATA_SOURCE_NAME). Use a read-only monitoring role in production. With host networking a co-located postgres pack is reachable on 127.0.0.1. |
| constraints | list | [] | Placement constraints. On a nomploy cluster: attribute = "$${meta.nomploy_control_plane}", operator = "=", value = "true". |
| resources | object | {
cpu = 200
memory = 64
} | The task resources. |
No variables match.
Prometheus Postgres Exporter — scrapes a PostgreSQL server and exposes database, table, index, and replication metrics for Prometheus.
Stateless, host-networked Nomad service. Point it at any reachable Postgres with a DSN; with
host networking a co-located postgres pack is on 127.0.0.1.
nomad-pack registry add nomploy https://github.com/Nomploy/nomad-packs
nomad-pack run postgres-exporter --registry=nomploy
| Variable | Default | Description |
|---|---|---|
port |
9187 |
Host port for /metrics. |
data_source_name |
postgresql://postgres:postgres@127.0.0.1:5432/postgres?sslmode=disable |
Postgres DSN (DATA_SOURCE_NAME). |
image |
quay.io/prometheuscommunity/postgres-exporter:latest |
Exporter image. Pin a tag in production. |
resources |
{ cpu = 200, memory = 64 } |
Task resources. |
Use a read-only monitoring role rather than a superuser:
CREATE USER pg_exporter WITH PASSWORD '...';
GRANT pg_monitor TO pg_exporter;
Then set data_source_name = "postgresql://pg_exporter:...@127.0.0.1:5432/postgres?sslmode=disable".
- job_name: postgres
static_configs:
- targets: ['127.0.0.1:9187']