Add documentation for auto-discover-databases

This commit is contained in:
Arno Geurts 2019-04-16 12:03:52 +02:00 committed by Will Rouesnel
parent 58043f72da
commit 4d96104c10
2 changed files with 6 additions and 1 deletions

View File

@ -161,6 +161,11 @@ or a variant of postgres (e.g. Greenplum) you can disable the default metrics wi
flag. This removes all built-in metrics, and uses only metrics defined by queries in the `queries.yaml` file you supply flag. This removes all built-in metrics, and uses only metrics defined by queries in the `queries.yaml` file you supply
(so you must supply one, otherwise the exporter will return nothing but internal statuses and not your database). (so you must supply one, otherwise the exporter will return nothing but internal statuses and not your database).
### Automatically discover databases
To scrape metrics from all databases on a database server, the database DSN's can be dynamically discovered via the
`--auto-discover-databases` flag. When true, `SELECT datname FROM pg_database` is run for all configured DSN's. From the
result a new set of DSN's is created for which the metrics are scraped.
### Running as non-superuser ### Running as non-superuser
To be able to collect metrics from `pg_stat_activity` and `pg_stat_replication` To be able to collect metrics from `pg_stat_activity` and `pg_stat_replication`

View File

@ -1064,7 +1064,7 @@ func newDesc(subsystem, name, help string, labels prometheus.Labels) *prometheus
} }
func queryDatabases(server *Server) ([]string, error) { func queryDatabases(server *Server) ([]string, error) {
rows, err := server.db.Query("SELECT datname FROM pg_database;") // nolint: safesql rows, err := server.db.Query("SELECT datname FROM pg_database") // nolint: safesql
if err != nil { if err != nil {
return nil, fmt.Errorf("Error retrieving databases: %v", err) return nil, fmt.Errorf("Error retrieving databases: %v", err)
} }