Tutorial - Grafana rendering on Raspberry Pi

And just as I gave up and moved the rendering to a docker instance on a separate server. Kudos to you for persistence. How is the performance? Are you in Rpi 4 or 3?

RPi3+ takes around 5 seconds to render, no matter about the size of the images

Hey,
I’am had the same problems, i managed it to cross-compile the right Chrome version. The pupeteer-versions that ships with the Pluging need a specific Chrome Version.

Feel free to use my Compiled bin, you only must replace it in the Folder /var/lib/grafana/plugins/grafana-image-renderer/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux

Chromium Binary

Hi Andre,

I tried your compiled version but unfortunately it’s not working for me (Pi 4).
How did you compile it, maybe I can compile it as well?

Based on your post I tried again to install the Grafana renderer plugin.

Eventually I managed to run chrome but I first had to set the executable bit on the binary (trivial with chmod +x chrome) and then I had to install some missing shared libraries:

# apt install libxcomposite1
# apt install libxcursor1
# apt install libxdamage1
# apt install libxi6
# apt install libxtst6
# apt install libxrandr2
# apt install libpangocairo-1.0-0
# apt install libatk-bridge2.0-0
# apt install libgtk-3-0

Now I am able to run chrome and display the version:

#./chrome --version
Chromium 70.0.3508.0

However, after restarting the Grafana service, I still get a server error. In the logs I see the following error:

Rendering failed: Error: Failed to launch chrome!
Received signal 11 SEGV_MAPERR 000000000000
#0 0x000001ea2160 <unknown>
#1 0x000001ea20d6 <unknown>
#2 0x000075ba3130 <unknown>
#3 0x000001e93970 <unknown>
#4 0x0000010c6f66 <unknown>
#5 0x0000010c54ec <unknown>
#6 0x000000ee850e <unknown>
#7 0x000000ee6798 <unknown>
#8 0x0000011264c6 <unknown>
#9 0x000000ee637c <unknown>
#10 0x000000ee8e86 <unknown>
#11 0x0000048c0ff0 <unknown>
#12 0x000001b8b4d0 <unknown>
#13 0x000001baf032 <unknown>
#14 0x000001b8a0fc <unknown>
#15 0x00000423aa2e <unknown>
#16 0x00000423aa70 <unknown>
#17 0x000001badd2e <unknown>
#18 0x0000008d9966 ChromeMain
#19 0x000075b8d718 __libc_start_main
[end of stack trace]
Calling _exit(1). Core file will not be generated.


TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

So I’m not there yet…

It appears that when running chrome without arguments, it tries to invoke other binaries which are also ELF (so unusable for ARM architecture). The first one is nacl_helper_bootstrap:

# ./chrome --no-sandbox
/var/lib/grafana/plugins/grafana-image-renderer/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/nacl_helper_bootstrap: 1: /var/lib/grafana/plugins/grafana-image-renderer/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/nacl_helper_bootstrap: ELF: not found
/var/lib/grafana/plugins/grafana-image-renderer/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/nacl_helper_bootstrap: 2: /var/lib/grafana/plugins/grafana-image-renderer/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/nacl_helper_bootstrap: Syntax error: "(" unexpected
[23041:23041:1202/224016.893634:ERROR:nacl_fork_delegate_linux.cc(314)] Bad NaCl helper startup ack (0 bytes)

(chrome:23039): Gtk-WARNING **: 22:40:16.899: cannot open display: 

By the way, running ./chrome --headless --no-sandbox also yields the same stack trace:

# ./chrome --headless --no-sandbox
Received signal 11 SEGV_MAPERR 000000000000
#0 0x000001e48160 <unknown>
#1 0x000001e480d6 <unknown>
#2 0x000075b59130 <unknown>
#3 0x000001e39970 <unknown>
#4 0x00000106cf66 <unknown>
#5 0x00000106b4ec <unknown>
#6 0x000000e8e50e <unknown>
#7 0x000000e8c798 <unknown>
#8 0x0000010cc4c6 <unknown>
#9 0x000000e8c37c <unknown>
#10 0x000000e8ee86 <unknown>
#11 0x000004866ff0 <unknown>
#12 0x000001b314d0 <unknown>
#13 0x000001b55032 <unknown>
#14 0x000001b300fc <unknown>
#15 0x0000041e0a2e <unknown>
#16 0x0000041e0a70 <unknown>
#17 0x000001b53d2e <unknown>
#18 0x00000087f966 ChromeMain
#19 0x000075b43718 __libc_start_main
[end of stack trace]
Calling _exit(1). Core file will not be generated.

Hey,

I used these Links and a Ubuntu VM to Cross-Compile

Build on Linux https://chromium.googlesource.com/chromium/src/+/master/docs/linux_build_instructions.md#Get-the-code
Build Old Version https://chromium.googlesource.com/chromium/src/+/master/docs/building_old_revisions.md
Linux ARM https://chromium.googlesource.com/chromium/src.git/+/master/docs/linux_chromium_arm.md#Recipe1_Building-for-an-ARM-CrOS-device
Chromium work with branches / tags

you must checkout the right Branch, even it wont work with puppeeter.
for puppeeter 1.7.0 it is Chrome Version 70.0.3508.0

Hey shutterfreak,

it was my mistake, i had think, that I only replaced the chrome binary. But I replaced more… Like the nacl_helper_bootstrap.

Now you can find at my github link above the complete chromium folder from my working setup.

Hope now it will run… :wink:

Hi @David_deMarco @Chrishab

Could you help me?

I tried to follow your procedure on my RPI4 with openhabian buster
but at the command:yarn run build
I have got:

root@openhab:/var/lib/grafana/plugins/grafana-image-renderer# yarn run build
yarn run v1.21.1
error renderer@1.0.0: The engine "node" is incompatible with this module. Expected version ">=12 <13". Got "10.18.0"
error Commands cannot run with an incompatible environment.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I had installed NodeRED with

sudo openhabian-config

clearly something went wrong… but at localhost:1880 Node-Red is working.

so I have three questions:

  • How can I update, in the right way, the node engine?
  • Is the edit of grpc-plugin.ts still necessary? my file is in /src/plugin and I don’t understand the right position for the two new lines
  • At the end of this game… will Grafana renders again ?

please be simple: I am a newbie with zero java skill!
Thanks in advance
Ale

Hey,

this mean you must update Node.js grafana have chanced to the last LTS version from Node.js

Follow the instructions at the point Major Version Upgrades

Major Update Node.js

ty @andre2308
I followed the tutorial and intalled node.js 12.x

then restarted with…

> [21:01:55] root@openhab:/var/lib/grafana/plugins/grafana-image-renderer/src# **sudo npm i grpc**
> 
> > grpc@1.24.2 install /var/lib/grafana/plugins/grafana-image-renderer/node_modules/grpc
> > node-pre-gyp install --fallback-to-build --library=static_library
> 
> node-pre-gyp WARN Using request for node-pre-gyp https download 
> [grpc] Success: "/var/lib/grafana/plugins/grafana-image-renderer/node_modules/grpc/src/node/extension_binary/node-v72-linux-arm-glibc/grpc_node.node" is installed via remote
> + grpc@1.24.2
> updated 1 package and audited 1893 packages in 22.011s
> 
> 5 packages are looking for funding
>   run `npm fund` for details
> 
> found 0 vulnerabilities
> 
> [21:02:24] root@openhab:/var/lib/grafana/plugins/grafana-image-renderer/src# **sudo npm i install**
> + install@0.13.0
> updated 1 package and audited 1893 packages in 9.471s
> 
> 5 packages are looking for funding
>   run `npm fund` for details
> 
> found 0 vulnerabilities
> 
> [21:02:42] root@openhab:/var/lib/grafana/plugins/grafana-image-renderer/src# **yarn run build**
> yarn run v1.21.1
> $ tsc
> Done in 8.69s.
[21:03:42] root@openhab:/var/lib/grafana/plugins/grafana-image-renderer# **cp plugin_start_linux_amd64 plugin_start_linux_arm`**

[21:03:58] root@openhab:/var/lib/grafana/plugins/grafana-image-renderer# **sudo systemctl restart grafana-server.service**

[21:05:45] openhabian@openhab:/etc/openhab2/rules$ sudo systemctl status grafana-server.service
● grafana-server.service - Grafana instance
Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-01-09 21:04:38 CET; 1min 9s ago
Docs: http://docs.grafana.org
Main PID: 25036 (grafana-server)
Tasks: 22 (limit: 4915)
Memory: 34.3M
CGroup: /system.slice/grafana-server.service
├─25036 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid --packaging=deb cfg:default.paths.logs=/var/log/grafana cfg:defa
├─25050 /bin/bash /var/lib/grafana/plugins/grafana-image-renderer/plugin_start_linux_arm
└─25053 node /var/lib/grafana/plugins/grafana-image-renderer/build/app.js

but still not working…
:confused:

Hey, @AleAle
Is the marked a typico by copy an paste the output from ssh?

Can you post the log from grafana?
Normally you can find it at

/var/log/grafana/grafana.log

Thanks

Hi @andre2308

the marked is copy an paste error

-rwxr-xr-x 1 root root 94 gen 9 21:03 plugin_start_linux_arm

and this is the grafana.log

> [19:44:39] openhabian@openhab:/var/log/grafana$ sudo cat grafana.log
> t=2020-01-09T21:04:38+0100 lvl=info msg="Shutdown started" logger=server reason="System signal: terminated"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Stopped UsageStatsService" logger=server reason="context canceled"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Stopped PluginManager" logger=server reason="context canceled"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Stopped CleanUpService" logger=server reason="context canceled"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Stopped NotificationService" logger=server reason="context canceled"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Stopped InternalMetricsService" logger=server reason="context canceled"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Stopped provisioningServiceImpl" logger=server reason="context canceled"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Stopped AlertEngine" logger=server reason="context canceled"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Stopped UserAuthTokenService" logger=server reason="context canceled"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Stopped RemoteCache" logger=server reason="context canceled"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Stopped Stream Manager"
> t=2020-01-09T21:04:38+0100 lvl=eror msg="Server shutdown" logger=server reason=nil
> t=2020-01-09T21:04:38+0100 lvl=info msg="Starting Grafana" logger=server version=6.5.2 commit=742d165 branch=HEAD compiled=2019-12-11T13:41:26+0100
> t=2020-01-09T21:04:38+0100 lvl=info msg="Config loaded from" logger=settings file=/usr/share/grafana/conf/defaults.ini
> t=2020-01-09T21:04:38+0100 lvl=info msg="Config loaded from" logger=settings file=/etc/grafana/grafana.ini
> t=2020-01-09T21:04:38+0100 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.data=/var/lib/grafana"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.logs=/var/log/grafana"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.plugins=/var/lib/grafana/plugins"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.provisioning=/etc/grafana/provisioning"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Path Home" logger=settings path=/usr/share/grafana
> t=2020-01-09T21:04:38+0100 lvl=info msg="Path Data" logger=settings path=/var/lib/grafana
> t=2020-01-09T21:04:38+0100 lvl=info msg="Path Logs" logger=settings path=/var/log/grafana
> t=2020-01-09T21:04:38+0100 lvl=info msg="Path Plugins" logger=settings path=/var/lib/grafana/plugins
> t=2020-01-09T21:04:38+0100 lvl=info msg="Path Provisioning" logger=settings path=/etc/grafana/provisioning
> t=2020-01-09T21:04:38+0100 lvl=info msg="App mode production" logger=settings
> t=2020-01-09T21:04:38+0100 lvl=info msg="Writing PID file" logger=server path=/var/run/grafana/grafana-server.pid pid=25036
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing SqlStore" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Connecting to DB" logger=sqlstore dbtype=sqlite3
> t=2020-01-09T21:04:38+0100 lvl=info msg="Starting DB migration" logger=migrator
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing HTTPServer" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing OSSLicensingService" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing SearchService" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing RemoteCache" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing QuotaService" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing ServerLockService" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing UserAuthTokenService" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing PluginManager" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Starting plugin search" logger=plugins
> t=2020-01-09T21:04:38+0100 lvl=info msg="Registering plugin" logger=plugins name="Grafana Image Renderer"
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing RenderingService" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing AlertEngine" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing DatasourceCacheService" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing HooksService" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing LoginService" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing InternalMetricsService" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing TracingService" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing UsageStatsService" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing CleanUpService" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing NotificationService" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing provisioningServiceImpl" logger=server
> t=2020-01-09T21:04:38+0100 lvl=info msg="Renderer plugin found, starting" logger=rendering cmd=plugin_start_linux_arm
> t=2020-01-09T21:04:38+0100 lvl=info msg="Initializing Stream Manager"
> t=2020-01-09T21:04:38+0100 lvl=info msg="HTTP Server Listen" logger=http.server address=[::]:3000 protocol=http subUrl= socket=
> t=2020-01-09T21:04:39+0100 lvl=info msg="Renderer plugin started" logger=rendering ignoreHttpsErrors=false timestamp=0001-01-01T00:00:00.000Z

I have a doubt: do I need a reboot?

Thanks in advance
Ale

Hey…

Hmm a reboot is a try…
unfortunately there are no errors in your log. Are you get an error in your browser, when you try to render a graph?

Maybe this is a solution for you…
https://github.com/grafana/grafana/issues/19842#issuecomment-561268838

I‘am still running Version 1.0.0

Anyone was able to get this running on RPi?
I have tried everything and still getting ‘Failed to launch chrome’ error.

I tried but the newer source code of the module are different and I don’t know how to modify it

I simply gave up on Grafana :smiley: even which part of it works is not great, shitty piece of software…

I followed the above steps to install the image rendering plugin on a RPi4 (with custom installation of openhab and grafana). As others pointed out, you need to install chromium-browser via apt, since the version included in puppeteer does not work. After that just add this:

to plugin_start_linux_arm.

If you use SSL with a custom CA, then you also need to add this line:

GF_RENDERER_PLUGIN_IGNORE_HTTPS_ERRORS=true

I got Grafana rendering working on RPi 4 (4Gb) running openhabian using a mix of the steps above and some more. Rendering takes approximately 5 seconds, so the webview solution is faster. But here we go:

InfluxDB and Grafana should be fairly straightforward to install in openhabian using sudo openhabian-config.
However, nodejs needed to be version 12 for yarn run build, whereas the the default repositories will install v10 and the latest will install v13. To install nodejs v12 i followed the instruction titled “Major version upgrades” here but make sure to change 13 to 12 like so:

sudo su
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
apt install nodejs
node -v

Then I followed the OP:

I cannot tell which of the following steps were necessary, but I did them as a part of trial and error:

(There was no grpc-plugin.ts to edit - no need)
Apparently yarn install was important too:

yarn install --pure-lockfile
yarn run build
cp plugin_start_linux_amd64 plugin_start_linux_arm

Now after restarting grafana, grafana renderer would complain in the log /var/log/grafana/grafana.log about executable not found, so we install chromium (1Gb):

sudo apt-get install chromium-browser

And make the renderer plugin use the chromium executable as pointed out above:

Finally:

I have likely missed something, but this is roughly how I got it working. I’m not an expert - I just put the pieces together. Hope it helps.

8 Likes

Thank’s Dude!
Once solved node version everything was smooth and went ok on my Pi 4.

Hi all,
First of all a big thank you for @wezzix for completing the journey to a functioning setup on a RPi 4. I’ve tried to get this running last year and gave up. I used an Ubuntu VM since to do the rendering part.
I followed @wezzix guidenace and had it running on my RPi 4 in less then 30 minutes!!

Now as an addition to this post, if any of you (like I do) have enabled HTTPS with a real TLD Certificate on Grafana the rendering fails with “ERR_CERT_COMMON_NAME_INVALID”

This is easy to solve by modifying the plugin_start_linux_arm adding the following line:

export GF_RENDERER_PLUGIN_IGNORE_HTTPS_ERRORS=true

Hope this helps!

1 Like