Integrating Grafana
Learning how to integrate Grafana to monitor my server
Why?
I wanted a way to monitor my Linux node in a visually appealing way. I saw that Grafana is widely used as an observability tool to collect data, examine logs and metrics. I figured this would be a great opportunity to gain experience using an industry-standard platform.
How?
I set up an account with Grafana Cloud's free tier. Inside the Grafana Cloud portal, I chose Add new connection in the sidebar. Under Integrations I chose Linux Server and followed the wizard to install Grafana Alloy locally on my server, first generating an API token. The wizard on Grafana Cloud has a Test Alloy connection button which will throw an error that I (learned to) ignore, because Alloy has to be configured with a file that comes in the next few steps.
I chose Include logs under Make optional selections, include alerts and Advanced set-up as I'm running the integration on a remote host (through SSH).
To copy and append the given code snippets, I used:
sudo nano /etc/alloy/config.alloy
After that, I restarted the service:
sudo systemctl restart alloy.service
I also allowed port 443 through ufw to allow outbound HTTPS, which I probably should have done before installation:
sudo ufw ...
I restarted the service and enabled it on boot:
sudo systemctl restart alloy.service
sudo systemctl enable alloy
After getting a successful Test connection, I installed the pre-configured dashboards and alerts. A snapshot of the overview dashboard can be seen here.
-
Learning Curve:
- Allowing port 443: I didn't know Grafana needs this port open for my server to be able to send out data to the Cloud instance
- Wizard mix-ups: I initially confused a local instance installation guide with the Grafana Cloud wizard, leading to errors in testing the connection
Conclusion
Grafana looks like a complex tool (and it is!). I feel I've barely started on all its possibilities. My next steps are to configure alerting, integrating it with Slack as opposed to email.