Skip to content

Commit

Permalink
Add support for enabling verbose logging using environment variable (g…
Browse files Browse the repository at this point in the history
…rafana#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.
  • Loading branch information
marefr authored Mar 19, 2020
1 parent 3452f40 commit d75d2ea
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ Change the listening port of the gRPC server. Default is `0` and will automatica
GF_RENDERER_PLUGIN_GRPC_PORT=50059
```

**Verbose logging:**

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.

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.

```bash
GF_RENDERER_PLUGIN_VERBOSE_LOGGING=true
```

## Remote Rendering Using Docker

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).
Expand Down
21 changes: 15 additions & 6 deletions docs/remote_rendering_using_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ You can override certain settings by using environment variables.
Change the listening host of the HTTP server. Default is unset and will use the local host.

```bash
export HTTP_HOST=localhost
HTTP_HOST=localhost
```

**HTTP port:**

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

```bash
export HTTP_PORT=0
HTTP_PORT=0
```

**Default timezone:**

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.

```bash
export BROWSER_TZ=Europe/Stockholm
BROWSER_TZ=Europe/Stockholm
```

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

```bash
export IGNORE_HTTPS_ERRORS=true
IGNORE_HTTPS_ERRORS=true
```

**Enable Prometheus metrics:**

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.

```bash
export ENABLE_METRICS=true
ENABLE_METRICS=true
```

**Log level:**

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

```bash
LOG_LEVEL=debug
```

**Verbose logging:**

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.

Note that you need to change log level to `debug`, see above, for the verbose information to be included in the logs.

```bash
export LOG_LEVEL=info
RENDERING_VERBOSE_LOGGING=true
```

## Configuration file
Expand Down
8 changes: 8 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ function populatePluginConfigFromEnv(config: PluginConfig, env: NodeJS.ProcessEn
if (env['GF_RENDERER_PLUGIN_CHROME_BIN']) {
config.rendering.chromeBin = env['GF_RENDERER_PLUGIN_CHROME_BIN'];
}

if (env['GF_RENDERER_PLUGIN_VERBOSE_LOGGING']) {
config.rendering.verboseLogging = env['GF_RENDERER_PLUGIN_VERBOSE_LOGGING'] === 'true';
}
}

function populateServiceConfigFromEnv(config: ServiceConfig, env: NodeJS.ProcessEnv) {
Expand Down Expand Up @@ -128,4 +132,8 @@ function populateServiceConfigFromEnv(config: ServiceConfig, env: NodeJS.Process
if (env['RENDERING_CLUSTERING_MAX_CONCURRENCY']) {
config.rendering.clustering.maxConcurrency = parseInt(env['RENDERING_CLUSTERING_MAX_CONCURRENCY'] as string, 10);
}

if (env['RENDERING_VERBOSE_LOGGING']) {
config.rendering.verboseLogging = env['RENDERING_VERBOSE_LOGGING'] === 'true';
}
}

0 comments on commit d75d2ea

Please sign in to comment.