Skip to content

Grafana

Vue d'ensemble

Grafana est une plateforme de visualisation et d'analytics open-source qui permet de créer des dashboards interactifs pour surveiller et analyser des métriques de diverses sources de données.

Avantages clés

  • Multi-datasources : Prometheus, InfluxDB, MySQL, PostgreSQL, etc.
  • Dashboards riches : Visualisations interactives et personnalisables
  • Alerting : Système d'alertes intégré
  • Plugins : Écosystème extensible

Intégration avec Prometheus

# docker-compose.yml
version: '3.8'
services:
  grafana:
    image: grafana/grafana:latest
    ports:
      - "3000:3000"
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=admin123
    volumes:
      - grafana-data:/var/lib/grafana
      - ./datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml
      - ./dashboards.yml:/etc/grafana/provisioning/dashboards/dashboards.yml

volumes:
  grafana-data:

Configuration datasource Prometheus

# datasources.yml
apiVersion: 1
datasources:
  - name: Prometheus
    type: prometheus
    access: proxy
    url: http://prometheus:9090
    isDefault: true

Dashboard pour Laravel

{
  "dashboard": {
    "title": "Laravel Application Metrics",
    "panels": [
      {
        "title": "Request Rate",
        "type": "graph",
        "targets": [
          {
            "expr": "rate(laravel_http_requests_total[5m])",
            "legendFormat": "{{method}} {{route}}"
          }
        ]
      },
      {
        "title": "Response Time",
        "type": "graph",
        "targets": [
          {
            "expr": "histogram_quantile(0.95, rate(laravel_http_request_duration_seconds_bucket[5m]))",
            "legendFormat": "95th percentile"
          }
        ]
      }
    ]
  }
}

Ressources