Skip to content

Commit 3c5ef40

Browse files
Update README.md (#1038)
Better example for the quick start with prometheus config and avoiding deprecated env variables. Signed-off-by: fhackenberger <[email protected]>
1 parent 49f66e1 commit 3c5ef40

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

README.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,29 @@ docker run --net=host -it --rm -e POSTGRES_PASSWORD=password postgres
1717
# Connect to it
1818
docker run \
1919
--net=host \
20-
-e DATA_SOURCE_NAME="postgresql://postgres:password@localhost:5432/postgres?sslmode=disable" \
20+
-e DATA_SOURCE_URI="localhost:5432/postgres?sslmode=disable" \
21+
-e DATA_SOURCE_USER=postgres \
22+
-e DATA_SOURCE_PASS=password \
2123
quay.io/prometheuscommunity/postgres-exporter
2224
```
2325

26+
Test with:
27+
```bash
28+
curl "http://localhost:9187/metrics"
29+
```
30+
31+
Example Prometheus config:
32+
```yaml
33+
scrape_configs:
34+
- job_name: postgres
35+
static_configs:
36+
- targets: ["127.0.0.1:9187"] # Replace IP with the hostname of the docker container if you're running the container in a separate network
37+
```
38+
39+
Now use the DATA_SOURCE_PASS_FILE with a mounted file containing the password to prevent having the password in an environment variable.
40+
41+
The container process runs with uid/gid 65534 (important for file permissions).
42+
2443
## Multi-Target Support (BETA)
2544
**This Feature is in beta and may require changes in future releases. Feedback is welcome.**
2645
@@ -208,7 +227,7 @@ The following environment variables configure the exporter:
208227
* `DATA_SOURCE_URI`
209228
an alternative to `DATA_SOURCE_NAME` which exclusively accepts the hostname
210229
without a username and password component. For example, `my_pg_hostname` or
211-
`my_pg_hostname?sslmode=disable`.
230+
`my_pg_hostname:5432/postgres?sslmode=disable`.
212231

213232
* `DATA_SOURCE_URI_FILE`
214233
The same as above but reads the URI from a file.

0 commit comments

Comments
 (0)