Grafana is a monitoring/analytics web interface. This manual documents how to build and run Grafana on Pi 4.
Prerequisites:
- Node exporter running on all nodes (calculates metrics locally)
- Prometheus running on one of the nodes (aggregates and stores all metrics in one place)
Citations:
- This section is based on the officail grafana doc
sudo adduser --disabled-password grafana
sudo mkdir /mnt/btrfs/grafana
sudo mkdir /mnt/btrfs/grafana/src
sudo mkdir /mnt/btrfs/grafana/gocode
sudo mkdir /mnt/btrfs/grafana/bin
sudo chown -R grafana /mnt/btrfs/grafana
https://github.com/alevchuk/minibank#network
sudo apt install -y python3 python3-distutils g++ make golang git
- Enable Go. Add exports to ~/.profile by running:
sudo su -l grafana
ln -s /mnt/btrfs/grafana/src ~/src
ln -s /mnt/btrfs/grafana/gocode ~/gocode
ln -s /mnt/btrfs/grafana/bin ~/bin
ln -s /mnt/btrfs/lightning/src/ ~/src_readonly
echo 'export GOROOT=~/src_readonly/go' >> ~/.profile
echo 'export GOPATH=~/gocode' >> ~/.profile
echo 'export PATH=$GOROOT/bin:$GOPATH/bin:$PATH' >> ~/.profile
echo 'export PATH=$HOME/bin/bin:$PATH' >> ~/.profile
Load new profile
. ~/.profile
node.js (includes NPM)
- unfortunatly, the make step here will take many hours (a whole day)
- installing node.js some other way maybe possible yet comes with other issues (e.g. the official debian build is out-dated, likely incompatible and has security vulnerabilities)
Login as grafana user:
sudo su -l grafana
rm -rf /mnt/btrfs/grafana/bin/lib/node_modules # clear previous install
git clone https://github.com/nodejs/node.git ~/src/node
cd ~/src/node
git checkout $(git tag | grep v21 | sort -V | tail -n1)
cd ~/src/node && make clean && ./configure --prefix $HOME/bin && make && make install
sudo su -l grafana
npm was installed as part of Node.js so you can just do this
npm install -g yarn
yarn set version stable
sudo su -l grafana
git clone https://github.com/grafana/grafana.git ~/src/grafana
cd ~/src/grafana
v=$(git tag | grep v9 | sort -V | tail -n1)
echo $v
git checkout $v
yarn install --immutable # this will take ~15 minutes
yarn start # this will build front-end assets
sudo su -l grafana
cd ~/src/grafana
make run
cd ~/gocode/src/github.com/grafana/grafana
./bin/grafana-server
sudo vi /etc/iptables/rules.v4
Add rule (modify -s if your subnet is different):
# Allow Grafana Web UI on local network
-A INPUT -p tcp -s 192.168.0.0/24 --dport 3000 -j ACCEPT
Reload firewall:
sudo systemctl restart netfilter-persistent.service
Use grafana: connect your browser to http://localhost:3000
Follow web-ui wizard. Import dashboards:
- Node Exporter Server Metrics dashboard https://gist.github.com/alevchuk/2a28d484945c86d3ffef0f7e671b065d
- Bitcoin dashboard https://gist.github.com/alevchuk/4235aefb3b8389b62c75878f5b1f7d04
E.g. "Node Exporter Server Metrics" can show multiple nodes side-by-side: