Skip to content

Commit 4d96104

Browse files
arnogeurts-sqillswrouesnel
authored andcommitted
Add documentation for auto-discover-databases
1 parent 58043f7 commit 4d96104

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ or a variant of postgres (e.g. Greenplum) you can disable the default metrics wi
161161
flag. This removes all built-in metrics, and uses only metrics defined by queries in the `queries.yaml` file you supply
162162
(so you must supply one, otherwise the exporter will return nothing but internal statuses and not your database).
163163

164+
### Automatically discover databases
165+
To scrape metrics from all databases on a database server, the database DSN's can be dynamically discovered via the
166+
`--auto-discover-databases` flag. When true, `SELECT datname FROM pg_database` is run for all configured DSN's. From the
167+
result a new set of DSN's is created for which the metrics are scraped.
168+
164169
### Running as non-superuser
165170

166171
To be able to collect metrics from `pg_stat_activity` and `pg_stat_replication`

cmd/postgres_exporter/postgres_exporter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ func newDesc(subsystem, name, help string, labels prometheus.Labels) *prometheus
10641064
}
10651065

10661066
func queryDatabases(server *Server) ([]string, error) {
1067-
rows, err := server.db.Query("SELECT datname FROM pg_database;") // nolint: safesql
1067+
rows, err := server.db.Query("SELECT datname FROM pg_database") // nolint: safesql
10681068
if err != nil {
10691069
return nil, fmt.Errorf("Error retrieving databases: %v", err)
10701070
}

0 commit comments

Comments
 (0)