Database metrics
This commit is contained in:
parent
3da182212e
commit
7c4e01e5c4
|
@ -6,6 +6,7 @@ import (
|
|||
"regexp"
|
||||
|
||||
"github.com/matrix-org/dendrite/setup/config"
|
||||
"github.com/prometheus/client_golang/prometheus/collectors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
@ -47,5 +48,6 @@ func Open(dbProperties *config.DatabaseOptions, writer Writer) (*sql.DB, error)
|
|||
db.SetMaxIdleConns(dbProperties.MaxIdleConns())
|
||||
db.SetConnMaxLifetime(dbProperties.ConnMaxLifetime())
|
||||
}
|
||||
collectors.NewDBStatsCollector(db, fmt.Sprintf("dendrite_%s", dbProperties.Name))
|
||||
return db, nil
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ func (c *FederationAPI) Defaults(opts DefaultOpts) {
|
|||
c.InternalAPI.Listen = "http://localhost:7772"
|
||||
c.InternalAPI.Connect = "http://localhost:7772"
|
||||
c.ExternalAPI.Listen = "http://[::]:8072"
|
||||
c.Database.Name = "federation_api"
|
||||
c.Database.Defaults(10)
|
||||
}
|
||||
c.FederationMaxRetries = 16
|
||||
|
|
|
@ -96,6 +96,7 @@ func (c *Global) Defaults(opts DefaultOpts) {
|
|||
}
|
||||
c.KeyValidityPeriod = time.Hour * 24 * 7
|
||||
if opts.Monolithic {
|
||||
c.DatabaseOptions.Name = "global"
|
||||
c.DatabaseOptions.Defaults(90)
|
||||
}
|
||||
c.JetStream.Defaults(opts)
|
||||
|
@ -237,6 +238,8 @@ func (c *Sentry) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
|||
}
|
||||
|
||||
type DatabaseOptions struct {
|
||||
// Which database is this? For use in prometheus collectors.
|
||||
Name string `json:"-"`
|
||||
// The connection string, file:filename.db or postgres://server....
|
||||
ConnectionString DataSource `yaml:"connection_string"`
|
||||
// Maximum open connections to the DB (0 = use default, negative means unlimited)
|
||||
|
|
|
@ -12,6 +12,7 @@ func (c *KeyServer) Defaults(opts DefaultOpts) {
|
|||
if !opts.Monolithic {
|
||||
c.InternalAPI.Listen = "http://localhost:7779"
|
||||
c.InternalAPI.Connect = "http://localhost:7779"
|
||||
c.Database.Name = "keyserver"
|
||||
c.Database.Defaults(10)
|
||||
}
|
||||
if opts.Generate {
|
||||
|
|
|
@ -43,6 +43,7 @@ func (c *MediaAPI) Defaults(opts DefaultOpts) {
|
|||
c.InternalAPI.Listen = "http://localhost:7774"
|
||||
c.InternalAPI.Connect = "http://localhost:7774"
|
||||
c.ExternalAPI.Listen = "http://[::]:8074"
|
||||
c.Database.Name = "media_api"
|
||||
c.Database.Defaults(5)
|
||||
}
|
||||
c.MaxFileSizeBytes = DefaultMaxFileSizeBytes
|
||||
|
|
|
@ -15,6 +15,7 @@ type MSCs struct {
|
|||
|
||||
func (c *MSCs) Defaults(opts DefaultOpts) {
|
||||
if !opts.Monolithic {
|
||||
c.Database.Name = "mscs"
|
||||
c.Database.Defaults(5)
|
||||
}
|
||||
if opts.Generate {
|
||||
|
|
|
@ -12,6 +12,7 @@ func (c *RoomServer) Defaults(opts DefaultOpts) {
|
|||
if !opts.Monolithic {
|
||||
c.InternalAPI.Listen = "http://localhost:7770"
|
||||
c.InternalAPI.Connect = "http://localhost:7770"
|
||||
c.Database.Name = "roomserver"
|
||||
c.Database.Defaults(20)
|
||||
}
|
||||
if opts.Generate {
|
||||
|
|
|
@ -18,6 +18,7 @@ func (c *SyncAPI) Defaults(opts DefaultOpts) {
|
|||
c.InternalAPI.Listen = "http://localhost:7773"
|
||||
c.InternalAPI.Connect = "http://localhost:7773"
|
||||
c.ExternalAPI.Listen = "http://localhost:8073"
|
||||
c.Database.Name = "sync_api"
|
||||
c.Database.Defaults(20)
|
||||
}
|
||||
c.Fulltext.Defaults(opts)
|
||||
|
|
|
@ -27,6 +27,7 @@ func (c *UserAPI) Defaults(opts DefaultOpts) {
|
|||
if !opts.Monolithic {
|
||||
c.InternalAPI.Listen = "http://localhost:7781"
|
||||
c.InternalAPI.Connect = "http://localhost:7781"
|
||||
c.AccountDatabase.Name = "user_api"
|
||||
c.AccountDatabase.Defaults(10)
|
||||
}
|
||||
c.BCryptCost = bcrypt.DefaultCost
|
||||
|
|
Loading…
Reference in a new issue