Live: max_connections option with strict default (#34634) (#34853)

this should help Live to be enabled by default but still
do not affect setups with lots of simultenious users. To
properly handle many WS connections Grafana administrators
should tune infrastructure a bit - for example increase a
number of open files for a process. Will be in more details
in documentation.

(cherry picked from commit 6d750c000e)

Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2021-05-27 21:47:40 +02:00
committed by GitHub
co-authored by Alexander Emelin
parent f44c41fde8
commit 04741642c5
9 changed files with 50 additions and 4 deletions
+18
View File
@@ -380,6 +380,11 @@ type Cfg struct {
ExpressionsEnabled bool
ImageUploadProvider string
// LiveMaxConnections is a maximum number of WebSocket connections to
// Grafana Live ws endpoint (per Grafana server instance). 0 disables
// Live, -1 means unlimited connections.
LiveMaxConnections int
}
// IsLiveConfigEnabled returns true if live should be able to save configs to SQL tables
@@ -950,6 +955,10 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
cfg.readDateFormats()
cfg.readSentryConfig()
if err := cfg.readLiveSettings(iniFile); err != nil {
return err
}
return nil
}
@@ -1420,3 +1429,12 @@ func (cfg *Cfg) readDataSourcesSettings() {
datasources := cfg.Raw.Section("datasources")
cfg.DataSourceLimit = datasources.Key("datasource_limit").MustInt(5000)
}
func (cfg *Cfg) readLiveSettings(iniFile *ini.File) error {
section := iniFile.Section("live")
cfg.LiveMaxConnections = section.Key("max_connections").MustInt(100)
if cfg.LiveMaxConnections < -1 {
return fmt.Errorf("unexpected value %d for [live] max_connections", cfg.LiveMaxConnections)
}
return nil
}