diff --git a/conf/defaults.ini b/conf/defaults.ini index 77bc39c9feb..125c748326c 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -1959,6 +1959,10 @@ max_connections = 100 # The limit can be disabled by setting it to -1. message_size_limit = 8388608 +# client_queue_max_size is the maximum size in bytes of the client queue +# for Live connections. Defaults to 4MB. +client_queue_max_size = 4194304 + # allowed_origins is a comma-separated list of origins that can establish connection with Grafana Live. # If not set then origin will be matched over root_url. Supports wildcard symbol "*". allowed_origins = diff --git a/conf/sample.ini b/conf/sample.ini index eea46ccaacb..3944ea20940 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -1903,6 +1903,10 @@ default_datasource_uid = # ha_prefix is a prefix for keys in the HA engine. It's used to separate keys for different Grafana instances. ;ha_prefix = +# client_queue_max_size is the maximum size in bytes of the client queue +# for Live connections. Defaults to 4MB. +;client_queue_max_size = + #################################### Grafana Image Renderer Plugin ########################## [plugin.grafana-image-renderer] # Instruct headless browser instance to use a default timezone when not provided by Grafana, e.g. when rendering panel image of alert. diff --git a/pkg/services/live/live.go b/pkg/services/live/live.go index 93f3e5211f2..4d91eae3e5e 100644 --- a/pkg/services/live/live.go +++ b/pkg/services/live/live.go @@ -120,7 +120,7 @@ func ProvideService(plugCtxProvider *plugincontext.Provider, cfg *setting.Cfg, r Metrics: centrifuge.MetricsConfig{ MetricsNamespace: "grafana_live", }, - ClientQueueMaxSize: 4194304, // 4MB + ClientQueueMaxSize: cfg.LiveClientQueueMaxSize, // Use reasonably large expiration interval for stream meta key, // much bigger than maximum HistoryLifetime value in Node config. // This way stream meta data will expire, in some cases you may want diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 885ea5703ec..fb69aa60259 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -480,6 +480,9 @@ type Cfg struct { // LiveMessageSizeLimit is the maximum size in bytes of Websocket messages // from clients. Defaults to 64KB. LiveMessageSizeLimit int + // LiveClientQueueMaxSize is the maximum size in bytes of the client queue + // for Live connections. Defaults to 4MB. + LiveClientQueueMaxSize int // Grafana.com URL, used for OAuth redirect. GrafanaComURL string @@ -2066,6 +2069,11 @@ func (cfg *Cfg) readLiveSettings(iniFile *ini.File) error { if cfg.LiveMessageSizeLimit < -1 { return fmt.Errorf("unexpected value %d for [live] message_size_limit", cfg.LiveMaxConnections) } + cfg.LiveClientQueueMaxSize = section.Key("client_queue_max_size").MustInt(4194304) + if cfg.LiveClientQueueMaxSize <= 0 { + return fmt.Errorf("unexpected value %d for [live] client_queue_max_size", cfg.LiveMaxConnections) + } + cfg.LiveHAEngine = section.Key("ha_engine").MustString("") switch cfg.LiveHAEngine { case "", "redis":