Skip to content

Commit

Permalink
Update README.md (#1038)
Browse files Browse the repository at this point in the history
Better example for the quick start with prometheus config and avoiding deprecated env variables.

Signed-off-by: fhackenberger <florian@hackenberger.at>
  • Loading branch information
fhackenberger authored Jul 6, 2024
1 parent 49f66e1 commit 3c5ef40
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,29 @@ docker run --net=host -it --rm -e POSTGRES_PASSWORD=password postgres
# Connect to it
docker run \
--net=host \
-e DATA_SOURCE_NAME="postgresql://postgres:password@localhost:5432/postgres?sslmode=disable" \
-e DATA_SOURCE_URI="localhost:5432/postgres?sslmode=disable" \
-e DATA_SOURCE_USER=postgres \
-e DATA_SOURCE_PASS=password \
quay.io/prometheuscommunity/postgres-exporter
```

Test with:
```bash
curl "http://localhost:9187/metrics"
```

Example Prometheus config:
```yaml
scrape_configs:
- job_name: postgres
static_configs:
- 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
```
Now use the DATA_SOURCE_PASS_FILE with a mounted file containing the password to prevent having the password in an environment variable.
The container process runs with uid/gid 65534 (important for file permissions).
## Multi-Target Support (BETA)
**This Feature is in beta and may require changes in future releases. Feedback is welcome.**
Expand Down Expand Up @@ -208,7 +227,7 @@ The following environment variables configure the exporter:
* `DATA_SOURCE_URI`
an alternative to `DATA_SOURCE_NAME` which exclusively accepts the hostname
without a username and password component. For example, `my_pg_hostname` or
`my_pg_hostname?sslmode=disable`.
`my_pg_hostname:5432/postgres?sslmode=disable`.

* `DATA_SOURCE_URI_FILE`
The same as above but reads the URI from a file.
Expand Down

0 comments on commit 3c5ef40

Please sign in to comment.