Live: Add configuration for client_queue_max_size (#114225)

Live: add configuration for client_queue_max_size
This commit is contained in:
Gareth 2025-11-20 20:08:26 +09:00 committed by GitHub
parent 6e9a33e712
commit 0efffd9ec8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 1 deletions

View file

@ -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 =

View file

@ -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.

View file

@ -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

View file

@ -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":