Dashboards
Guide pour créer et gérer les dashboards Grafana.
Dashboards Pré-configurés
Logs Overview
Chemin : Lyroh Apps > Logs Overview
Contient : - Vue d'ensemble des logs par application - Répartition par serveur et environnement - Timeline du volume - Détection des erreurs - Explorateur de logs avec filtres
Créer un Dashboard Applicatif
Template pour NestJS
{
"title": "NestJS Backend Logs",
"panels": [
{
"title": "Logs Stream",
"type": "logs",
"targets": [{
"expr": "{app=\"nestjs-backend\", env=\"$env\"} |= \"$search\""
}]
},
{
"title": "Erreurs par Heure",
"type": "timeseries",
"targets": [{
"expr": "sum(count_over_time({app=\"nestjs-backend\"} |~ \"error\" [$__interval]))"
}]
},
{
"title": "Logs par Niveau",
"type": "piechart",
"targets": [{
"expr": "sum by (level) (count_over_time({app=\"nestjs-backend\"} | json [1h]))"
}]
}
]
}
Template pour Python Scraper
{
"title": "Python Scraper Logs",
"panels": [
{
"title": "Activité du Scraper",
"type": "timeseries",
"targets": [{
"expr": "sum(count_over_time({app=\"python-scraper\"} [$__interval]))"
}]
},
{
"title": "Erreurs de Scraping",
"type": "logs",
"targets": [{
"expr": "{app=\"python-scraper\"} |~ \"(?i)(error|exception|failed)\""
}]
},
{
"title": "URLs Traitées",
"type": "stat",
"targets": [{
"expr": "count_over_time({app=\"python-scraper\"} |~ \"processed|fetched\" [1h])"
}]
}
]
}
Template pour NextJS
{
"title": "NextJS App Logs",
"panels": [
{
"title": "Build & Requests",
"type": "logs",
"targets": [{
"expr": "{app=~\"nextjs-app-.*\", env=\"$env\"}"
}]
},
{
"title": "Erreurs par App",
"type": "bargauge",
"targets": [{
"expr": "sum by (app) (count_over_time({app=~\"nextjs-app-.*\"} |~ \"error\" [1h]))"
}]
}
]
}
Variables de Dashboard
Définir une variable
- Dashboard settings (icône engrenage)
- Variables > Add variable
Variable app
| Paramètre | Valeur |
|---|---|
| Name | app |
| Type | Query |
| Data source | Loki |
| Query | label_values(app) |
| Multi-value | Yes |
| Include All | Yes |
Variable env
| Paramètre | Valeur |
|---|---|
| Name | env |
| Type | Query |
| Data source | Loki |
| Query | label_values(env) |
| Multi-value | No |
| Include All | Yes |
Variable search (texte)
| Paramètre | Valeur |
|---|---|
| Name | search |
| Type | Text box |
| Default | `` (vide) |
Panels Utiles
Compteur d'Erreurs (Stat)
- Unit :
short - Color mode :
Background - Thresholds : 0 (green), 10 (yellow), 50 (red)
Heatmap des Erreurs
- Type : Status history ou Heatmap
Top Erreurs (Table)
Logs Récents (Logs Panel)
Options : - Show time: On - Show labels: On - Wrap lines: On
Organisation
Structure des Dossiers
Dashboards/
├── Lyroh Apps/
│ ├── Logs Overview
│ ├── NestJS Backend
│ ├── Python Scraper
│ └── NextJS Apps
├── Infrastructure/
│ └── Loki Health
└── Alerting/
└── Error Dashboard
Créer un Dossier
- Dashboards > Browse
- New > New folder
- Nommez le dossier
Export / Import
Exporter un Dashboard
- Ouvrez le dashboard
- Share > Export
- Cochez Export for sharing externally
- Save to file
Importer un Dashboard
- Dashboards > Browse
- Import
- Uploadez le fichier JSON ou collez l'ID Grafana.com
Dashboards Communautaires
Grafana.com propose des dashboards prêts à l'emploi :
Pour importer : 1. Copiez l'ID du dashboard 2. Import > Grafana.com dashboard 3. Collez l'ID 4. Sélectionnez la datasource Loki