Skip to content

Commit

Permalink
Merge c1bc236 into c768e64
Browse files Browse the repository at this point in the history
  • Loading branch information
alexissellier committed Aug 12, 2019
2 parents c768e64 + c1bc236 commit 31eb2b0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ flag. This removes all built-in metrics, and uses only metrics defined by querie

### 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
`--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
result a new set of DSN's is created for which the metrics are scraped.

In addition, the option `--exclude-databases` adds the possibily to filter the result from the auto discovery to discard databases you do not need.
Expand Down
2 changes: 1 addition & 1 deletion cmd/postgres_exporter/postgres_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ func newDesc(subsystem, name, help string, labels prometheus.Labels) *prometheus
}

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 WHERE datallowconn = true AND datistemplate = false") // nolint: safesql
if err != nil {
return nil, fmt.Errorf("Error retrieving databases: %v", err)
}
Expand Down

0 comments on commit 31eb2b0

Please sign in to comment.