File tree 1 file changed +21
-2
lines changed
1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,29 @@ docker run --net=host -it --rm -e POSTGRES_PASSWORD=password postgres
17
17
# Connect to it
18
18
docker run \
19
19
--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 \
21
23
quay.io/prometheuscommunity/postgres-exporter
22
24
```
23
25
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
+
24
43
## Multi-Target Support (BETA)
25
44
**This Feature is in beta and may require changes in future releases. Feedback is welcome.**
26
45
@@ -208,7 +227,7 @@ The following environment variables configure the exporter:
208
227
* `DATA_SOURCE_URI`
209
228
an alternative to `DATA_SOURCE_NAME` which exclusively accepts the hostname
210
229
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` .
212
231
213
232
* `DATA_SOURCE_URI_FILE`
214
233
The same as above but reads the URI from a file.
You can’t perform that action at this time.
0 commit comments