Plugins 〉Grafana Image Renderer


Developer
Grafana Labs


Sign up to receive occasional product news and updates:



Renderer
grafana

Grafana Image Renderer

  • Overview
  • Installation
  • Change log
  • Related content

A Grafana backend plugin that handles rendering panels and dashboards to PNGs using a headless browser (Chromium).

Requirements

Supported operating systems

  • Linux (x64)
  • Windows (x64)
  • Mac OS X (x64)

Dependencies

This plugin is packaged in a single executable with Node.js runtime and Chromium browser. This means that you don't need to have Node.js and Chromium installed in your system for the plugin to function.

However, the Chromium browser depends on certain libraries. If you don't have all of those libraries installed in your system, you may see some errors when you try to render an image. For more information including troubleshooting help, refer to Grafana Image Rendering documentation.

Memory requirements

Rendering images requires a lot of memory, mainly because Grafana creates browser instances in the background for the actual rendering. We recommend a minimum of 16GB of free memory on the system rendering images.

Rendering multiple images in parallel requires an even bigger memory footprint. You can use the remote rendering service in order to render images on a remote system, so your local system resources are not affected.

Plugin installation

You can install the plugin using Grafana CLI (recommended way) or with Grafana Docker image.

Grafana CLI (recommended)

grafana-cli plugins install grafana-image-renderer

Grafana Docker image

This plugin is not compatible with the current Grafana Docker image and requires additional system-level dependencies. We recommend setting up another Docker container for rendering and using remote rendering instead. For instruction, refer to Run in Docker.

If you still want to install the plugin with the Grafana Docker image, refer to the instructions on building a custom Grafana image in Grafana Docker documentation.

Remote rendering service installation

Note: Requires an internet connection.

You can run this plugin as a remote HTTP rendering service. In this setup, Grafana renders an image by making an HTTP request to the remote rendering service, which in turn renders the image and returns it back in the HTTP response to Grafana.

You can run the remote HTTP rendering service using Docker or as a standalone Node.js application.

Run in Docker

Grafana Docker images are published at Docker Hub.

The following example shows how you can run Grafana and the remote HTTP rendering service in two separate Docker containers using Docker Compose.

  1. Create a docker-compose.yml with the following content:

    version: '2'
    

    services: grafana: image: grafana/grafana:latest ports: - ‘3000:3000’ environment: GF_RENDERING_SERVER_URL: http://renderer:8081/render GF_RENDERING_CALLBACK_URL: http://grafana:3000/ GF_LOG_FILTERS: rendering:debug renderer: image: grafana/grafana-image-renderer:latest ports: - 8081

  2. Next, run docker compose.

    docker-compose up
    

Run as standalone Node.js application

The following example describes how to build and run the remote HTTP rendering service as a standalone Node.js application and configure Grafana appropriately.

  1. Clone the Grafana image renderer plugin Git repository.

  2. Install dependencies and build:

    yarn install --pure-lockfile
    yarn run build
    
  3. Run the server:

    node build/app.js server --port=8081
    
  4. Update Grafana configuration:

    [rendering]
    server_url = http://localhost:8081/render
    callback_url = http://localhost:3000/
    
  5. Restart Grafana.

Security

Access to the rendering endpoints is restricted to requests providing an auth token. This token should be configured in the Grafana configuration file and the renderer configuration file. This token is important when you run the plugin in remote rendering mode to avoid unauthorized file disclosure (see CVE-2022-31176).

See Grafana Image Rendering documentation to configure this secret token. The default value - is configured on both Grafana and the image renderer when you get started but we strongly recommend you to update this to a more secure value.

Configuration

For available configuration settings, please refer to Grafana Image Rendering documentation.

Troubleshooting

For troubleshooting help, refer to Grafana Image Rendering troubleshooting documentation.

Testing

In order to run the image-renderer automated test suites, you need to run the following command from the root folder:

yarn test

This will launch a Grafana instance in Docker and, then, run the test suites.

Notes:

If there are some expected changes in the reference image files (located in /tests/testdata), run yarn test-update and push the updated references.

If the tests are failing and you want to see the difference between the image you get and the reference image, run yarn test-diff. This will generate images (called diff_<test case>.png) containing the differences in the /tests/testdata folder.

Fixing Drone issues

If tests are successful in your local environement but fail in Drone. You can follow these steps to run the tests in an environment similar to the Drone pipeline. This will mount your local files of the grafana-image-renderer repo in the Docker image so any change that happens in the Docker image will be available in your local environment. This allows you to run yarn test-diff and yarn test-update in Docker and see the results locally.

  1. Run the Drone environment in Docker:
cd ./devenv/docker/drone
docker-compose up
  1. Open a terminal within the drone-docker-puppeteer container and run the following commands:
cd /drone/src
PUPPETEER_CACHE_DIR=/drone/src/cache yarn install --frozen-lockfile --no-progress
PUPPETEER_CACHE_DIR=/drone/src/cache CI=true yarn test-ci

Notes: The tests might take longer in the Docker container. If you run into timeout issues, you can run the test command with the --testTimeout option:

PUPPETEER_CACHE_DIR=/drone/src/cache CI=true yarn test-ci --testTimeout=10000

Installing Grafana Image Renderer on Grafana Cloud:

For more information, visit the docs on plugin installation.

3.10.1 (2024-03-07)

3.10.0 (2024-02-20)

  • WaitingForPanels: Change waiting logic for Scenes #496, torkelo
  • Experimental: Support PDF rendering #487, ryantxu

3.9.1 (2024-01-29)

3.9.0 (2023-12-04)

3.8.4 (2023-10-17)

3.8.3 (2023-09-29)

3.8.2 (2023-09-21)

  • Browser: Revert to old headless mode to fix usage with Kubernetes #459, AgnesToulet

3.8.1 (2023-09-18)

3.8.0 (2023-08-22)

3.7.2 (2023-07-27)

3.7.1 (2023-05-15)

3.7.0 (2023-04-17)

3.6.4 (2023-02-10)

3.6.3 (2023-01-11)

3.6.2 (2022-10-22)

  • Log errors related to JSHandle@object as debug #376, spinillos
  • Chore: Update Puppeteer deprecated functions #375, spinillos
  • Fix: Update _client with _client() to avoid to fail when creating a CSV #372, spinillos
  • Chore: Update all dependencies #369, DanCech

3.6.1 (2022-08-30)

3.6.0 (2022-08-16)

3.5.0 (2022-07-18)

3.4.2 (2022-03-23)

3.4.1 (2022-02-23)

  • Fix: replace sharp with jimp to resolve issues with installing native dependencies #325, ArturWierzbicki

3.4.0 (2022-02-17)

3.3.0 (2021-11-18)

3.2.1 (2021-10-07)

3.2.0 (2021-09-17)

  • Docs: Update documentation to improve visibility and avoid duplicates with Grafana documentation #277, AgnesToulet
  • Instrumentation: Update grafana_image_renderer_step_duration_seconds buckets #287, AgnesToulet
  • Security: Bump chokidar from 3.5.1 to 3.5.2 #284, AgnesToulet
  • Instrumentation: Add gauge of total number of requests in flight #281, AgnesToulet
  • Security: Bump axios from 0.21.1 to 0.21.4 #283, dependabot[bot]
  • Chore: Add self-contained setup for load test #275, pianohacker

3.1.0 (2021-09-01)

Important change

The default Chromium flags have been updated to include --disable-gpu as it fixes memory leaks issues when using the default rendering mode. If you don't want to use this flag, you need to update your service configuration, either through the service configuration file, the environment variables or the Grafana configuration file (if you're using the plugin mode).

3.0.1 (2021-06-10)

  • Browser: Fix panel timezone when the timezone query parameter is specified #224, Bujupah
  • Docker: Fix version endpoint for Docker images #248, mbentley

3.0.0 (2021-06-07)

3.0.0-beta2 (2021-05-26)

3.0.0-beta1 (2021-05-19)

2.1.1 (2021-05-18)

2.1.0 (2021-05-11)

  • Chore/Security: Upgrade dependencies and bump Node to LTS (14.16.1) #218, AgnesToulet

2.0.1 (2021-01-26)

  • Browser: Use timeout parameter for initial navigation to the dashboard being rendered #171,

2.0.0 (2020-05-16)

  • Plugin: Migrate to @grpc/grpc-js to resolve problems when IPv6 is disabled #135, aknuds1
  • Adds support for new Grafana backend plugin system #128, marefr
  • Browser: Adds support for setting viewport device scale factor #128, marefr
  • Browser: Adds support for attaching Accept-Language header to support render is name locale as Grafana user #128, marefr
  • Browser: Fail render if the URL has socket protocol #127, aknuds1
  • Chore: Upgrade typescript dependencies #129, marefr

2.0.0-beta1 (2020-04-22)

  • Adds support for new Grafana backend plugin system #128, marefr
  • Browser: Adds support for setting viewport device scale factor #128, marefr
  • Browser: Adds support for attaching Accept-Language header to support render is name locale as Grafana user #128, marefr
  • Browser: Fail render if the URL has socket protocol #127, aknuds1
  • Chore: Upgrade typescript dependencies #129, marefr

1.0.12 (2020-03-31)

  • Remote rendering: Delete temporary file after serving it to client #120, marefr
  • Remote rendering: More configuration options #123, marefr

1.0.12-beta1 (2020-03-30)

  • Remote rendering: More configuration options #123, marefr

1.0.11 (2020-03-20)

  • Render: Add support for enabling verbose logging using environment variable #105, marefr
  • Render: Fix panel titles should not be focused when rendering #114, AgnesToulet
  • Security: Upgrade minimist dependency to v1.2.5 #118, marefr

1.0.10 (2020-02-18)

  • Plugin: Fix unable to start Grafana (Windows) with version 1.0.8 and 1.0.9 #103, marefr

1.0.9 (2020-01-30)

  • Remote rendering: Improve error handling, logging and metrics #92, marefr
    • Service: Don't swallow exceptions and fix logging of parameters
    • Metrics: Use status 499 when client close the connection
    • Docker: Set NODE_ENV=production
    • Changed request logging to use debug level if status < 400 and error if >= 400
  • Plugin: Adds icon #95, marefr

1.0.8 (2020-01-20)

  • Build: Upgrade Node.js requirement to LTS (v12) #57, marefr
  • Docker: Add unifont font to support rendering other language, like Chinese/Japanese #75, okhowang
  • Subscribing to page events to catch errors from browser #88, marefr
  • Plugin: Automatically assign grpc port per default #87, marefr
  • Plugin: Support configuring default timezone thru environment variable #86, marefr
  • Remote rendering: Support configuring default timezone thru config file and environment variable #86, marefr
  • Remote rendering: Support configuring HTTP host and port thru config and environment variables #40, marefr
  • Remote rendering: Support reading config from file #73, marefr
  • Remote rendering: Collect and expose Prometheus metrics #71, marefr

Breaking changes

  • Plugin now automatically assigns gPRC port not in use. Before port 50059 was used. You can change this by using the GF_RENDERER_PLUGIN_GRPC_PORT environment variable.

1.0.8-beta1 (2019-12-17)

  • Remote rendering: Collect and expose Prometheus metrics #71, marefr
  • Build: Upgrade Node.js requirement to LTS (v12) #57, marefr

1.0.7 (2019-12-03)

  • Provide correctly named config parameter to Chromium when overriding to skip https errors using environment variable GF_RENDERER_PLUGIN_IGNORE_HTTPS_ERRORS and/or IGNORE_HTTPS_ERRORS #62, marefr

1.0.6 (2019-11-25)

  • Wait until all network connections to be idle before rendering #24, d1ff
  • Support ignoring https errors using environment variable #59, marefr
  • Docker: Update dependencies to remove vulnerabilities #53, marefr
  • Fix typo in log statement #39, ankon
  • Updated documentation

1.0.5 (2019-09-11)

  • Include md5 checksums in release artifacts

1.0.4 (2019-09-11)

  • Update readme and docs

1.0.3 (2019-09-10)

  • Automate docker release

1.0.2 (2019-09-10)

  • Don't include dist directory in archive (zip) files

1.0.1 (2019-09-09)

  • Switch docker base image from node:10 to node:alpine-10 #36, marefr
  • Updated the panel render wait function to account for Grafana version 6 #26, bmichaelis
  • Updated dependencies

1.0.0 (2019-08-16)

Initial release containing prebuilt binaries available for download. Right now the binaries themselves should be considered alpha as they need more testing.