# Grafana Image Renderer

**URL:** <https://community.openhab.org/t/grafana-image-renderer/83350>\
**Category:** Solutions\
**Tags:** charts, grafana\
**Created:** [October 9, 2019, 9:43pm UTC](https://community.openhab.org/t/grafana-image-renderer/83350 "2019-10-09T21:43:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [October 9, 2019, 9:43pm UTC](https://community.openhab.org/t/grafana-image-renderer/83350/1 "2019-10-09T21:43:08Z")

</div>

We have all had issues with Grafana generating static png charts for some time now. The root cause is PhantomJS. According to the docs on [Grafana’s website](https://grafana.com/docs/administration/image_rendering/#image-rendering):

> PhantomJS is deprecated since Grafana v6.4 and will be removed in a future release. Please migrate to Grafana image renderer plugin or remote rendering service.

For at least a year now rendering the images on an RPi has been unavailable as PhantomJS would run amok and consume all the resources until openHAB itself was killed by the kernel. As of the past couple of weeks, it appears there has been an update made where rendering the pngs using PhantomJS even on more powerful machines no longer works (perhaps they finally removed the library).

Why not just use a webview? I’ve never had good luck with webviews. Either the Android app won’t show it, or it won’t work through a reverse proxy or through [myopenhab.org](http://myopenhab.org). If I generate static images it works everywhere.

Thankfully, Grafana now provides a separate [image renderer plugin](https://grafana.com/grafana/plugins/grafana-image-renderer) for rendering charts to pngs.

# Installation

You have a few options for installing this plugin.

- If Grafana is installed on your machine, you can use grafana-cli.

- Alternatively, you can download the zip file and unpack it into the plugins folder (see the link above for the latest links to the downloads).

- Finally, you can [run the renderer as a separate service using Docker](https://github.com/grafana/grafana-image-renderer/blob/master/docs/remote_rendering_using_docker.md). This approach is handy if you want to host the render on a host separate from your Grafana instance.

I run Grafana in Docker and I tried to install the plugin but it will not work. I get the following error:

```auto
Oct 9 15:05:49 argus 1f33221f8c3a[1686]: t=2019-10-09T15:05:49-0600 lvl=eror msg="Rendering failed." logger=context userId=0 orgId=1 uname= error="Rendering failed: Error: Failed to launch chrome!\n/var/lib/grafana/plugins/grafana-image-renderer/chrome-linux/chrome: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory\n\n\nTROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md\n"
Oct 9 15:05:49 argus 1f33221f8c3a[1686]: t=2019-10-09T15:05:49-0600 lvl=eror msg="Request Completed" logger=context userId=0 orgId=1 uname= method=GET path=/render/d-solo/000000001/home-automation status=500 remote_addr=10.10.1.138 time_ms=16 size=1722 referer="http://argus:3000/d/000000001/home-automation?orgId=1"

```

So it looks like I have to host a separate container for the renderer. Instructions for doing so are located at [https://github.com/grafana/grafana-image-renderer/blob/master/docs/remote\_rendering\_using\_docker.md](https://github.com/grafana/grafana-image-renderer/blob/master/docs/remote_rendering_using_docker.md).

That provides a DockerCompose file. I use Ansible so I’ll show that below:

```yaml
- name: Pull and run latest Grafana image
  docker_container:
    detach: True
    exposed_ports:
      - "3000"
    hostname: grafana.koshak.net
    image: grafana/grafana
    log_driver: syslog
    name: grafana
    env:
      GF_USERS_ALLOW_SIGN_UP: "false"
      GF_AUTH_ANONYMOUS_ENABLED: "true"
      GF_SECURITY_ALLOW_EMBEDDING: "true"
      GF_SECURITY_COOKIE_SECURE: "true"
      GF_SECURITY_COOKIE_SAMESITE: "none"
      GF_RENDERING_SERVER_URL: "http://10.10.1.127:8081/render"
      GF_RENDERING_CALLBACK_URL: "http://10.10.1.127:3000/"
      GF_LOG_FILTERS: "rendering:debug"
    published_ports:
      - "3000:3000"
    pull: True
    restart: True
    restart_policy: always
    volumes:
      - "{{ grafana_data }}:/var/lib/grafana"
      - "/etc/localtime:/etc/localtime:ro"
      - "/etc/passwd:/etc/passwd:ro"

- name: Pull and run the latest grafana image renderer
  docker_container:
    detach: True
    exposed_ports:
      - 8081
    image: grafana/grafana-image-renderer:latest
    log_driver: syslog
    name: grafana-image-renderer
    published_ports:
        - "8081:8081"
    pull: True
    restart: True
    restart_policy: always

```

NOTE: I need to change the IP address above to use the ansible variables to make it more generic. You should use the IP address of the machine these containers are deployed to.

# Use

Just like with PhantomJS, click on the title of one of your panels in Grafana and choose “Share”

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/4/f/4f3776b79e19f9d580d3f8a6f1eb81b6132d5cea.png)

Then click on “Direct link rendered image”. See [InfluxDB+Grafana persistence and graphing](https://community.openhab.org/t/influxdb-grafana-persistence-and-graphing/13761) or the Grafana docs for details on how to fill in the URL parameters for the time periods you care about.

See [Grafana Image Charts](https://community.openhab.org/t/grafana-image-charts/77707) for a Rule that will call the URL to generate the chart images only as often as necessary based on the time period currently selected in the UI. Without something like this, Grafana will be generating the images for all the panels and all the views whether they are being used or not. Since this is an expensive operation, using this Rule will reduce the cost to the minimum.

---

<div class="post-metadata">

**Author:** ![Kim\_Andersen](https://community.openhab.org/letter_avatar_proxy/v4/letter/k/6bbea6/32.png) [@Kim\_Andersen](https://community.openhab.org/u/Kim_Andersen)\
**Post date:** [October 10, 2019, 9:33am UTC](https://community.openhab.org/t/grafana-image-renderer/83350/2 "2019-10-10T09:33:14Z")

</div>

> [@rlkoshak](#):
>
> See [Grafana Image Charts](https://community.openhab.org/t/grafana-image-charts/77707) for a Rule that will call the URL to generate the chart images only as often as necessary based on the time period currently selected in the UI. Without something like this, Grafana will be generating the images for all the panels and all the views whether they are being used or not. Since this is an expensive operation, using this Rule will reduce the cost to the minimum.

Is this new in Grafana 6.4.x and their new rendering plugin?  
I use Grafana 5.4.3 on a windows server, and I still use the phantomjs.  
I dont see any activity unless I´m on a sitemap which calls Grafana?

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [October 10, 2019, 1:34pm UTC](https://community.openhab.org/t/grafana-image-renderer/83350/3 "2019-10-10T13:34:28Z")

</div>

I don’t know how new the image renderer plugin is. Last week my charts stopped rendering, failing with a timeout. Yesterday I had a chance to look into it and their docs now state PhantomJS is deprecated and will be soon removed and to use the plugin instead. Hence this tutorial.

> [@Kim\_Andersen](#):
>
> I dont see any activity unless I´m on a sitemap which calls Grafana?

That should be completely explained in that other tutorial. The tl;dr is if you use visibility to show charts of a different period, Grafana has to generate all the images for all the time periods regardless of which one is visible. With the Rule at that link, only the charts for the time period you are actually looking at are rendered. If you have last: hour, day, week, month, and year, you will see a 4x reduction in load on Grafana using that Rule over using visibility.

---

<div class="post-metadata">

**Author:** ![Kim\_Andersen](https://community.openhab.org/letter_avatar_proxy/v4/letter/k/6bbea6/32.png) [@Kim\_Andersen](https://community.openhab.org/u/Kim_Andersen)\
**Post date:** [October 10, 2019, 4:30pm UTC](https://community.openhab.org/t/grafana-image-renderer/83350/4 "2019-10-10T16:30:59Z")

</div>

> [@rlkoshak](#):
>
> With the Rule at that link, only the charts for the time period you are actually looking at are rendered. If you have last: hour, day, week, month, and year, you will see a 4x reduction in load on Grafana using that Rule over using visibility.

Hmm okay I see your point.. Its when using several images and visibility. I have one sitemap where I have 3 charts on at the same time. Grafana render this every 30 second, but only when I´m on the sitemap.

---

<div class="post-metadata">

**Author:** ![pune2001](https://community.openhab.org/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@pune2001](https://community.openhab.org/u/pune2001)\
**Post date:** [October 12, 2019, 1:03pm UTC](https://community.openhab.org/t/grafana-image-renderer/83350/5 "2019-10-12T13:03:05Z")

</div>

When I try to install the plugin on my RPi4 through grafana-cli, I get the following error:

> Error: ✗ Plugin is not supported on your architecture and os.

I’m on openhab 2.4 and grafana 6.4.2. Is the plugin supposed to work in this environment?

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [October 12, 2019, 2:43pm UTC](https://community.openhab.org/t/grafana-image-renderer/83350/6 "2019-10-12T14:43:19Z")

</div>

It’s complaining about architecture (i.e. to if CPU) and OS (i.e. operating system, e.g. Linux). Are you on an RPi? If so it seems not to be supported.

Grafana had no knowledge of ooenHAB.

---

<div class="post-metadata">

**Author:** ![sapster77](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@sapster77](https://community.openhab.org/u/sapster77)\
**Post date:** [October 13, 2019, 8:04pm UTC](https://community.openhab.org/t/grafana-image-renderer/83350/7 "2019-10-13T20:04:51Z")

</div>

I am experiencing the issues you are describing with the kernel killing openhab when all ressources are gone. I wanted to try your guide but got the following reply :

```csv
grafana-cli plugins install grafana-image-renderer
Failed to send requesterrorApi returned invalid status: 404 Not Found
Error: ✗ Failed to send request. error: Api returned invalid status: 404 Not Found

NAME:
   Grafana cli plugins install - install <plugin id> <plugin version (optional)>

USAGE:
   Grafana cli plugins install [arguments...]

```

I then checked my Grafana version and it is 5.1.4…I have just apt updated and upgraded my system, but Grafana remains 5.1.4 - not 6.4 which is the most recent. Any idea as to why it does not upgrade and what to do?  
Running openhabian on raspberry pi 3B+

---

<div class="post-metadata">

**Author:** ![Udo\_Hartmann](https://community.openhab.org/user_avatar/community.openhab.org/udo_hartmann/32/70871_2.png) [@Udo\_Hartmann](https://community.openhab.org/u/Udo_Hartmann)\
**Post date:** [October 13, 2019, 9:51pm UTC](https://community.openhab.org/t/grafana-image-renderer/83350/8 "2019-10-13T21:51:43Z")

</div>

I may be wrong, but afaik grafana is not part of standard archives. I’m not sure about how openhabian handles grafana stuff either. Did you update openhabian-config yet?

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [October 13, 2019, 10:48pm UTC](https://community.openhab.org/t/grafana-image-renderer/83350/9 "2019-10-13T22:48:36Z")

</div>

I run Grafana in Docker so I don’t really know how openHABian installs it not how to install it using apt.

---

<div class="post-metadata">

**Author:** ![sapster77](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@sapster77](https://community.openhab.org/u/sapster77)\
**Post date:** [October 14, 2019, 6:45am UTC](https://community.openhab.org/t/grafana-image-renderer/83350/10 "2019-10-14T06:45:39Z")

</div>

yep - I updated the openhabian-config, but still the same…

---

<div class="post-metadata">

**Author:** ![Kim\_Andersen](https://community.openhab.org/letter_avatar_proxy/v4/letter/k/6bbea6/32.png) [@Kim\_Andersen](https://community.openhab.org/u/Kim_Andersen)\
**Post date:** [October 14, 2019, 7:48am UTC](https://community.openhab.org/t/grafana-image-renderer/83350/11 "2019-10-14T07:48:37Z")

</div>

> [@sapster77](#):
>
> I then checked my Grafana version and it is 5.1.4…I have just apt updated and upgraded my system, but Grafana remains 5.1.4 - not 6.4 which is the most recent. Any idea as to why it does not upgrade and what to do?

When I did the same long time ago. I noticed I had to uninstall the old Grafana, and then install the new one manually. It might be worth a try.  
Remember to make a backup of your charts if any, (easily done with export json files, which afterwards can be imported to the new version).  
Please notice - Today I´m running Grafana on a windows server, cause I simply gave up getting Grafana to render a chart on a Rpi3B+ Grafana consume too much resources when rendering with phantomjs, so it will breake Java and then kill openhab.

---

<div class="post-metadata">

**Author:** ![vshaev](https://community.openhab.org/user_avatar/community.openhab.org/vshaev/32/12651_2.png) [@vshaev](https://community.openhab.org/u/vshaev)\
**Post date:** [October 14, 2019, 9:54am UTC](https://community.openhab.org/t/grafana-image-renderer/83350/12 "2019-10-14T09:54:10Z")

</div>

I am constantly updating Grafana with a regular reinstall. The old version does not need to be deleted. all charts remain in place. At the same time, no one canceled the backup.  
The download page [https://grafana.com/grafana/download](https://grafana.com/grafana/download) has all the recommendations. They change with the release of a new stable version. It is necessary to execute only two teams.

---

<div class="post-metadata">

**Author:** ![sapster77](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@sapster77](https://community.openhab.org/u/sapster77)\
**Post date:** [October 14, 2019, 10:13am UTC](https://community.openhab.org/t/grafana-image-renderer/83350/13 "2019-10-14T10:13:33Z")

</div>

Thanks all of you. I manually updated and am now running newest version.  
Using this [tutorial](https://community.openhab.org/t/tutorial-grafana-rendering-on-raspberry-pi/71777) I now have the Grafana image renderer plugin working on my Rpi3B+ 🙂

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [October 14, 2019, 1:16pm UTC](https://community.openhab.org/t/grafana-image-renderer/83350/14 "2019-10-14T13:16:55Z")

</div>

I’m glad you got it working and thanks for the confirmation that it works on an RPi.

---

<div class="post-metadata">

**Author:** ![thisisIO](https://community.openhab.org/letter_avatar_proxy/v4/letter/t/22d042/32.png) [@thisisIO](https://community.openhab.org/u/thisisIO)\
**Post date:** [November 16, 2019, 9:55pm UTC](https://community.openhab.org/t/grafana-image-renderer/83350/15 "2019-11-16T21:55:32Z")

</div>

> [@rlkoshak](#):
>
> If Grafana is installed on your machine, you can use grafana-cli.
> 
> grafana-cli plugins install grafana-image-renderer

HI Rich,

1. after this command i get the messege

```php
Error: ✗ Plugin is not supported on your architecture and os.

```

i am on 2.5M4 on Pi4 and Grafana v6.4.4

1. Tried manual installation, but on this page [https://grafana.com/grafana/plugins/grafana-image-renderer/installation](https://grafana.com/grafana/plugins/grafana-image-renderer/installation) the link with zip is unavailable [Screenshot by Lightshot](http://prntscr.com/pxxuvu)  
1.0.0 [https://grafana.com/api/plugins/grafana-image-renderer/versions/1.0.0/download](https://grafana.com/api/plugins/grafana-image-renderer/versions/1.0.0/download)  
1.0.5 [https://grafana.com/api/plugins/grafana-image-renderer/versions/1.0.5/download](https://grafana.com/api/plugins/grafana-image-renderer/versions/1.0.5/download)

It means i have no ability to render grafana images? 😪

PS  
Manual install from this [thread](https://community.openhab.org/t/tutorial-grafana-rendering-on-raspberry-pi/71777/29) also gives error

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [November 16, 2019, 10:24pm UTC](https://community.openhab.org/t/grafana-image-renderer/83350/16 "2019-11-16T22:24:51Z")

</div>

I don’t run it on an RPi so I can’t be of much help. But @sapster77 posted a link to a tutorial that might help.

---

<div class="post-metadata">

**Author:** ![thisisIO](https://community.openhab.org/letter_avatar_proxy/v4/letter/t/22d042/32.png) [@thisisIO](https://community.openhab.org/u/thisisIO)\
**Post date:** [November 16, 2019, 10:32pm UTC](https://community.openhab.org/t/grafana-image-renderer/83350/17 "2019-11-16T22:32:52Z")

</div>

Thanks but as said above - Manual install from this [thread](https://community.openhab.org/t/tutorial-grafana-rendering-on-raspberry-pi/71777/29) also gives error

So it seems to be no way to render grafana on pi4 and the most bad thing is that according all that **no way to get grafana on the myopenhab cloud and outside the local network**.  
It a pity.

---

<div class="post-metadata">

**Author:** ![sapster77](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@sapster77](https://community.openhab.org/u/sapster77)\
**Post date:** [November 17, 2019, 6:59am UTC](https://community.openhab.org/t/grafana-image-renderer/83350/18 "2019-11-17T06:59:21Z")

</div>

Via the link I posted above I made it run nicely on a Pi3 (local network). I can see that the thread has now been updated to also include instructions for a Pi4, so you could try that.  
Let us know if it works:-)

---

<div class="post-metadata">

**Author:** ![shutterfreak](https://community.openhab.org/user_avatar/community.openhab.org/shutterfreak/32/74067_2.png) [@shutterfreak](https://community.openhab.org/u/shutterfreak)\
**Post date:** [November 24, 2019, 10:47am UTC](https://community.openhab.org/t/grafana-image-renderer/83350/19 "2019-11-24T10:47:25Z")

</div>

> [@sapster77](#):
>
> Using this [tutorial](https://community.openhab.org/t/tutorial-grafana-rendering-on-raspberry-pi/71777) I now have the Grafana image renderer plugin working on my Rpi3B+ 🙂

What did you do to make it work on a RPi3B+? So far all my attempts, following those instructions, failed. Compilation always ended prematurely.

**EDIT:** here are the instructions for compiling the new Grafana renderer plugin on RPi3B+:

> [@Tutorial - Grafana rendering on Raspberry Pi](https://community.openhab.org/t/tutorial-grafana-rendering-on-raspberry-pi/71777/33):
>
> Here are instructions for compiling it on the RPi3B+: sudo su cd /var/lib/grafana/plugins git clone https://github.com/grafana/grafana-image-renderer cd grafana-image-renderer Now we’ll update npm, just in case: npm -g install npm Now we’ll install yarn and typescript: npm -g install yarn npm -g install typescript The following line is essential for compiling the plugin’s dependencies on a RPi3B+ on openhabian buster: npm config set unsafe-perm=true We can now at last add the Node.JS dep…

---

<div class="post-metadata">

**Author:** ![sapster77](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@sapster77](https://community.openhab.org/u/sapster77)\
**Post date:** [November 24, 2019, 7:13pm UTC](https://community.openhab.org/t/grafana-image-renderer/83350/20 "2019-11-24T19:13:51Z")

</div>

Super - so you made it work:-) Thanks for sharing the updated solution.

[Next page](https://community.openhab.org/t/grafana-image-renderer/83350.md?page=2)
