Something completely different in contrast to the last few weeks: Grafana dashboarding, using Graphite metrics.
A great while ago I’ve introduced and setup Icinga 2 and Icinga Web 2 to monitor our relatively new managed hosting platform. I’ve written a couple of posts about it, starting here.
Not too long after that I’ve added Graphite to visualise the configuration more, as described here and here. Today we’re building a whole new dashboard that looks much prettier and using our existing Graphite installation, it’s also pretty easy.
My installation is the latest Debian 9 version and everything regarding Graphite is up to date as well. That being said, it should also work on non-Debian distributions.
Let’s add the Grafana repo and key:
# echo deb https://packages.grafana.com/oss/deb stable main > /etc/apt/sources.list.d/grafana.list # curl https://packages.grafana.com/gpg.key | apt-key add -
Optional: Add the repo to the unattended upgrades mechanism (when you’re using this like me) in the file /etc/apt/apt.conf.d/50unattended-upgrades:
Get the software:
# apt update # apt install grafana
Simply start, enable and check the server:
# systemctl start grafana-server # systemctl enable grafana-server # systemctl status grafana-server
For the most part, Grafana is good to go. Let’s get a copy of our certificates in place and make sure Grafana runs via https:
# cd /etc/grafana # cp /etc/ssl/private/mycert.com.key server.key # cp /etc/ssl/public/mycert.com.crt server.crt
Probably needless to say, is that your certificates should actually reside in the /etc/ssl folders. Mine are, so I’m copying them from there. Also, this can also be setup without SSL but I’m never recommending that.
Grafana should be able to read the files:
# chown root:grafana server.key server.crt # chmod 640 server.key server.crt
Edit the grafana.ini file in this same directory. The file is pretty comprehensive, these are only the changes:
protocol = https root_url = https://grafana.mydomain.com:3000 cert_file = /etc/grafana/server.crt cert_key = /etc/grafana/server.key
Change your URL to suit your needs. Restart the service and check for errors:
# systemctl start grafana-server # systemctl status grafana-server
If everything went OK, you can now login at https://grafana.mydomain.com:3000. You’ll be prompted to change the admin password and can login.
As said, we’re using our Graphite installation as data source. You’ll be redirected to add your first datasource after logging in. Just add your Graphite URL and click ‘Save & Test’. You should be good.
You can now add new collections, dashboards and panels via the GUI.