Skip to content

Commit 38ae043

Browse files
author
Mike Holloway
committed
initial commit
0 parents  commit 38ae043

13 files changed

+8458
-0
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# swarmstack/postgresql-exporter
2+
3+
Docker compose file for postgres-exporter, Prometheus configuration example, and Grafana Dashboard for PostgreSQL servers
4+
5+
6+
## USAGE
7+
8+
```
9+
docker stack deploy -c docker-compose.yml postgresql-exporters
10+
```
11+
12+
[swarmstack](https://github.com/swarmstack/swarmstack) users should use docker-compose-swarmstack.yml above instead.
13+
14+
---
15+
16+
In the prometheus/ directory in this repo, you'll find example Prometheus configurations to scrape the exporters once per 5 minutes as to not induce extra load on your servers. If your PG servers aren't heavily loaded, you can scrape them at whatever interval you like.
17+
18+
In the grafana/ directory you'll find a Grafana 6.0+ dashboard that uses information from the postgres-exporter plus netdata to give you a full view of your PostgreSQL hosts.

bounce

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
./down
4+
sleep 5
5+
./up

bounce-swarmstack

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
./down
4+
sleep 5
5+
./up-swarmstack

docker-compose-swarmstack.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
version: '3.5'
2+
3+
networks:
4+
default:
5+
external: true
6+
name: swarmstack_net
7+
8+
configs:
9+
10+
postgres_exporter_config:
11+
file: ./queries.yaml
12+
13+
#postgres92_exporter_config:
14+
# file: ./queries92.yaml
15+
16+
services:
17+
18+
# Example for PostgreSQL 9.4 or later host
19+
postgres-exporter-pgserver94:
20+
image: wrouesnel/postgres_exporter:latest
21+
configs:
22+
- source: postgres_exporter_config
23+
target: /etc/postgres_exporter/queries.yaml
24+
deploy:
25+
# recommend static scrape target rather than swarm-discovery via labels below so that you can scrape less often
26+
#labels:
27+
# prometheus.enable: "true"
28+
# prometheus.port: "9187"
29+
# prometheus.path: "/metrics"
30+
mode: replicated
31+
replicas: 1
32+
environment:
33+
- DATA_SOURCE_NAME=postgresql://[email protected]:5432/postgres?sslmode=disable
34+
- PG_EXPORTER_EXTEND_QUERY_PATH=/etc/postgres_exporter/queries.yaml
35+
36+
# Example for older PostgreSQL 9.2
37+
#postgres-exporter-pgserver92:
38+
# image: wrouesnel/postgres_exporter:latest
39+
# configs:
40+
# - source: postgres92_exporter_config
41+
# target: /etc/postgres_exporter/queries.yaml
42+
# deploy:
43+
# # recommend static scrape target rather than swarm-discovery via labels below so that you can scrape less often
44+
# #labels:
45+
# # prometheus.enable: "true"
46+
# # prometheus.port: "9187"
47+
# # prometheus.path: "/metrics"
48+
# mode: replicated
49+
# replicas: 1
50+
# environment:
51+
# - DATA_SOURCE_NAME=postgresql://[email protected]:5432/postgres?sslmode=disable
52+
# - PG_EXPORTER_EXTEND_QUERY_PATH=/etc/postgres_exporter/queries.yaml
53+
# - PG_EXPORTER_DISABLE_DEFAULT_METRICS=true

docker-compose.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
version: "3.4"
2+
3+
configs:
4+
5+
postgres_exporter_config:
6+
file: ./queries.yaml
7+
8+
#postgres92_exporter_config:
9+
# file: ./queries92.yaml
10+
11+
services:
12+
13+
# Example for PostgreSQL 9.4 or later host
14+
postgres-exporter-pgserver94:
15+
image: wrouesnel/postgres_exporter:latest
16+
configs:
17+
- source: postgres_exporter_config
18+
target: /etc/postgres_exporter/queries.yaml
19+
deploy:
20+
mode: replicated
21+
replicas: 1
22+
environment:
23+
- DATA_SOURCE_NAME=postgresql://[email protected]:5432/postgres?sslmode=disable
24+
- PG_EXPORTER_EXTEND_QUERY_PATH=/etc/postgres_exporter/queries.yaml
25+
26+
# Example for older PostgreSQL 9.2
27+
#postgres-exporter-pgserver92:
28+
# image: wrouesnel/postgres_exporter:latest
29+
# configs:
30+
# - source: postgres92_exporter_config
31+
# target: /etc/postgres_exporter/queries.yaml
32+
# deploy:
33+
# mode: replicated
34+
# replicas: 1
35+
# environment:
36+
# - DATA_SOURCE_NAME=postgresql://[email protected]:5432/postgres?sslmode=disable
37+
# - PG_EXPORTER_EXTEND_QUERY_PATH=/etc/postgres_exporter/queries.yaml
38+
# - PG_EXPORTER_DISABLE_DEFAULT_METRICS=true

down

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
docker stack rm postgresql-exporters

0 commit comments

Comments
 (0)