Skip to content

Commit 2908189

Browse files
committed
fix: set sensible defaults
1 parent 345f51f commit 2908189

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

cmd/postgres_exporter/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ var (
5757
excludeDatabases = kingpin.Flag("exclude-databases", "A list of databases to remove when autoDiscoverDatabases is enabled (DEPRECATED)").Default("").Envar("PG_EXPORTER_EXCLUDE_DATABASES").String()
5858
includeDatabases = kingpin.Flag("include-databases", "A list of databases to include when autoDiscoverDatabases is enabled (DEPRECATED)").Default("").Envar("PG_EXPORTER_INCLUDE_DATABASES").String()
5959
metricPrefix = kingpin.Flag("metric-prefix", "A metric prefix can be used to have non-default (not \"pg\") prefixes for each of the metrics").Default("pg").Envar("PG_EXPORTER_METRIC_PREFIX").String()
60-
maxOpenConnections = kingpin.Flag("max-connections", "the maximum number of opened connections").Default("-1").Envar("PG_MAX_CONNECTIONS").Int()
61-
maxIdleConnections = kingpin.Flag("max-idle-connections", "the maximum number of idle connections").Default("-1").Envar("PG_MAX_IDLE_CONNECTIONS").Int()
60+
maxOpenConnections = kingpin.Flag("max-connections", "the maximum number of opened connections").Default("10").Envar("PG_MAX_CONNECTIONS").Int()
61+
maxIdleConnections = kingpin.Flag("max-idle-connections", "the maximum number of idle connections").Default("5").Envar("PG_MAX_IDLE_CONNECTIONS").Int()
6262
collectorTimeout = kingpin.Flag("collector-timeout", "the single collector scrape timeout").Default("10s").Envar("PG_COLLECTOR_TIMEOUT").Duration()
6363
logger = log.NewNopLogger()
6464
)

cmd/postgres_exporter/postgres_exporter.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,12 @@ func NewExporter(dsn []string, opts ...ExporterOpt) *Exporter {
540540
}
541541

542542
e.setupInternalMetrics()
543-
e.servers = NewServers(ServerWithLabels(e.constantLabels))
543+
e.servers = NewServers(
544+
ServerWithLabels(e.constantLabels),
545+
ServerWithMaxIdleConnections(*maxIdleConnections),
546+
ServerWithMaxOpenConnections(*maxOpenConnections),
547+
ServerWithScrapeTimeout(e.scrapeTimeout),
548+
)
544549

545550
return e
546551
}

0 commit comments

Comments
 (0)