Skip to content

Commit

Permalink
Add pool_size and max_connections (#27)
Browse files Browse the repository at this point in the history
Signed-off-by: Nikita <errowsf@gmail.com>
  • Loading branch information
Tearix authored Mar 25, 2024
1 parent fa4ec82 commit a5497c0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions internal/collector/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,22 @@ func buildMetrics(cfg config.Config) []metric {
return results
},
},
{
enabled: cfg.ExportDatabases,
name: fqName(SubsystemDatabases, "pool_size"),
help: "Maximum number of server connections.",
labels: []string{"name", "pool_mode"},
valType: prometheus.GaugeValue,
eval: func(res *storeResult) (results []metricResult) {
for _, database := range res.databases {
results = append(results, metricResult{
labels: []string{database.Name, database.PoolMode},
value: float64(database.PoolSize),
})
}
return results
},
},
{
enabled: cfg.ExportDatabases,
name: fqName(SubsystemDatabases, "current_connections"),
Expand All @@ -248,6 +264,22 @@ func buildMetrics(cfg config.Config) []metric {
return results
},
},
{
enabled: cfg.ExportDatabases,
name: fqName(SubsystemDatabases, "max_connections"),
help: "Maximum number of allowed connections for this database.",
labels: []string{"name", "pool_mode"},
valType: prometheus.GaugeValue,
eval: func(res *storeResult) (results []metricResult) {
for _, database := range res.databases {
results = append(results, metricResult{
labels: []string{database.Name, database.PoolMode},
value: float64(database.MaxConnections),
})
}
return results
},
},
{
enabled: cfg.ExportLists,
name: fqName(SubsystemLists, "items"),
Expand Down

0 comments on commit a5497c0

Please sign in to comment.