mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-04-17 12:35:26 +00:00
Add documentation for auto-discover-databases
This commit is contained in:
parent
58043f72da
commit
4d96104c10
@ -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`
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user