align for IA agents + grafana
This commit is contained in:
parent
a5fcd69fbc
commit
4d06fb96b6
205
IA_agents/diagnostic-loki-unhealthy.md
Normal file
205
IA_agents/diagnostic-loki-unhealthy.md
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
# Diagnostic : Loki Unhealthy - Causes et Solutions
|
||||||
|
|
||||||
|
## 🔍 Analyse du Problème
|
||||||
|
|
||||||
|
### **Symptômes Observés**
|
||||||
|
- Loki démarre et fonctionne (logs normaux)
|
||||||
|
- Endpoint `/ready` retourne "ready" depuis l'intérieur du conteneur
|
||||||
|
- Healthcheck externe retourne HTTP 503 "Service Unavailable"
|
||||||
|
- Message d'erreur : "Ingester not ready: waiting for 15s after being ready"
|
||||||
|
- Healthcheck Docker marque le service comme "unhealthy"
|
||||||
|
|
||||||
|
### **Cause Racine Identifiée**
|
||||||
|
Loki a un **délai d'attente de 15 secondes** après être "prêt" avant que l'endpoint `/ready` retourne un code HTTP 200. Pendant cette période, il retourne HTTP 503.
|
||||||
|
|
||||||
|
## 🚨 Raisons Possibles pour Loki Unhealthy
|
||||||
|
|
||||||
|
### **1. Délai de Démarrage Insuffisant (PRINCIPAL)**
|
||||||
|
```bash
|
||||||
|
# Configuration actuelle
|
||||||
|
start_period: 60s
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
```
|
||||||
|
|
||||||
|
**Problème** : Loki prend plus de 60 secondes pour être complètement prêt
|
||||||
|
**Solution** : Augmenter le `start_period`
|
||||||
|
|
||||||
|
### **2. Configuration Loki Incomplète**
|
||||||
|
- Fichier de configuration manquant ou incorrect
|
||||||
|
- Variables d'environnement non définies
|
||||||
|
- Permissions sur les volumes incorrectes
|
||||||
|
|
||||||
|
### **3. Ressources Système Insuffisantes**
|
||||||
|
- Mémoire insuffisante pour Loki
|
||||||
|
- CPU surchargé
|
||||||
|
- Espace disque insuffisant
|
||||||
|
|
||||||
|
### **4. Problème de Réseau**
|
||||||
|
- Port 3100 bloqué ou en conflit
|
||||||
|
- Configuration réseau Docker incorrecte
|
||||||
|
- Firewall bloquant les connexions
|
||||||
|
|
||||||
|
### **5. Configuration Healthcheck Incorrecte**
|
||||||
|
- Timeout trop court (10s)
|
||||||
|
- Intervalle trop fréquent (30s)
|
||||||
|
- Retries insuffisantes (3)
|
||||||
|
|
||||||
|
### **6. Problème de Configuration Loki**
|
||||||
|
- Configuration par défaut inadaptée
|
||||||
|
- Paramètres de stockage incorrects
|
||||||
|
- Configuration des composants (ingester, distributor, etc.)
|
||||||
|
|
||||||
|
## 🔧 Solutions Proposées
|
||||||
|
|
||||||
|
### **Solution 1: Augmenter le Start Period (RECOMMANDÉE)**
|
||||||
|
```yaml
|
||||||
|
loki:
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "sh", "-c", "if curl -f http://localhost:3100/ready >/dev/null 2>&1; then echo 'Loki ready: Log aggregation service responding'; exit 0; else echo 'Loki starting: Log aggregation service not yet ready'; exit 1; fi"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 15s # Augmenté de 10s à 15s
|
||||||
|
retries: 5 # Augmenté de 3 à 5
|
||||||
|
start_period: 120s # Augmenté de 60s à 120s
|
||||||
|
```
|
||||||
|
|
||||||
|
### **Solution 2: Healthcheck Alternatif**
|
||||||
|
```yaml
|
||||||
|
loki:
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "sh", "-c", "if wget -q --spider http://localhost:3100/ready; then echo 'Loki ready: Log aggregation service responding'; exit 0; else echo 'Loki starting: Log aggregation service not yet ready'; exit 1; fi"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 15s
|
||||||
|
retries: 5
|
||||||
|
start_period: 120s
|
||||||
|
```
|
||||||
|
|
||||||
|
### **Solution 3: Healthcheck Simplifié**
|
||||||
|
```yaml
|
||||||
|
loki:
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "sh", "-c", "wget -q --spider http://localhost:3100/ready"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 15s
|
||||||
|
retries: 5
|
||||||
|
start_period: 120s
|
||||||
|
```
|
||||||
|
|
||||||
|
### **Solution 4: Configuration Loki Optimisée**
|
||||||
|
```yaml
|
||||||
|
loki:
|
||||||
|
command: -config.file=/etc/loki/local-config.yaml -server.http-listen-port=3100 -server.grpc-listen-port=9096
|
||||||
|
environment:
|
||||||
|
- LOKI_READY_DELAY=5s
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🧪 Tests de Diagnostic
|
||||||
|
|
||||||
|
### **Test 1: Vérifier la Configuration**
|
||||||
|
```bash
|
||||||
|
# Vérifier la configuration Loki
|
||||||
|
docker exec loki cat /etc/loki/local-config.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
### **Test 2: Vérifier les Ressources**
|
||||||
|
```bash
|
||||||
|
# Vérifier l'utilisation des ressources
|
||||||
|
docker stats loki
|
||||||
|
```
|
||||||
|
|
||||||
|
### **Test 3: Vérifier les Logs Détaillés**
|
||||||
|
```bash
|
||||||
|
# Logs avec plus de détails
|
||||||
|
docker logs loki --tail 100
|
||||||
|
```
|
||||||
|
|
||||||
|
### **Test 4: Test de Connectivité**
|
||||||
|
```bash
|
||||||
|
# Test depuis l'extérieur
|
||||||
|
curl -v http://localhost:3100/ready
|
||||||
|
|
||||||
|
# Test depuis l'intérieur
|
||||||
|
docker exec loki wget -q -O- http://localhost:3100/ready
|
||||||
|
```
|
||||||
|
|
||||||
|
### **Test 5: Vérifier les Volumes**
|
||||||
|
```bash
|
||||||
|
# Vérifier les permissions des volumes
|
||||||
|
docker exec loki ls -la /loki
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📊 Configuration Recommandée
|
||||||
|
|
||||||
|
### **Healthcheck Optimisé**
|
||||||
|
```yaml
|
||||||
|
loki:
|
||||||
|
image: grafana/loki:latest
|
||||||
|
container_name: loki
|
||||||
|
ports:
|
||||||
|
- "0.0.0.0:3100:3100"
|
||||||
|
volumes:
|
||||||
|
- loki_data:/loki
|
||||||
|
command: -config.file=/etc/loki/local-config.yaml
|
||||||
|
networks:
|
||||||
|
btcnet:
|
||||||
|
aliases:
|
||||||
|
- loki
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "sh", "-c", "if wget -q --spider http://localhost:3100/ready; then echo 'Loki ready: Log aggregation service responding'; exit 0; else echo 'Loki starting: Log aggregation service not yet ready'; exit 1; fi"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 15s
|
||||||
|
retries: 5
|
||||||
|
start_period: 120s
|
||||||
|
restart: unless-stopped
|
||||||
|
```
|
||||||
|
|
||||||
|
### **Variables d'Environnement**
|
||||||
|
```yaml
|
||||||
|
loki:
|
||||||
|
environment:
|
||||||
|
- LOKI_READY_DELAY=5s
|
||||||
|
- LOKI_LOG_LEVEL=info
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🎯 Plan d'Action
|
||||||
|
|
||||||
|
### **Étape 1: Diagnostic Immédiat**
|
||||||
|
1. Vérifier la configuration actuelle
|
||||||
|
2. Analyser les logs détaillés
|
||||||
|
3. Tester la connectivité
|
||||||
|
|
||||||
|
### **Étape 2: Application des Corrections**
|
||||||
|
1. Augmenter le `start_period` à 120s
|
||||||
|
2. Augmenter le `timeout` à 15s
|
||||||
|
3. Augmenter les `retries` à 5
|
||||||
|
|
||||||
|
### **Étape 3: Test et Validation**
|
||||||
|
1. Redémarrer Loki
|
||||||
|
2. Surveiller le healthcheck
|
||||||
|
3. Vérifier le statut final
|
||||||
|
|
||||||
|
### **Étape 4: Optimisation Continue**
|
||||||
|
1. Ajuster les paramètres si nécessaire
|
||||||
|
2. Documenter les améliorations
|
||||||
|
3. Mettre à jour la configuration
|
||||||
|
|
||||||
|
## 🔍 Points d'Attention
|
||||||
|
|
||||||
|
### **Signaux d'Alerte**
|
||||||
|
- Healthcheck qui échoue constamment
|
||||||
|
- Logs d'erreur dans Loki
|
||||||
|
- Ressources système élevées
|
||||||
|
- Timeouts fréquents
|
||||||
|
|
||||||
|
### **Indicateurs de Succès**
|
||||||
|
- Healthcheck "healthy" stable
|
||||||
|
- Endpoint `/ready` retourne HTTP 200
|
||||||
|
- Logs Loki normaux
|
||||||
|
- Performance acceptable
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Document créé le 2025-09-21**
|
||||||
|
**Version** : 1.0
|
||||||
|
**Diagnostic** : Loki Unhealthy Analysis
|
174
IA_agents/loki-health-starting-analysis.md
Normal file
174
IA_agents/loki-health-starting-analysis.md
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
# Analyse : Que fait Loki pendant "health: starting" ?
|
||||||
|
|
||||||
|
## 🔍 Situation Observée
|
||||||
|
|
||||||
|
### **État Actuel**
|
||||||
|
- **Statut Docker** : `Up X seconds (health: starting)`
|
||||||
|
- **Endpoint /ready** : Retourne HTTP 200 et "ready" ✅
|
||||||
|
- **Logs Loki** : Fonctionnement normal ✅
|
||||||
|
- **Healthcheck Docker** : Continue d'échouer ❌
|
||||||
|
|
||||||
|
### **Incohérence Détectée**
|
||||||
|
```bash
|
||||||
|
# Test manuel depuis l'extérieur - SUCCÈS
|
||||||
|
curl -s http://localhost:3100/ready # → "ready"
|
||||||
|
|
||||||
|
# Test manuel depuis l'intérieur - SUCCÈS
|
||||||
|
docker exec loki wget -q -O- http://localhost:3100/ready # → "ready"
|
||||||
|
|
||||||
|
# Healthcheck Docker - ÉCHEC
|
||||||
|
# Retourne : "Loki starting: Log aggregation service not yet ready"
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🕐 Ce que Loki Attend Pendant "health: starting"
|
||||||
|
|
||||||
|
### **1. Start Period (120 secondes)**
|
||||||
|
Loki est dans la période de grâce où Docker n'évalue pas encore le healthcheck comme définitif :
|
||||||
|
- **Durée** : 120 secondes depuis le démarrage
|
||||||
|
- **Comportement** : Docker ignore les échecs de healthcheck
|
||||||
|
- **Statut** : "health: starting" → "healthy" ou "unhealthy"
|
||||||
|
|
||||||
|
### **2. Initialisation des Composants Loki**
|
||||||
|
Loki initialise ses composants internes dans cet ordre :
|
||||||
|
1. **Configuration** : Lecture du fichier de configuration
|
||||||
|
2. **Stockage** : Initialisation des volumes et index
|
||||||
|
3. **Ingester** : Composant de réception des logs
|
||||||
|
4. **Distributor** : Composant de distribution
|
||||||
|
5. **Query Frontend** : Interface de requête
|
||||||
|
6. **Table Manager** : Gestion des tables d'index
|
||||||
|
|
||||||
|
### **3. Processus de Démarrage Observé**
|
||||||
|
```bash
|
||||||
|
# Logs typiques pendant le démarrage
|
||||||
|
level=info msg="starting recalculate owned streams job"
|
||||||
|
level=info msg="completed recalculate owned streams job"
|
||||||
|
level=info msg="uploading tables" index-store=tsdb-2020-10-24
|
||||||
|
level=info msg="flushing stream" component=ingester
|
||||||
|
```
|
||||||
|
|
||||||
|
### **4. Délai d'Attente Ingester**
|
||||||
|
Loki a un **délai d'attente de l'ingester** après être "prêt" :
|
||||||
|
- **Message** : "Ingester not ready: waiting for 15s after being ready"
|
||||||
|
- **Durée** : 15 secondes supplémentaires
|
||||||
|
- **Raison** : Stabilisation des composants internes
|
||||||
|
|
||||||
|
## 🚨 Problème Identifié : Healthcheck Docker Défaillant
|
||||||
|
|
||||||
|
### **Cause Racine**
|
||||||
|
Le healthcheck Docker ne fonctionne pas correctement malgré :
|
||||||
|
- Loki fonctionnel
|
||||||
|
- Endpoint /ready accessible
|
||||||
|
- Configuration healthcheck corrigée
|
||||||
|
|
||||||
|
### **Hypothèses**
|
||||||
|
1. **Problème de timing** : Healthcheck s'exécute à un mauvais moment
|
||||||
|
2. **Problème d'environnement** : Différence d'environnement d'exécution
|
||||||
|
3. **Problème de cache Docker** : Cache healthcheck corrompu
|
||||||
|
4. **Problème de réseau interne** : Connectivité réseau Docker
|
||||||
|
|
||||||
|
## 🔧 Solutions Proposées
|
||||||
|
|
||||||
|
### **Solution 1: Healthcheck Simplifié (RECOMMANDÉE)**
|
||||||
|
```yaml
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3100/ready"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 15s
|
||||||
|
retries: 5
|
||||||
|
start_period: 120s
|
||||||
|
```
|
||||||
|
|
||||||
|
### **Solution 2: Healthcheck avec Logging Détaillé**
|
||||||
|
```yaml
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "sh", "-c", "echo 'Testing Loki readiness...' && wget -q --spider http://localhost:3100/ready && echo 'Loki ready' || (echo 'Loki not ready' && exit 1)"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 15s
|
||||||
|
retries: 5
|
||||||
|
start_period: 120s
|
||||||
|
```
|
||||||
|
|
||||||
|
### **Solution 3: Healthcheck Alternative (Metrics)**
|
||||||
|
```yaml
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "sh", "-c", "wget -q --spider http://localhost:3100/metrics || wget -q --spider http://localhost:3100/ready"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 15s
|
||||||
|
retries: 5
|
||||||
|
start_period: 120s
|
||||||
|
```
|
||||||
|
|
||||||
|
### **Solution 4: Pas de Healthcheck (Temporaire)**
|
||||||
|
```yaml
|
||||||
|
# Commentaire temporaire du healthcheck pour tester
|
||||||
|
# healthcheck:
|
||||||
|
# test: ["CMD", "wget", "-q", "--spider", "http://localhost:3100/ready"]
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📊 Timeline Typique du Démarrage Loki
|
||||||
|
|
||||||
|
### **0-30 secondes : Initialisation**
|
||||||
|
- Démarrage des processus
|
||||||
|
- Lecture de la configuration
|
||||||
|
- Initialisation du stockage
|
||||||
|
|
||||||
|
### **30-60 secondes : Composants**
|
||||||
|
- Démarrage de l'ingester
|
||||||
|
- Démarrage du distributor
|
||||||
|
- Initialisation des tables
|
||||||
|
|
||||||
|
### **60-90 secondes : Stabilisation**
|
||||||
|
- Recalcul des streams
|
||||||
|
- Upload des tables d'index
|
||||||
|
- Flush des streams
|
||||||
|
|
||||||
|
### **90-120 secondes : Finalisation**
|
||||||
|
- Délai d'attente ingester (15s)
|
||||||
|
- Stabilisation finale
|
||||||
|
- Service prêt
|
||||||
|
|
||||||
|
## 🎯 Recommandations
|
||||||
|
|
||||||
|
### **Immédiate**
|
||||||
|
1. **Simplifier le healthcheck** pour éliminer les variables
|
||||||
|
2. **Augmenter les timeouts** si nécessaire
|
||||||
|
3. **Surveiller les logs** pendant le démarrage
|
||||||
|
|
||||||
|
### **À Moyen Terme**
|
||||||
|
1. **Optimiser la configuration Loki** pour un démarrage plus rapide
|
||||||
|
2. **Ajuster les ressources** (mémoire, CPU) si nécessaire
|
||||||
|
3. **Documenter les patterns** de démarrage observés
|
||||||
|
|
||||||
|
### **Monitoring**
|
||||||
|
1. **Surveiller la durée** de démarrage
|
||||||
|
2. **Alerter** si le démarrage prend plus de 2 minutes
|
||||||
|
3. **Documenter** les variations de performance
|
||||||
|
|
||||||
|
## 🔍 Diagnostic Continue
|
||||||
|
|
||||||
|
### **Commandes Utiles**
|
||||||
|
```bash
|
||||||
|
# Vérifier le statut
|
||||||
|
docker compose --env-file .env.master ps loki
|
||||||
|
|
||||||
|
# Vérifier les logs de démarrage
|
||||||
|
docker logs loki --tail 50
|
||||||
|
|
||||||
|
# Tester l'endpoint manuellement
|
||||||
|
curl -s http://localhost:3100/ready
|
||||||
|
|
||||||
|
# Vérifier les healthchecks
|
||||||
|
docker inspect loki --format='{{range .State.Health.Log}}{{.Start}} - {{.ExitCode}}: {{.Output}}{{end}}' | tail -5
|
||||||
|
```
|
||||||
|
|
||||||
|
### **Métriques à Surveiller**
|
||||||
|
- **Temps de démarrage** : < 2 minutes
|
||||||
|
- **Disponibilité endpoint** : /ready retourne "ready"
|
||||||
|
- **Logs d'erreur** : Absence d'erreurs critiques
|
||||||
|
- **Ressources** : Utilisation CPU/mémoire acceptable
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Document créé le 2025-09-21**
|
||||||
|
**Version** : 1.0
|
||||||
|
**Analyse** : Loki Health Starting Process
|
@ -8,6 +8,7 @@ Arrete et nettoie tous les services, images, tests, commandes, éditions... enco
|
|||||||
Toujours veiller à supprimer les fichiers distants non suivis
|
Toujours veiller à supprimer les fichiers distants non suivis
|
||||||
A la fin met bien à jour les documents de `IA_agents/` et ses sous dossiers.
|
A la fin met bien à jour les documents de `IA_agents/` et ses sous dossiers.
|
||||||
Si un processus est en attente alors utiliser les scripts de monitoring, si ils sont peu utiles pour comprendre la raison de l'attente ou la progression, alors améliore les.
|
Si un processus est en attente alors utiliser les scripts de monitoring, si ils sont peu utiles pour comprendre la raison de l'attente ou la progression, alors améliore les.
|
||||||
|
Important : ne simplifie jamais face à un problème mais résout le
|
||||||
|
|
||||||
## Contexte obligatoire
|
## Contexte obligatoire
|
||||||
- Consulte attentivement et chacun des documents de `IA_agents/`
|
- Consulte attentivement et chacun des documents de `IA_agents/`
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 0ee0505ce53085ff1249d19ebc2caf43c06156ad
|
Subproject commit 56a46a516ca33b467f1f51932f6fb9a533628c0f
|
Loading…
x
Reference in New Issue
Block a user