Skip to content

Commit d75d2ea

Browse files
authored
Add support for enabling verbose logging using environment variable (#105)
Verbose rendering logging have been possible to enable only thru configuration file and when running in remote rendering setup. This adds support for enabling verbose logging using environment variable for both plugin and service mode.
1 parent 3452f40 commit d75d2ea

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ Change the listening port of the gRPC server. Default is `0` and will automatica
6767
GF_RENDERER_PLUGIN_GRPC_PORT=50059
6868
```
6969

70+
**Verbose logging:**
71+
72+
Instruct headless Chrome whether to capture and log verbose information when rendering an image. Default is `false` and will only capture and log error messages. When enabled, `true`, debug messages are captured and logged as well.
73+
74+
For the verbose information to be included in the Grafana server log you have to adjust the rendering log level to `debug`, see [Troubleshoot image rendering](https://grafana.com/docs/grafana/latest/administration/image_rendering/#troubleshoot-image-rendering) for instructions.
75+
76+
```bash
77+
GF_RENDERER_PLUGIN_VERBOSE_LOGGING=true
78+
```
79+
7080
## Remote Rendering Using Docker
7181

7282
Instead of installing and running the image renderer as a plugin, you can run it as a remote image rendering service using Docker. Read more about [remote rendering using Docker](https://github.com/grafana/grafana-image-renderer/blob/master/docs/remote_rendering_using_docker.md).

docs/remote_rendering_using_docker.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ You can override certain settings by using environment variables.
1313
Change the listening host of the HTTP server. Default is unset and will use the local host.
1414

1515
```bash
16-
export HTTP_HOST=localhost
16+
HTTP_HOST=localhost
1717
```
1818

1919
**HTTP port:**
2020

2121
Change the listening port of the HTTP server. Default is `8081`. Setting `0` will automatically assign a port not in use.
2222

2323
```bash
24-
export HTTP_PORT=0
24+
HTTP_PORT=0
2525
```
2626

2727
**Default timezone:**
2828

2929
Instruct headless Chrome to use a default timezone when not provided by Grafana, .e.g. when rendering panel image of alert. See [ICU’s metaZones.txt](https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1) for a list of supported timezone IDs. Fallbacks to `TZ` environment variable if not set.
3030

3131
```bash
32-
export BROWSER_TZ=Europe/Stockholm
32+
BROWSER_TZ=Europe/Stockholm
3333
```
3434

3535
**Ignore HTTPS errors:**
@@ -38,24 +38,33 @@ Instruct headless Chrome whether to ignore HTTPS errors during navigation. Per d
3838
Due to the security risk it's not recommended to ignore HTTPS errors.
3939

4040
```bash
41-
export IGNORE_HTTPS_ERRORS=true
41+
IGNORE_HTTPS_ERRORS=true
4242
```
4343

4444
**Enable Prometheus metrics:**
4545

4646
You can enable [Prometheus](https://prometheus.io/) metrics endpoint `/metrics` using the environment variable `ENABLE_METRICS`. Node.js and render request duration metrics are included, see [output example](#prometheus-metrics-endpoint-output-example) for details.
4747

4848
```bash
49-
export ENABLE_METRICS=true
49+
ENABLE_METRICS=true
5050
```
5151

5252
**Log level:**
5353

5454
Change the log level. Default is `info` and will include log messages with level `error`, `warning` and info.
5555

56+
```bash
57+
LOG_LEVEL=debug
58+
```
59+
60+
**Verbose logging:**
61+
62+
Instruct headless Chrome whether to capture and log verbose information when rendering an image. Default is `false` and will only capture and log error messages. When enabled (`true`) debug messages are captured and logged as well.
63+
64+
Note that you need to change log level to `debug`, see above, for the verbose information to be included in the logs.
5665

5766
```bash
58-
export LOG_LEVEL=info
67+
RENDERING_VERBOSE_LOGGING=true
5968
```
6069

6170
## Configuration file

src/app.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ function populatePluginConfigFromEnv(config: PluginConfig, env: NodeJS.ProcessEn
8484
if (env['GF_RENDERER_PLUGIN_CHROME_BIN']) {
8585
config.rendering.chromeBin = env['GF_RENDERER_PLUGIN_CHROME_BIN'];
8686
}
87+
88+
if (env['GF_RENDERER_PLUGIN_VERBOSE_LOGGING']) {
89+
config.rendering.verboseLogging = env['GF_RENDERER_PLUGIN_VERBOSE_LOGGING'] === 'true';
90+
}
8791
}
8892

8993
function populateServiceConfigFromEnv(config: ServiceConfig, env: NodeJS.ProcessEnv) {
@@ -128,4 +132,8 @@ function populateServiceConfigFromEnv(config: ServiceConfig, env: NodeJS.Process
128132
if (env['RENDERING_CLUSTERING_MAX_CONCURRENCY']) {
129133
config.rendering.clustering.maxConcurrency = parseInt(env['RENDERING_CLUSTERING_MAX_CONCURRENCY'] as string, 10);
130134
}
135+
136+
if (env['RENDERING_VERBOSE_LOGGING']) {
137+
config.rendering.verboseLogging = env['RENDERING_VERBOSE_LOGGING'] === 'true';
138+
}
131139
}

0 commit comments

Comments
 (0)