mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-04-26 13:08:01 +00:00
Merge c44e907a00
into 2ce65c324c
This commit is contained in:
commit
887f64b6ff
@ -224,6 +224,9 @@ The following environment variables configure the exporter:
|
|||||||
the default legacy format. Accepts URI form and key=value form arguments. The
|
the default legacy format. Accepts URI form and key=value form arguments. The
|
||||||
URI may contain the username and password to connect with.
|
URI may contain the username and password to connect with.
|
||||||
|
|
||||||
|
* `DATA_SOURCE_NAME_FILE`
|
||||||
|
The same as above but reads the URI from a file.
|
||||||
|
|
||||||
* `DATA_SOURCE_URI`
|
* `DATA_SOURCE_URI`
|
||||||
an alternative to `DATA_SOURCE_NAME` which exclusively accepts the hostname
|
an alternative to `DATA_SOURCE_NAME` which exclusively accepts the hostname
|
||||||
without a username and password component. For example, `my_pg_hostname` or
|
without a username and password component. For example, `my_pg_hostname` or
|
||||||
|
@ -124,6 +124,16 @@ func getDataSources() ([]string, error) {
|
|||||||
return strings.Split(dsn, ","), nil
|
return strings.Split(dsn, ","), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dataSourceNameFile := os.Getenv("DATA_SOURCE_NAME_FILE")
|
||||||
|
if len(dataSourceNameFile) != 0 {
|
||||||
|
fileContents, err := ioutil.ReadFile(dataSourceNameFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed loading data source name file %s: %s", dataSourceNameFile, err.Error())
|
||||||
|
}
|
||||||
|
dsnContent := strings.TrimSpace(string(fileContents))
|
||||||
|
return strings.Split(dsnContent, ","), nil
|
||||||
|
}
|
||||||
|
|
||||||
var user, pass, uri string
|
var user, pass, uri string
|
||||||
|
|
||||||
dataSourceUserFile := os.Getenv("DATA_SOURCE_USER_FILE")
|
dataSourceUserFile := os.Getenv("DATA_SOURCE_USER_FILE")
|
||||||
|
Loading…
Reference in New Issue
Block a user