Commit 76650e60 by Marcus Efraimsson Committed by GitHub

Image Rendering: New setting to control render request concurrency (#23950)

Fixes #23806

Co-Authored-By: Torkel Ödegaard <torkel@grafana.com>
Co-Authored-By: Arve Knudsen <arve.knudsen@gmail.com>
parent 14de3db2
...@@ -683,6 +683,9 @@ container_name = ...@@ -683,6 +683,9 @@ container_name =
server_url = server_url =
# If the remote HTTP image renderer service runs on a different server than the Grafana server you may have to configure this to a URL where Grafana is reachable, e.g. http://grafana.domain/. # If the remote HTTP image renderer service runs on a different server than the Grafana server you may have to configure this to a URL where Grafana is reachable, e.g. http://grafana.domain/.
callback_url = callback_url =
# Concurrent render request limit affects when the /render HTTP endpoint is used. Rendering many images at the same time can overload the server,
# which this setting can help protect against by only allowing a certain amount of concurrent requests.
concurrent_render_request_limit = 30
[panels] [panels]
# here for to support old env variables, can remove after a few months # here for to support old env variables, can remove after a few months
......
...@@ -673,6 +673,9 @@ ...@@ -673,6 +673,9 @@
;server_url = ;server_url =
# If the remote HTTP image renderer service runs on a different server than the Grafana server you may have to configure this to a URL where Grafana is reachable, e.g. http://grafana.domain/. # If the remote HTTP image renderer service runs on a different server than the Grafana server you may have to configure this to a URL where Grafana is reachable, e.g. http://grafana.domain/.
;callback_url = ;callback_url =
# Concurrent render request limit affects when the /render HTTP endpoint is used. Rendering many images at the same time can overload the server,
# which this setting can help protect against by only allowing a certain amount of concurrent requests.
;concurrent_render_request_limit = 30
[panels] [panels]
# If set to true Grafana will allow script tags in text panels. Not recommended as it enable XSS vulnerabilities. # If set to true Grafana will allow script tags in text panels. Not recommended as it enable XSS vulnerabilities.
......
...@@ -822,6 +822,11 @@ URL to a remote HTTP image renderer service, e.g. http://localhost:8081/render, ...@@ -822,6 +822,11 @@ URL to a remote HTTP image renderer service, e.g. http://localhost:8081/render,
If the remote HTTP image renderer service runs on a different server than the Grafana server you may have to configure this to a URL where Grafana is reachable, e.g. http://grafana.domain/. If the remote HTTP image renderer service runs on a different server than the Grafana server you may have to configure this to a URL where Grafana is reachable, e.g. http://grafana.domain/.
### concurrent_render_request_limit
Concurrent render request limit affects when the /render HTTP endpoint is used. Rendering many images at the same time can overload the server,
which this setting can help protect against by only allowing a certain amount of concurrent requests.
## [panels] ## [panels]
### disable_sanitize_html ### disable_sanitize_html
......
...@@ -52,7 +52,6 @@ func (hs *HTTPServer) RenderToPng(c *models.ReqContext) { ...@@ -52,7 +52,6 @@ func (hs *HTTPServer) RenderToPng(c *models.ReqContext) {
headers["Accept-Language"] = acceptLanguageHeader headers["Accept-Language"] = acceptLanguageHeader
} }
maxConcurrentLimitForApiCalls := 30
result, err := hs.RenderService.Render(c.Req.Context(), rendering.Opts{ result, err := hs.RenderService.Render(c.Req.Context(), rendering.Opts{
Width: width, Width: width,
Height: height, Height: height,
...@@ -63,7 +62,7 @@ func (hs *HTTPServer) RenderToPng(c *models.ReqContext) { ...@@ -63,7 +62,7 @@ func (hs *HTTPServer) RenderToPng(c *models.ReqContext) {
Path: c.Params("*") + queryParams, Path: c.Params("*") + queryParams,
Timezone: queryReader.Get("tz", ""), Timezone: queryReader.Get("tz", ""),
Encoding: queryReader.Get("encoding", ""), Encoding: queryReader.Get("encoding", ""),
ConcurrentLimit: maxConcurrentLimitForApiCalls, ConcurrentLimit: hs.Cfg.RendererConcurrentRequestLimit,
DeviceScaleFactor: scale, DeviceScaleFactor: scale,
Headers: headers, Headers: headers,
}) })
......
...@@ -241,8 +241,7 @@ type Cfg struct { ...@@ -241,8 +241,7 @@ type Cfg struct {
ImagesDir string ImagesDir string
RendererUrl string RendererUrl string
RendererCallbackUrl string RendererCallbackUrl string
RendererLimit int RendererConcurrentRequestLimit int
RendererLimitAlerting int
// Security // Security
DisableInitAdminCreation bool DisableInitAdminCreation bool
...@@ -938,6 +937,8 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error { ...@@ -938,6 +937,8 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
log.Fatal(4, "Invalid callback_url(%s): %s", cfg.RendererCallbackUrl, err) log.Fatal(4, "Invalid callback_url(%s): %s", cfg.RendererCallbackUrl, err)
} }
} }
cfg.RendererConcurrentRequestLimit = renderSec.Key("concurrent_render_request_limit").MustInt(30)
cfg.ImagesDir = filepath.Join(cfg.DataPath, "png") cfg.ImagesDir = filepath.Join(cfg.DataPath, "png")
cfg.TempDataLifetime = iniFile.Section("paths").Key("temp_data_lifetime").MustDuration(time.Second * 3600 * 24) cfg.TempDataLifetime = iniFile.Section("paths").Key("temp_data_lifetime").MustDuration(time.Second * 3600 * 24)
cfg.MetricsEndpointEnabled = iniFile.Section("metrics").Key("enabled").MustBool(true) cfg.MetricsEndpointEnabled = iniFile.Section("metrics").Key("enabled").MustBool(true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment