Monitoring a Prometheus Exporter
This how-to wires pgwatch to a Prometheus text-format HTTP exporter. A common use case is Patroni, which exposes cluster-health metrics (node role, WAL position, DCS connectivity, …) on GET /metrics. The same recipe works for postgres_exporter and any other endpoint that emits the Prometheus exposition format.
For the connection-string format, query parameters, and full preset/metric tables, see Reference: Prometheus source.
Prerequisites
- A reachable Prometheus text exposition endpoint
- Network access from the pgwatch host to the exporter port
- (Optional) A CA certificate file if the exporter is served over HTTPS with a non-public CA
Steps
-
Add a source of kind
prometheus. Pointconn_strat the exporter URL and pick the right preset.For Patroni:
- name: patroni-prod-node1 kind: prometheus conn_str: "http://patroni-node1:8008/metrics" preset_metrics: patroni is_enabled: trueFor
postgres_exporter, pickpostgres-exporter-basicinstead. -
For HTTPS endpoints with a private CA, pass the CA file path via a query parameter:
-
(Optional) Attach
custom_tagsso multi-node metrics can be distinguished in Grafana: -
Wait for the next refresh cycle (default 120 seconds). pgwatch fetches the URL, parses the Prometheus text, and forwards every metric family to the sink.
Verifying metrics are flowing
List the metrics the source is producing:
You should see the metric families from the chosen preset (or your custom_metrics list).
See also
- Reference: Prometheus source — URI format, query parameters, preset/metric tables
- Reference: Source types —
prometheusvspostgresvspatroni