grafana / grafana-image-renderer

A Grafana backend plugin that handles rendering of panels & dashboards to PNGs using headless browser (Chromium/Chrome)
Apache License 2.0
378 stars 152 forks source link

Add support for ARM #7

Open andre2308 opened 5 years ago

andre2308 commented 5 years ago

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

ThoZed commented 5 years ago

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.

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

git clone into Grafana external plugins folder.
yarn install --pure-lockfile
yarn run build

/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"

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

andre2308 commented 5 years ago

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

marefr commented 5 years ago

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

Creamers158 commented 5 years ago

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?

marefr commented 5 years ago

@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 grpc@1.11.3 --build-from-source
patricktokeeffe commented 4 years ago

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?

koying commented 4 years ago

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 . ./
Cossey commented 4 years ago

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

aukedejong commented 4 years ago

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

aukedejong commented 4 years ago

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
dpsenner commented 4 years ago

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.

marefr commented 4 years ago

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

master0v commented 4 years ago

+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?

Wolfgang1966 commented 4 years ago

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

Legion2 commented 4 years ago

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

asksven commented 4 years ago

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

careyer commented 4 years ago

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

asksven commented 4 years ago

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

Diapolo commented 4 years ago

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

GSzabados commented 4 years ago

+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.

koying commented 4 years ago

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 :)

GSzabados commented 4 years ago

@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...

Wolfgang1966 commented 4 years ago

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.

careyer commented 4 years ago

+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!

koying commented 4 years ago

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

ldab commented 4 years ago

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

andreasloe commented 4 years ago

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

It renders on the client side.

BiasF commented 3 years ago

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

groissi commented 3 years ago

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

Roberto6969 commented 3 years ago

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

dan-m-joha commented 3 years ago

+1 for RPi 4B (ARMv7) for use with OpenHAB (InfluxDB) without use of docker images

justfra commented 3 years ago

+1 for use with OpenHAB (InfluxDB) without use of docker images

diplopoda commented 3 years ago

+1 for RPi 4B (ARMv7) for use with Grafana (InfluxDB) without use of docker images

DanielIbaseta commented 3 years ago

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

This worked perfectly on my Raspberry Pi3 running an influxDB. Thank you very much

Sandaru48 commented 3 years ago

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

I'm new to docker and I followed the above docker-compose.yml file. Only renderer container is running. time to tome grafana container up and down. I'm using raspberry pi 4 running raspios-buster-armhf-lite with Prometheus, Node_exporter and hubot. Is there any workaround to resolve this?

log :

pi@raspberrypi:~/mydocker $ docker logs 8542bbf67135 GF_PATHS_CONFIG='/etc/grafana/grafana.ini' is not readable. GF_PATHS_DATA='/var/lib/grafana' is not writable. You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migration-from-a-previous-version-of-the-docker-container-to-5-1-or-later installing raintank-worldping-app @ 1.2.7 from: https://grafana.com/api/plugins/raintank-worldping-app/versions/1.2.7/download into: /var/lib/grafana/plugins

Legion2 commented 3 years ago

For all openHAB users here, from the openHAB 3 documentation:

It also provides flexible charting now so you won't require Grafana or a similar external tool any more.

See https://www.openhab.org/docs/configuration/

image

angadsingh commented 3 years ago

@asksven i followed your docker buildx approach to the letter (built it on my mac though, im not sure if that matters). however the image does not start on rpi4. here's the error:

terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::_M_replace_aux

the image "adejong/grafana-image-renderer-pi:1.0.8-beta2" with the dockerfile patch works perfectly. however i want to use your approach to build the latest master.

BarkinSpider commented 3 years ago

+1 - Arm6 and Arm7 renderer support please!

fuomag9 commented 3 years ago

+1 Please add support for armv7 and armv8!

okaufmann commented 3 years ago

Meanwhile, you can use this image: https://hub.docker.com/r/adejong/grafana-image-renderer-pi It is not updated since a while, but it seems to work well (At least it does for me on a Raspberry Pi in a little side project)

fuomag9 commented 3 years ago

Meanwhile, you can use this image: https://hub.docker.com/r/adejong/grafana-image-renderer-pi It is not updated since a while, but it seems to work well (At least it does for me on a Raspberry Pi in a little side project)

Pi4 running ubuntu-server 64bit, I managed to get it working, so thanks!

anoff commented 3 years ago

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

@asksven thanks a lot for providing this image. Would you be willing to push a 2.x tag to make the versioning better reflect the version of the original renderer image? If you've already moved on from this issue I might do it myself 🙄

Judging from the timestamps https://hub.docker.com/r/adejong/grafana-image-renderer-pi should be a 1.x base

careyer commented 3 years ago

Meanwhile, you can use this image: https://hub.docker.com/r/adejong/grafana-image-renderer-pi It is not updated since a while, but it seems to work well (At least it does for me on a Raspberry Pi in a little side project)

Pi4 running ubuntu-server 64bit, I managed to get it working, so thanks!

I also downloaded that docker image and got it running. However when trying to render an image I get this error message from grafana: grafik

It sais: The grafic can not be displayed because it contains errors" What am I doing wrong??

Hmm... i found that the return value of that webrequest seen in the screenshot return a <a href="/login">Found</a>. as content... this is definetly not a graphic

anoff commented 3 years ago

@careyer I am using docker-compose with @asksven's image for a few days now. Maybe this helps:

  grafana:
    image: grafana/grafana:latest
    container_name: grafana
    ports:
      - "3000:3000" # expose for localhost
    env_file: [.env.grafana]
    environment:
      - GF_RENDERING_SERVER_URL=http://grafana-renderer:8081/render
      - GF_RENDERING_CALLBACK_URL=http://grafana:3000/
    volumes:
      - /mnt/data/grafana/data:/var/lib/grafana # data path
      - /mnt/data/grafana/grafana.ini:/etc/grafana/grafana.ini
      - /mnt/data/grafana/provisioning:/etc/grafana/provisioning
  grafana-renderer:
    image: asksven/grafana-image-renderer:1
    container_name: grafana-renderer
    ports:
      - "8081"
careyer commented 3 years ago

@anoff Thank you very much! I was finally able to resolve the problem. It was something simple but not too obvious. In the grafana confguration in /etc/grafana/grafana.ini I configured the following:

[rendering]
# Options to configure external image rendering server like https://github.com/$
server_url = http://localhost:8081/render
callback_url = http://localhost:3000/

I used localhost bevcause the image renderer clearly was available at this address (When I tried to open http://localhost:8081 with a browser it greeted me with the message "Grafana Image Renderer"). However this configuration would cause the problem described in https://github.com/grafana/grafana-image-renderer/issues/7#issuecomment-762964925

When I changed config to:

[rendering]
# Options to configure external image rendering server like https://github.com/$
server_url = http://<virtual_ip_of_docker_container>:8081/render
callback_url = http://localhost:3000/

it finally worked! From my understanding it should just do the same but obviously it doesn't. There seems to be some strange callback problem.

Nevermind... Problem resolved and the Grafana Image Renderer is doing its job perfectly now. :-) Thanks for stepping in and trying to help

Legion2 commented 3 years ago

Each docker container has its own network address and if you open localhost in a container it is different from localhost in your browser. When you use docker-compose, it defines a virtual network where all containers are connected and the containers can use the names of each other as DNS names to connect to each other. Then you can use the name of the service instead of the random ip address.

MPatzek commented 3 years ago

Hi,

i'm trying to get this working on RPi4 using docker-compose: grafana: restart: always image: grafana/grafana:latest container_name: grafana labels:

The renderer greets me when I access the IP:3002. Trying to render a graph gives me an error on the grafana container: vl=eror msg="Rendering failed." logger=context userId=2 orgId=1 uname=fhem error="Failed to send request to remote rendering service. Get \"http://grafana-renderer:3002/render?deviceScaleFactor=1.000000&domain=grafana&encoding=&height=400&renderKey=XXXXXXXXXXX&timeout=60&timezone=&url=http%3A%2F%2Fgrafana%3A3001%2Fdashboard%2FBcZVINRRz%2Fzuhause%3ForgId%3D1%26from%3Dnow-2d%26to%3Dnow%26render%3D1&width=800\": dial tcp 172.18.0.9:3002: connect: connection refused"

The 172.18.0.9 is the internal IP of the grafana-renderer given in the network "fhem-network", meaning that the DNS resolving works.

I also tried it with localhost as the callback url, but it also didn't help (of course). Does anybody have any idea on how to fix this?

All the best

anoff commented 3 years ago

@IcedEarth don't you have to use the internal ports within the docker network? i.e. grafana-renderer:8081 and grafana:3000 instead of the host ports

MPatzek commented 3 years ago

@anoff You are right. Newbie mistake ;-) Thanks for the clarification. It is working now.

thetravellor commented 3 years ago

This works on 32 bit Buster on RPI:

Distributor ID: Raspbian Description: Raspbian GNU/Linux 10 (buster) Release: 10 Codename: buster Linux raspberrypi 5.4.83-v7l+ #1379 SMP Mon Dec 14 13:11:54 GMT 2020 armv7l GNU/Linux Raspberry Pi 4b

Compile and install Grafana image renderer on 32 bit Raspbian 10.

Amalgamation of disparate github and grafana forum comments


apt-get update apt-get install git cd /var/lib/grafana/plugins git clone https://github.com/grafana/grafana-image-renderer cd /var/lib/grafana/plugins/grafana-image-renderer npm i grpc npm i install npm install -g typescript

this will fail, nodejs is too old.

yarn run build

installs 12.20.1-1nodesource1, probably dont need nodered for this (I needed it for other things)

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) 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 apt update apt install yarn yarn install --pure-lockfile

this will work

yarn run build cp plugin_start_linux_amd64 plugin_start_linux_arm sudo apt-get install chromium-browser –yes systemctl restart grafana-server

fails

root@raspberrypi:/var/log/grafana# cat grafana.log | grep sign t=2021-01-25T15:34:05+1100 lvl=warn msg="Some plugins failed to load" logger=plugins errors="[plugin \"grafana-image-renderer\" is unsigned]"

cd /etc/grafana nano grafani.ini

uncomment and modify the following:

[plugins] allow_loading_unsigned_plugins = grafana-image-renderer [plugin.grafana-image-renderer] rendering_chrome_bin = /usr/bin/chromium-browser

Save/Exit

systemctl restart grafana-server

succeeds

root@raspberrypi:/var/log/grafana# cat grafana.log | grep sign t=2021-01-25T18:44:37+1100 lvl=warn msg="Running an unsigned backend plugin" logger=plugins pluginID=grafana-image-renderer pluginDir=/var/lib/grafana/plugins/grafana-image-renderer t=2021-01-25T18:44:37+1100 lvl=info msg="Registering plugin" logger=plugins id=grafana-image-renderer

t=2021-01-25T16:21:26+1100 lvl=info msg=Rendering logger=rendering renderer=plugin path="d-solo/qARRyNaWk/aussie-broadband-bandwidth?orgId=1&refresh=15m&from=1610947278896&to=1611552078896&var-DS_SPEEDTESTS=speedtest&panelId=10&width=1000&height=500&tz=Australia%2FSydney"

enjoy