Skip to main content

Monitoring

Overview

Monitor application health, performance, and errors.

Monitoring Tools

Application Monitoring

  • Laravel Telescope: Development debugging
  • Sentry: Error tracking
  • New Relic: APM
  • DataDog: Full-stack monitoring

Infrastructure Monitoring

  • Prometheus + Grafana: Metrics and dashboards
  • CloudWatch: AWS monitoring
  • Uptime Robot: Availability monitoring

Key Metrics

Application Metrics

  • Request rate
  • Response time
  • Error rate
  • Database query performance
  • Queue job processing

Infrastructure Metrics

  • CPU usage
  • Memory usage
  • Disk space
  • Network throughput
  • Database connections

Business Metrics

  • Active users
  • New registrations
  • API usage
  • Feature adoption

Error Tracking

Sentry Integration

// config/app.php
'providers' => [
Sentry\Laravel\ServiceProvider::class,
],
SENTRY_LARAVEL_DSN=your-sentry-dsn

Logging

Log Channels

// config/logging.php
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['daily', 'slack'],
],
],

Structured Logging

Log::info('User logged in', [
'user_id' => $user->id,
'ip' => request()->ip(),
]);

Alerts

Alert Conditions

  • High error rate
  • Slow response times
  • Database connection issues
  • Disk space low
  • High CPU/memory usage

Alert Channels

  • Email
  • Slack
  • PagerDuty
  • SMS

Health Checks

Route::get('/health', function () {
return response()->json([
'status' => 'healthy',
'database' => DB::connection()->getPdo() ? 'ok' : 'error',
'cache' => Cache::has('test') ? 'ok' : 'error',
]);
});

Best Practices

  1. Monitor proactively
  2. Set up meaningful alerts
  3. Track user-facing metrics
  4. Monitor third-party dependencies
  5. Maintain runbooks for incidents
  6. Review logs regularly
  7. Test alerting systems