Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for enabling verbose logging using environment variable #105

Merged
merged 2 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ Change the listening port of the gRPC server. Default is `0` and will automatica
GF_RENDERER_PLUGIN_GRPC_PORT=50059
```

**Verbose logging:**

Enable capturing verbose information when headless Chrome browses a page and takes a screenshot of it. It will capture all requests initiated and finished, when page is closed and any non-error logged to the console. These are logged as debug messages. Default is `false` and will only capture errors when page crashes, uncaught exception thrown in page, page request fails or error logged to the console.
oddlittlebird marked this conversation as resolved.
Show resolved Hide resolved

```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:**
marefr marked this conversation as resolved.
Show resolved Hide resolved

Enable capturing verbose information when headless Chrome browses a page and takes a screenshot of it. It will capture all requests initiated and finished, when page is closed and any non-error logged to the console. These are logged as debug messages. Default is `false` and will only capture errors when page crashes, uncaught exception thrown in page, page request fails or error logged to the console.

Note that you need to change log level to `debug` for the verbose output to be seen in the logs.
oddlittlebird marked this conversation as resolved.
Show resolved Hide resolved

```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';
}
}