balena-io-experimental / balena-prometheus-grafana

14 stars 7 forks source link

Grafana container is restarting every second #1

Open pckltr opened 4 years ago

pckltr commented 4 years ago

I had balena sense installed and then I pushed your app. It seemed it replaced all the containers from balena sense but Grafana container keeps restarting every second.

HOST OS VERSION balenaOS 2.46.1+rev1 production SUPERVISOR VERSION 10.6.27

edorgeville commented 4 years ago

Having the same issue here. From the logs, it seems that the official grafana image isn't compatible with the Pi. Balena sense doesn't use the official image but builds from debian. Might have part of a solution here: https://github.com/balenalabs/balena-sense/blob/master/grafana/Dockerfile.template

edorgeville commented 4 years ago

I got something running by changing grafana/Dockerfile.template to this:

FROM balenalib/%%BALENA_MACHINE_NAME%%:buster

RUN install_packages \
  fontconfig-config \
  fonts-dejavu-core \
  libfontconfig1 \
  ucf \
  jq \
  wget

RUN wget -O "/tmp/grafana.deb" "https://dl.grafana.com/oss/release/grafana_6.6.1_armhf.deb"

RUN dpkg -i /tmp/grafana.deb && rm /tmp/grafana.deb

WORKDIR /usr/src/app

COPY ./conf/datasources.yml /etc/grafana/provisioning/datasources/

COPY ./conf/dash* /etc/grafana/provisioning/dashboards/

EXPOSE 3000

CMD [ "/usr/sbin/grafana-server", "-homepath=/usr/share/grafana", "-config=/etc/grafana/grafana.ini"]

At this point grafana seems to be starting but seems to load the default config.

edorgeville commented 4 years ago

Ouch. I went in the complete wrong direction. Turns out, there actually is an official arm32v7 docker image for grafana. There also was a typo at the last line of the Dockerfile, missing a " right before the ]. Here is the resulting grafana Dockerfile.template:

FROM grafana/grafana-arm32v7-linux

WORKDIR /usr/src/app

COPY ./conf/datasources.yml /etc/grafana/provisioning/datasources/

COPY ./conf/dash* /etc/grafana/provisioning/dashboards/

EXPOSE 3000

CMD [ "/usr/share/grafana/bin/grafana-server", "--homepath=/usr/share/grafana --config=/etc/grafana/grafana.ini --pac"]

Diff:

diff --git a/grafana/Dockerfile.template b/grafana/Dockerfile.template
index 98e0fc3..28f8f8e 100644
--- a/grafana/Dockerfile.template
+++ b/grafana/Dockerfile.template
@@ -1,4 +1,4 @@
-FROM grafana/grafana
+FROM grafana/grafana-arm32v7-linux

 WORKDIR /usr/src/app

@@ -8,4 +8,4 @@ COPY ./conf/dash* /etc/grafana/provisioning/dashboards/

 EXPOSE 3000

-CMD [ "/usr/share/grafana/bin/grafana-server", "--homepath=/usr/share/grafana --config=/etc/grafana/grafana.ini --pac]
\ No newline at end of file
+CMD [ "/usr/share/grafana/bin/grafana-server", "--homepath=/usr/share/grafana --config=/etc/grafana/grafana.ini --pac"]
\ No newline at end of file

Wiping the docker volumes (using Purge device data in the balena cloud dashboard) resolves the missing dashboard issue.

holgerimbery commented 4 years ago

@edorgeville It is better to introduce a separate Dockerfile.armv7hf file for arm and leave the Dockerfile.template as it is. By changing Dockerfile.template, you will break the compability for other architectures.

edorgeville commented 4 years ago

I didn't know you could do that. Does balenaCloud pick the right file when building for a Raspberry Pi 3 app?

holgerimbery commented 4 years ago

@edorgeville, yes - it is described here [https://www.balena.io/docs/learn/develop/dockerfile/#multiple-dockerfiles]

Dockerfile.<device-type>
Dockerfile.<arch>
Dockerfile.template