Skip to content

Commit 9aeff83

Browse files
authored
Merge branch 'master' into concurrency-improvements
2 parents e580e33 + 1ab8d2b commit 9aeff83

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ flag. This removes all built-in metrics, and uses only metrics defined by querie
163163

164164
### Automatically discover databases
165165
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
166+
`--auto-discover-databases` flag. When true, `SELECT datname FROM pg_database WHERE datallowconn = true AND datistemplate = false` is run for all configured DSN's. From the
167167
result a new set of DSN's is created for which the metrics are scraped.
168168

169169
In addition, the option `--exclude-databases` adds the possibily to filter the result from the auto discovery to discard databases you do not need.

cmd/postgres_exporter/postgres_exporter.go

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

10891089
func queryDatabases(server *Server) ([]string, error) {
1090-
rows, err := server.db.Query("SELECT datname FROM pg_database") // nolint: safesql
1090+
rows, err := server.db.Query("SELECT datname FROM pg_database WHERE datallowconn = true AND datistemplate = false") // nolint: safesql
10911091
if err != nil {
10921092
return nil, fmt.Errorf("Error retrieving databases: %v", err)
10931093
}

0 commit comments

Comments
 (0)