Nomploy Nomad Packs

← All packs

postgres-exporter v0.1.0

Observability

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.

nomad-pack run postgres-exporter --registry nomploy
1 task http 9187 image quay.io/prometheuscommunity/postgres-exporter:latest
Variables 8
values.hcl

Save as values.hcl, edit, then run:

nomad-pack run postgres-exporter -f values.hcl --registry nomploy
# 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
  }
NameTypeDefaultDescription
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.
Readme

postgres-exporter

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.

Deploy

nomad-pack registry add nomploy https://github.com/Nomploy/nomad-packs
nomad-pack run postgres-exporter --registry=nomploy

Configure

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".

Scrape

- job_name: postgres
  static_configs:
    - targets: ['127.0.0.1:9187']