Monitoring & Observability
Grafana is an extremely powerful visualization tool that can be used to create dashboards and graphs from a variety of data sources to monitor your homelab.
When combined with Loki for log aggregation and Prometheus for metrics collection, you can create a comprehensive monitoring solution. Both Loki and Prometheus use separate agents to collect data: Alloy for logs and Telegraf for metrics, as well as extra optional exporters for Prometheus to collect specific data points.
All of these applications create a network of observability, but can be confusing to wrap your head around. This guide will help you understand how these applications work together, and how to get them set up as painlessly as possible.
Applications
Section titled “Applications”None of these are strictly required, but some are dependent on one another. For example, None if the specific Prometheus exporters are required if you aren’t interested in those metrics, but Prometheus itself is required to use them.
- Grafana: Visualization tool for creating dashboards and graphs.
- Loki: Log aggregation system that collects and stores logs from various sources.
- Alloy: Log collector that sends logs to Loki.
- Prometheus: Metrics server that collects and stores metrics data.
- Telegraf: Metrics collector that sends metrics to Prometheus.
- Prometheus_hddtemp: Exporter for collecting hard drive temperature metrics.
- Prometheus_smartctl: Exporter for collecting SMART data from hard drives.
- Prometheus_speedtest: Exporter for collecting internet speed test metrics.
Application Visualization
Section titled “Application Visualization”With so many different applications working together, it can be hard to visualize how they all connect.
graph TD Grafana["Grafana (Visualization)"] Loki["Loki (Log Aggregator)"] Alloy["Alloy (Log Collector)"] Prometheus["Prometheus (Metrics Server)"] Prometheus_HDDTemp[HDDTemp] Prometheus_Smartctl[Smartctl] Prometheus_Speedtest[Speedtest] Telegraf["Telegraf (Metrics Collector)"] Alloy --> Loki Loki --> Grafana Prometheus --> Grafana Prometheus_HDDTemp --> Prometheus Prometheus_Smartctl --> Prometheus Prometheus_Speedtest --> Prometheus Telegraf --> Prometheus click Grafana "../applications/grafana" click Loki "../applications/loki" click Alloy "../applications/alloy" click Telegraf "../applications/telegraf" click Prometheus "../applications/prometheus" click Prometheus_HDDTemp "../applications/prometheus_hddtemp" click Prometheus_Smartctl "../applications/prometheus_smartctl" click Prometheus_Speedtest "../applications/prometheus_speedtest"
Application Setup
Section titled “Application Setup”To enable the entire monitoring stack, add the following to your inventories/[your_inventory]/group_vars/homelab.yml file:
grafana_enabled: true
loki_enabled: truealloy_enabled: true
prometheus_enabled: truetelegraf_enabled: trueprometheus_hddtemp_enabled: trueprometheus_smartctl_enabled: trueprometheus_speedtest_enabled: trueThe next time you run the playbook, all of the applications will be installed.