Phase 4.6 — Monitoring
Provisionnement de la VM via OpenTofu, configuration via Ansible.
Vue d'ensemble
Stack Prometheus + Grafana + Loki pour l'observabilité de l'infrastructure.
| Rôle | Valeur |
|---|---|
| VM | 202 — monitoring (192.168.1.31) |
| Nœud Proxmox | pve02 |
| Groupe Ansible | monitoring |
| Prometheus | Métriques, rétention 30 jours |
| Grafana | Dashboards, auth OIDC via Keycloak |
| Loki + Promtail | Logs système, rétention 2 jours |
1. Provisionnement OpenTofu
# monitoring.tf — appel au module vm
module "monitoring" {
source = "./modules/vm"
name = "monitoring"
target_node = "pve02"
vmid = 202
cores = 2
memory = 4096
balloon = 2048
disk_size = "100G"
ip = "192.168.1.31"
ssh_key = local.ssh_key
depends_on = [module.harbor]
}
Exécution :
cd homelab-proxmox/opentofu
tofu plan -target=module.monitoring -out=tfplan
tofu apply tfplan
2. Configuration Ansible
Stack monitoring
Le playbook ansible/playbooks/06-monitoring.yml applique le rôle monitoring :
ansible-playbook -i inventory/homelab.yml playbooks/06-monitoring.yml
Le rôle monitoring déploie 3 services en Docker :
1. Prometheus — prom/prometheus:v3.2, port 9090, scrape toutes les VMs + Traefik
2. Grafana — grafana/grafana:11.5, port 3000, OIDC Keycloak
3. Loki — grafana/loki:3.4, port 3100, rétention 48h
Variable sensible : grafana_oidc_secret (via Vault).
Node Exporter + Promtail (toutes les VMs)
Le playbook ansible/playbooks/06-node-exporter.yml applique le rôle node_exporter sur toutes les VMs :
ansible-playbook -i inventory/homelab.yml playbooks/06-node-exporter.yml
Installe :
- node_exporter — binaire + service systemd (port 9100), métriques système
- Promtail — binaire + service systemd, collecte /var/log/syslog vers Loki (192.168.1.31:3100)
3. Vérification
curl http://192.168.1.31:9090/api/v1/status/config
curl -I https://grafana.mounik.ovh
curl http://192.168.1.31:3100/ready
Ajouter la datasource Prometheus dans Grafana : http://localhost:9090.
Dashboards recommandés :
| Dashboard | ID |
|---|---|
| Node Exporter Full | 1860 |
| Traefik | 17344 |
Pour aller plus loin
- Phase 2 — OpenTofu — provisioning de toutes les VMs
- Phase 4.7 — DefectDojo — gestion des vulnérabilités
- Playbooks Ansible — dans
ansible/du dépôt