Symptômes les plus fréquents après (dés)activation de Loki ou changement de format des journaux Caddy :
1. « NO DATA » sur le tableau de bord Caddy malgré les requêtes entrantes.
Vérifiez toute la chaîne d’ingestion, de bout en bout :
# On the Caddy host: is Alloy running? reading files?
sudo systemctl status alloy --no-pager
sudo journalctl -u alloy -n 100 --no-pager | grep -iE 'error|permission'
ls -la /var/log/caddy/access-*.log # must be caddy:caddy
# On the monitoring host itself, or from the tailnet: is Loki receiving?
# (replace <IP> with the monitoring host's internal IP, Loki does NOT
# bind on 127.0.0.1 — see http_listen_address = bindAddr. From a plain
# LAN client the connection is refused, by design.)
curl -s http://<IP>:3100/loki/api/v1/labels | jq
curl -sG http://<IP>:3100/loki/api/v1/query \
--data-urlencode 'query={job="caddy"}' | jq '.data.result | length'
Une réponse vide sur /loki/api/v1/* alors que /ready répond 200 signifie que le frontend annonce une mauvaise adresse (voir common.instance_addr) ; journalctl -u loki | grep frontend= l’indique. Redémarrez Loki après correction.
2. alloy.service: mkdir data-alloy/remotecfg: permission denied.
Propriétaire orphelin de /var/lib/alloy, hérité d’un ancien DynamicUser.
Le service ExecStartPre le corrige normalement, mais s’il reste bloqué (unité en start-limit-hit, par exemple) :
sudo systemctl stop alloy
sudo chown -R caddy:caddy /var/lib/alloy
sudo systemctl reset-failed alloy
sudo systemctl start alloy
3. Grafana refuse de démarrer : Datasource provisioning error: data source not found. Conflit d’UID dans la base SQLite après un changement de provisionnement
(typiquement le passage d’un UID généré automatiquement à uid = "loki").
L’option deleteDatasources gère ce cas en théorie ; sinon, purge manuelle :
sudo systemctl stop grafana
sudo sqlite3 /var/lib/grafana/grafana.db \
"DELETE FROM data_source WHERE name='Loki';"
sudo systemctl reset-failed grafana
sudo systemctl start grafana
4. Fichiers de journaux Caddy obsolètes (ancien nommage avec : ou ancien schéma, par exemple
access-http:__nextcloud.log). Sans danger, mais ils polluent la sortie du suivi Alloy.
Nettoyez après une migration :
sudo rm /var/log/caddy/access-{http,https}:__*.log
sudo rm /var/log/caddy/access-:*.log # variants `:80`, `:443`
sudo systemctl reload caddy # optional