# Configuration des métriques - Veza Platform
# Définit les métriques à collecter et les seuils d'alerte

# Configuration globale
global:
  project_name: "Veza Platform"
  version: "1.0.0"
  environment: "development"
  collection_interval: "60s"
  retention_period: "30d"

# Métriques de performance
performance:
  # Latence API
  api_latency:
    enabled: true
    threshold:
      warning: 100  # ms
      critical: 200  # ms
    percentiles: [50, 90, 95, 99]
    
  # Throughput
  throughput:
    enabled: true
    threshold:
      warning: 1000  # req/s
      critical: 5000  # req/s
      
  # Mémoire
  memory_usage:
    enabled: true
    threshold:
      warning: 80  # %
      critical: 95  # %
      
  # CPU
  cpu_usage:
    enabled: true
    threshold:
      warning: 70  # %
      critical: 90  # %
      
  # Disque
  disk_usage:
    enabled: true
    threshold:
      warning: 80  # %
      critical: 95  # %

# Métriques de qualité
quality:
  # Couverture de tests
  test_coverage:
    enabled: true
    threshold:
      warning: 70  # %
      critical: 50  # %
    targets:
      backend: 80
      frontend: 75
      rust: 85
      
  # Complexité cyclomatique
  cyclomatic_complexity:
    enabled: true
    threshold:
      warning: 10
      critical: 15
      
  # Duplication de code
  code_duplication:
    enabled: true
    threshold:
      warning: 5  # %
      critical: 10  # %
      
  # Dette technique
  technical_debt:
    enabled: true
    threshold:
      warning: 100  # points
      critical: 200  # points

# Métriques de sécurité
security:
  # Vulnérabilités
  vulnerabilities:
    enabled: true
    threshold:
      warning: 1
      critical: 0
    severity:
      critical: 0
      high: 0
      medium: 1
      low: 5
      
  # Secrets détectés
  secrets_detected:
    enabled: true
    threshold:
      warning: 0
      critical: 0
      
  # Licences
  license_compliance:
    enabled: true
    threshold:
      warning: 5
      critical: 10
    allowed_licenses:
      - "MIT"
      - "Apache-2.0"
      - "BSD-3-Clause"
      - "ISC"
      - "GPL-3.0"

# Métriques de disponibilité
availability:
  # Uptime
  uptime:
    enabled: true
    threshold:
      warning: 99.0  # %
      critical: 95.0  # %
      
  # Health checks
  health_checks:
    enabled: true
    threshold:
      warning: 95.0  # %
      critical: 90.0  # %
    endpoints:
      - "/health"
      - "/api/health"
      - "/metrics"
      
  # Erreurs
  error_rate:
    enabled: true
    threshold:
      warning: 1.0  # %
      critical: 5.0  # %

# Métriques métier
business:
  # Utilisateurs actifs
  active_users:
    enabled: true
    threshold:
      warning: 100
      critical: 50
    period: "24h"
    
  # Sessions
  sessions:
    enabled: true
    threshold:
      warning: 1000
      critical: 500
    period: "24h"
    
  # Revenus
  revenue:
    enabled: true
    threshold:
      warning: 1000  # $
      critical: 500  # $
    period: "24h"
    
  # Conversions
  conversion_rate:
    enabled: true
    threshold:
      warning: 5.0  # %
      critical: 2.0  # %

# Métriques d'infrastructure
infrastructure:
  # Conteneurs
  containers:
    enabled: true
    threshold:
      warning: 80  # %
      critical: 95  # %
    metrics:
      - "cpu_usage"
      - "memory_usage"
      - "disk_usage"
      
  # Base de données
  database:
    enabled: true
    threshold:
      warning: 80  # %
      critical: 95  # %
    metrics:
      - "connection_pool"
      - "query_time"
      - "lock_wait"
      
  # Cache
  cache:
    enabled: true
    threshold:
      warning: 80  # %
      critical: 95  # %
    metrics:
      - "hit_rate"
      - "memory_usage"
      - "eviction_rate"

# Métriques des agents IA
agents:
  # Planner
  planner:
    enabled: true
    metrics:
      - "tasks_processed"
      - "prioritization_time"
      - "rice_scores_calculated"
    threshold:
      warning: 10  # tasks/min
      critical: 5  # tasks/min
      
  # Researcher
  researcher:
    enabled: true
    metrics:
      - "research_queries"
      - "sources_analyzed"
      - "findings_generated"
    threshold:
      warning: 5  # queries/min
      critical: 2  # queries/min
      
  # Implementer
  implementer:
    enabled: true
    metrics:
      - "code_commits"
      - "tests_written"
      - "builds_successful"
    threshold:
      warning: 2  # commits/hour
      critical: 1  # commits/hour
      
  # QA
  qa:
    enabled: true
    metrics:
      - "tests_executed"
      - "bugs_found"
      - "coverage_improved"
    threshold:
      warning: 50  # tests/hour
      critical: 25  # tests/hour
      
  # Docs
  docs:
    enabled: true
    metrics:
      - "pages_updated"
      - "diagrams_generated"
      - "links_verified"
    threshold:
      warning: 5  # pages/hour
      critical: 2  # pages/hour
      
  # Maintainer
  maintainer:
    enabled: true
    metrics:
      - "dependencies_updated"
      - "security_patches"
      - "cleanup_tasks"
    threshold:
      warning: 10  # tasks/hour
      critical: 5  # tasks/hour

# Configuration des alertes
alerts:
  # Canaux de notification
  channels:
    email:
      enabled: false
      recipients:
        - "dev-team@veza-platform.com"
        - "tech-lead@veza-platform.com"
        
    slack:
      enabled: false
      webhook_url: "${SLACK_WEBHOOK_URL}"
      channel: "#veza-platform"
      
    github:
      enabled: true
      repository: "okinrev/veza-full-stack"
      create_issues: true
      
  # Règles d'alerte
  rules:
    - name: "High API Latency"
      condition: "api_latency > 200ms"
      severity: "critical"
      channels: ["slack", "github"]
      
    - name: "Low Test Coverage"
      condition: "test_coverage < 50%"
      severity: "critical"
      channels: ["email", "github"]
      
    - name: "Security Vulnerability"
      condition: "vulnerabilities > 0"
      severity: "critical"
      channels: ["email", "slack", "github"]
      
    - name: "High Memory Usage"
      condition: "memory_usage > 95%"
      severity: "warning"
      channels: ["slack"]
      
    - name: "Agent Performance"
      condition: "agent_tasks < 5/hour"
      severity: "warning"
      channels: ["github"]

# Configuration des tableaux de bord
dashboards:
  # Tableau de bord principal
  main:
    enabled: true
    refresh_interval: "30s"
    panels:
      - "api_latency"
      - "throughput"
      - "error_rate"
      - "active_users"
      
  # Tableau de bord des agents
  agents:
    enabled: true
    refresh_interval: "60s"
    panels:
      - "agent_tasks"
      - "agent_performance"
      - "agent_errors"
      
  # Tableau de bord de sécurité
  security:
    enabled: true
    refresh_interval: "5m"
    panels:
      - "vulnerabilities"
      - "secrets_detected"
      - "license_compliance"

# Configuration des rapports
reports:
  # Rapport quotidien
  daily:
    enabled: true
    schedule: "0 9 * * *"
    recipients:
      - "dev-team@veza-platform.com"
    metrics:
      - "performance_summary"
      - "quality_summary"
      - "security_summary"
      
  # Rapport hebdomadaire
  weekly:
    enabled: true
    schedule: "0 9 * * 1"
    recipients:
      - "tech-lead@veza-platform.com"
      - "product-manager@veza-platform.com"
    metrics:
      - "trend_analysis"
      - "agent_performance"
      - "business_metrics"
      
  # Rapport mensuel
  monthly:
    enabled: true
    schedule: "0 9 1 * *"
    recipients:
      - "cto@veza-platform.com"
      - "ceo@veza-platform.com"
    metrics:
      - "comprehensive_analysis"
      - "predictive_insights"
      - "recommendations"

# Configuration des exports
exports:
  # Prometheus
  prometheus:
    enabled: true
    endpoint: "/metrics"
    port: 9090
    
  # Grafana
  grafana:
    enabled: true
    port: 3000
    datasource: "prometheus"
    
  # Elasticsearch
  elasticsearch:
    enabled: true
    index: "veza-platform-metrics"
    retention: "30d"
