After avoiding and putting this off for months now, I finally decided to set this up and I must say, I was a bit silly to even fear this. The only reason I didn’t want to get into it was that I felt it was going to be tedious and hard to maintain, but to my surprise, it was extremely easy to install and set up.
I’ll start by explaining what these self-hosting services are:
What Is Prometheus? Prometheus is an open-source technology designed to provide monitoring and alerting functionality for cloud-native environments, including Kubernetes. It can collect and store metrics as time-series data, recording information with a timestamp.
To have Prometheus collect and scrape all the metrics, we also need to use Node-Exporter service, which is provided by the same developer.
Grafana is an open-source interactive data-visualization platform, developed by Grafana Labs, which allows users to see their data via charts and graphs that are unified into one dashboard (or multiple dashboards!) for easier interpretation and understanding.
I will not get into Kubernetes at this time as that needs an entire post and I’m still not too sure how that even works at this point haha!
Now, there are several ways of going about this but I found that the best way, at least for me, was to use docker and deploy all the services in a stack, through Portainer’s UI.
Docker-Compose file for how I’ve done this –
Make sure to deploy a node-exporter on each machine that you want to be scraped by Prometheus.
Prometheus will need a yml file to know what nodes to scrape. I will provide my config as an example –
After Prometheus server is started, if everything is set correctly, you should have something like this –
In Grafana, you will need to add your preferred Dashboard and link it to your Prometheus instance.
You can find a multitude of pre-set dashboards on Grafana’s official website. Just copy/paste dashboard id’s into your Grafana setup and you should be good to go.
After Grafana is booted, you should have something like this –
I must say, this has been a godsend. I can see how all my home lab environments are doing and troubleshoot at the click of a button. We get an abundance of information from our system poured into ONE beautiful UI and this is extremely useful for admins in general.
I hope you’ll find this just as useful as I did! See ya!