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
- 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
- Monitor proactively
- Set up meaningful alerts
- Track user-facing metrics
- Monitor third-party dependencies
- Maintain runbooks for incidents
- Review logs regularly
- Test alerting systems