SYS://VISION.ACTIVE
VIEWPORT.01
LAT 28.0222° N
SIGNAL.NOMINAL
VISION Loading
Back to Blog

Server Monitoring and Alerting: Knowing Before Users Do

Shane Barron

Shane Barron

Laravel Developer & AI Integration Specialist

You Can't Fix What You Can't See

Production systems need monitoring. Without it, you learn about problems from angry users. Good monitoring catches issues early and provides data for debugging.

Key Metrics

System Metrics

  • CPU usage
  • Memory usage
  • Disk space and I/O
  • Network traffic

Application Metrics

  • Request rate
  • Error rate
  • Response time (p50, p95, p99)
  • Queue depth and processing time

Business Metrics

  • Active users
  • Transaction volume
  • Conversion rates

Laravel Pulse Integration

// Built-in monitoring with Laravel Pulse
composer require laravel/pulse
php artisan pulse:install

// Access at /pulse
// Shows: slow requests, exceptions, queues, cache stats

External Monitoring

// Health check endpoint
Route::get('/health', function () {
    $checks = [
        'database' => $this->checkDatabase(),
        'cache' => $this->checkCache(),
        'queue' => $this->checkQueue(),
        'storage' => $this->checkStorage(),
    ];

    $healthy = collect($checks)->every(fn ($c) => $c['status'] === 'ok');

    return response()->json([
        'status' => $healthy ? 'healthy' : 'degraded',
        'checks' => $checks,
    ], $healthy ? 200 : 503);
});

Alerting Rules

// Example Prometheus alerting rules
groups:
  - name: laravel
    rules:
      - alert: HighErrorRate
        expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.1
        for: 5m
        labels:
          severity: critical
        annotations:
          summary: High error rate detected

      - alert: SlowResponseTime
        expr: histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m])) > 2
        for: 10m
        labels:
          severity: warning

Log Aggregation

// Structured logging
Log::info('Order processed', [
    'order_id' => $order->id,
    'total' => $order->total,
    'processing_time_ms' => $timer->elapsed(),
]);

// Ship to centralized logging (ELK, Datadog, etc.)

Conclusion

Monitoring is essential for production systems. Track system, application, and business metrics. Set up alerts for anomalies. Aggregate logs for debugging. Know about problems before your users do.

Share this article
Shane Barron

Shane Barron

Strategic Technology Architect with 40 years of experience building production systems. Specializing in Laravel, AI integration, and enterprise architecture.

Need Help With Your Project?

I respond to all inquiries within 24 hours. Let's discuss how I can help build your production-ready system.

Get In Touch