grafana-image-renderer icon indicating copy to clipboard operation
grafana-image-renderer copied to clipboard

Add support for ARM

Open andre2308 opened this issue 6 years ago • 106 comments

Hey,

is there any plans to support arm CPUs?

I'am using a Synology DS216play with a STM STiH412 CPU. When i want to install the image rendering, yarn throw me these errors: yarn log.txt with Google i found out that node grpc supports arm after Version 1.4.1.

Or is there a way to Cross Compile it?

Thank you

andre2308 avatar Nov 01 '18 19:11 andre2308

Hey There, i just installed this plugin on odroidxu4, so maybe we had the same experience:-) i run influxdb on this box too and grafana should render images for the openhab instance. to replace PhantomJs which seems broken for my case grafana-image-renderer was the next try.

  • to get it running i first had to install yarn and nodejs in the latest versions.

Node.js v8.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

refer to: https://github.com/nodesource/distributions/blob/master/README.md

yarn:

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn

refer to : https://github.com/yarnpkg/yarn/issues/2821

  • follwing commands installed the plugin seamless
git clone into Grafana external plugins folder.
yarn install --pure-lockfile
yarn run build
  • after restart of the server the renderer could not be started

/var/log/grafana/grafana.log "Server shutdown" logger=server reason="fork/exec /var/lib/grafana/plugins/grafana-image-renderer/plugin_start_linux_arm: no such file or directory"

  • create a start file with
cd /var/lib/grafana/plugins/grafana-image-renderer/
cp plugin_start_linux_amd64 plugin_start_linux_arm
  • the grafana-image-renderer is started correctly after grafana restart

  • on render request the grafana threw following error:

/var/log/grafana/grafana.log "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/node_modules/puppeteer/.local-chromium/linux-579032/chrome-linux/chrome: 1: /var/lib/grafana/plugins/grafana-image-renderer/node_modules/puppeteer/.local-chromium/linux-579032/chrome-linux/chrome: Syntax error: word unexpected (expecting ")")\n\n\nTROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md\n"

  • it turns out that the binary for chrome wasn't suitable for arm https://github.com/GoogleChrome/puppeteer/issues/2124

  • install chromium for arm like described here: https://github.com/GoogleChrome/puppeteer/issues/550#issuecomment-432018195

  • backup binary

cd /var/lib/grafana/plugins/grafana-image-renderer/node_modules/puppeteer/.local-chromium/linux-579032/chrome-linux/
mv chrome chrome.bak
  • replace binary
cp /usr/bin/chromium-browser /var/lib/grafana/plugins/grafana-image-renderer/node_modules/puppeteer/.local-chromium/linux-579032/chrome-linux/chrome

Hey @andre2308 ,have a try. maybe it fixes your issue too.

Best Regards Thomas

ThoZed avatar Nov 05 '18 22:11 ThoZed

Hey @ThoZed,

Meantime i think My mainproblem is the „custom“ Linux Version from Synology with no apt-get... I have tryed a lot. Yarn i had to install with npm and add the Path.

I Managed to install make with entware and glibc. Then the Build process will run a Bit, stops with make: cc: command Not found.. i have no clang Compiler or Build-essentials on entware-Ng or opt.

With Export cc=gcc before, it will compile, make the arm startup file and then crashed grafana by startup, with the Message „plugin exit before we could connect“ from RenderingService

andre2308 avatar Nov 07 '18 04:11 andre2308

Please try out the new build/packaging of this just merged to master, see https://github.com/grafana/grafana-image-renderer#packaging

marefr avatar Aug 16 '19 09:08 marefr

Phantomjs isnt working anymore so I tried to clone the grafana-image-renderer into the plugin folder as instructed in the readme as I dont have grafana-cli 6.4 on rasbian to use that method, but the yarn install --pure-lockfile gives me the following errors on Raspbian GNU/Linux 10 (buster) :

https://community.icinga.com/uploads/default/original/2X/7/752cf847647a6056b2d055867b9198ea928aae8c.png

Any suggestions/tips?

Creamers158 avatar Sep 15 '19 14:09 Creamers158

@Creamers158 seems like pre-built binaries for grpc v1.11.3 on arm are not available, only arm64. Not sure that there are prebuilt grpc node binaries at all for arm. I don't currently have an arm device so hard for me to help out.

Seems like the only way is to build it from source and looking at your error seems like it tries to compile it but fails. Maybe your lacking some dependency like node-gyp and/or C++ build tools?

I would start with trying to install node-gyp:

npm install -g node-gyp

Then grpc:

npm install [email protected] --build-from-source

marefr avatar Sep 16 '19 09:09 marefr

When I visit this list of prebuilt binaries linked to from the readme Packaging section, I see listings for both arm and arm64.

image

Does this mean grafana-image-renderer can now be built to support arm platforms? (I realize gprc might be pinned at v1.11.3, but that version pre-dates the oldest version listed in the precompiled binary bucket, v1.14.0-pre1.)

Or is building locally with yarn still the best install method for arm platform?

patricktokeeffe avatar Oct 22 '19 00:10 patricktokeeffe

FWIW, I got the docker to build on a rpi4.

Here is the patch I applied to the Dockerfile, based on info gathered left and right:

diff --git a/Dockerfile b/Dockerfile
index 7404aad..bcf0ba4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,6 +2,7 @@ FROM node:10-alpine AS base

 ENV CHROME_BIN="/usr/bin/chromium-browser"
 ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"
+ENV CXXFLAGS="-Wno-ignored-qualifiers -Wno-stringop-truncation -Wno-cast-function-type"

 WORKDIR /usr/src/app

@@ -16,6 +17,10 @@ RUN \
                ca-certificates dumb-init \
   && rm -rf /var/cache/apk/* /tmp/*

+RUN apk add --no-cache libc6-compat python alpine-sdk
+RUN npm install -g node-gyp
+RUN npm install --build-from-source=grpc
+
 FROM base as build

 COPY . ./

koying avatar Oct 26 '19 12:10 koying

Thanks for this diff @koying. I can confirm that this works on a Raspberry Pi 3!

Cossey avatar Nov 05 '19 10:11 Cossey

Thanks. I can confirm this also works on a Raspberry Pi 4.

aukedejong avatar Jan 01 '20 07:01 aukedejong

I pushed the image I created. It's my first image I pushed, so if I've done something wrong, please let me know.

This docker-compose.yml is working on a Raspberry Pi 4

version: "2"

services:
  grafana:
    image: grafana/grafana:latest
    container_name: grafana
    environment:
      GF_RENDERING_SERVER_URL: http://renderer:8081/render
      GF_RENDERING_CALLBACK_URL: http://grafana:3000/
    ports:
      - 3000:3000
    links:
      - renderer
    volumes:
      - ./data:/var/lib/grafana
  renderer:
    image: adejong/grafana-image-renderer-pi:1.0.8-beta2
    container_name: grafana-image-renderer-pi
    ports:
      - 8081

aukedejong avatar Jan 01 '20 10:01 aukedejong

Is grafana-cli plugins install grafana-image-renderer meanwhile supposed to work for grafana 6.5.2 (742d165) on raspbian armv7l? For me it gives an error that the architecture and os is not supported.

dpsenner avatar Jan 08 '20 11:01 dpsenner

@dpsenner ARM is currently not supported. See above for workarounds building custom docker image

marefr avatar Jan 10 '20 10:01 marefr

+1 for making it work on Rpi "out of the box" (i.e. without having to build custom docker images). Where is the "upvote" button?

master0v avatar Jun 11 '20 01:06 master0v

+1 for supporting this plugin on ARM architecture. Thanks a lot!

Wolfgang1966 avatar Jun 13 '20 11:06 Wolfgang1966

I created a fork which can be built and run on ARM docker build -t grafana-image-renderer https://github.com/Legion2/grafana-image-renderer.git

Legion2 avatar Jun 13 '20 11:06 Legion2

Based on the current master I was able to build for arm64 and arm/v7, with the following steps (happy to provide a PR):

  1. Clone the grafana-image-renderer repo: https://github.com/grafana/grafana-image-renderer
  2. Copy Makefile to the repo
  3. cd into the repo
  4. Login to the registry you are going to push to: docker login
  5. Set environment variables: export REPOSITORY=asksven/grafana-image-renderer && export VERSION=1
  6. Start the emulator: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
  7. Build: make

and the following Makefile:

# Build docker image with buildx
# Experimental docker feature to build cross platform multi-architecture docker images
# https://docs.docker.com/buildx/working-with-buildx/
docker-buildx:
	export DOCKER_CLI_EXPERIMENTAL=enabled
	@if ! docker buildx ls | grep -q container-builder; then\
		docker buildx create --platform "linux/amd64,linux/arm64,linux/arm/v7" --name container-builder --use;\
	fi
	docker buildx build --platform "linux/amd64,linux/arm64,linux/arm/v7" \
		-t $(REPOSITORY):$(VERSION) \
		. --push

If you want to test: https://hub.docker.com/r/asksven/grafana-image-renderer:1

I am running Grafana and the renderer on k8s and I am happy to provide the deployment and service and the changes I made to the helm chart as well if it helps

asksven avatar Jun 20 '20 15:06 asksven

+1 for making it work on Rpi - Please without having to build custom docker images! Thank you very much!!

careyer avatar Jun 20 '20 21:06 careyer

Well, the image still has to be built but it is not custom since using the Dockerfiles from master. I definitely hope that docker buildx makes it to the default so that multi-arch images get pushed to dockerhub

asksven avatar Jun 21 '20 15:06 asksven

It's a pitty that this plugin can't be installed in openHABian Grafana environments out-of-the-box.

Diapolo avatar Jun 27 '20 11:06 Diapolo

+1, it is a bit weird that one feature is forcefully removed and the other replacement is not built for the arm platform. A lot of people uses grafana on RPis to visualise data. Why not to support these people? Since November 2018 nobody has thought of this?

Now I can read only this in every email from Grafana.

No image renderer available/installed.

GSzabados avatar Jun 30 '20 22:06 GSzabados

Gents,

  1. ARM32 will disappear sooner than latter, even on rpi

  2. it's not even an issue with grafana-image-renderer, but one of its dependencies that doesn't provide arm32

  3. you have patches to build your own docker image

  4. @aukedejong was even kind enough to make a prebuilt image available.

Help yourselves a little bit :)

koying avatar Jul 01 '20 07:07 koying

@koying, thanks for the heads up.

You might want to read this blog post first.

https://grafana.com/blog/2020/05/07/grafana-7.0-preview-new-image-renderer-plugin-to-replace-phantomjs/

The Grafana Image Render plugin and Docker image are currently not supported on ARM architectures. There’s an open GitHub issue requesting ARM support that includes some suggestions from the community on how you could get it to work. We kindly ask users of ARM devices who want support to upvote the issue and share any information that could be valuable for your use case. With enough interest we will prioritize this. We’re of course always happy to receive contributions, if anyone is interested.

Many people using grafana or RPis especially in Home Automations use cases. Tracking temperature, air quality, power consumption, doors/windows being open close etc. The images rendered are displayed on panels or used by alert emails.

Myself, I use grafana with SmartThings and Telegraph. I use the alert emails to track the quality of my internet connection. Purely ping.

And I appreciate what you are saying, but I didn't want to spend hours building a Docker image, what I haven't got really experience with it. And meanwhile solving zillions of other issues. Otherwise it is issue #7 and dates back 2 years almost. Wow...

GSzabados avatar Jul 01 '20 08:07 GSzabados

Regarding "ARM32 will disappear sooner than latter":

Currently ARM32 boards are still sold widely. And when you buy one today you likely want to use it 2-3 years before you replace it. So, "sooner" very likely will be at least 3 years in the future from now.

Wolfgang1966 avatar Jul 01 '20 08:07 Wolfgang1966

+1 ... I am using Grafana in combination with Node-RED and Influx.DB on a RPi 3B+ (so ARMv7 based bare metal installtion). It works flawlessly and with awesome performance. No need to upgrade to Pi4 anytime soon really. As @Wolfgang1966 said: ARM32 will still be arround for years and will be ideally suited for jobs like this. Take a Jeston Nano SBC for example. It is popular like nothing else right now and what architecture is is based on? ARM32 / ARMv7

You asked to upvote this thread? Here is my upvote +1!

careyer avatar Jul 01 '20 10:07 careyer

@careyer For your information, Jetson Nano is an ARM A57, i.e. armv8, i.e. aarch64 :)

koying avatar Jul 01 '20 11:07 koying

+1 rendering images in order to present on the main Hass.io dashboard

ldab avatar Jul 30 '20 05:07 ldab

Maybe this is a solution to the problem: http://html2canvas.hertzen.com/

It renders on the client side.

andreasloe avatar Aug 18 '20 10:08 andreasloe

Would be nice to have image rendering on ARM. I am using Grafana on Homeassistant (As HASS AddOn) for visualising my power measurement !

BiasF avatar Oct 23 '20 20:10 BiasF

+1 rendering images for OpenHAB dashboard integration with InfluxDB // RPi 3B/4B installation, ARM32/ARMv7

groissi avatar Nov 04 '20 01:11 groissi

+1 for making it work on Rpi - Please without having to build custom docker images!

Roberto6969 avatar Nov 12 '20 07:11 Roberto6969