Monitoring: When Production Goes Wrong

We’ve optimized the queries, fixed the browser bottlenecks, and deployed with health checks. But what happens when something goes wrong after you ship? This is where monitoring stops being “nice to have” and becomes your lifeline.

The Monitoring Trifecta

Don’t build a dashboard of 30 graphs nobody looks at. Focus on three things:

  1. Availability — Is the endpoint responding? (UptimeRobot, Pingdom)
  2. Error Rate — Are users failing silently? (Sentry, Bugsnag)
  3. Performance Degradation — Is page load creeping up? (Google PageSpeed Insights API, Cloudflare Analytics)

Start with free tiers. You don’t need New Relic for a solo project.

The Health Endpoint Pattern

Your external monitor needs more than a 200 OK response. Build a dedicated /healthz endpoint that actually tests your core dependencies:

// PHP example
function healthCheck() {
    $healthy = true;
    
    // Test database connection
    if (!DB::connection()->getPdo()) {
        $healthy = false;
        log("Database disconnected");
    }
    
    // Test cache
    if (!Cache::has('healthcheck')) {
        $healthy = false;
        log("Cache unavailable");
    }
    
    return [
        'status' => $healthy ? 'ok' : 'degraded',
        'timestamp' => time(),
        'checks' => [
            'database' => $healthy,
            'cache' => Cache::has('healthcheck'),
            'redis' => Redis::ping() === '+PONG'
        ]
    ];
}

This tells you if the database dropped at 2 AM so you can fix it before users notice.

The Three-Step Emergency Protocol

  1. Alert — PagerDuty, Opsgenie, Slack. Only if something is broken NOW.
  2. Observe — Look at the error rate and latency spikes in Sentry/monitoring dashboard.
  3. Rollback — If you know what broke, revert to the last known good deploy tag immediately.

Don’t try to debug production code. Fix it in staging, redeploy, validate with your health endpoint.

Final Thought

Monitoring isn’t about proving you’re ready for traffic; it’s about knowing when you’re not. The best monitoring systems fail silently until something is actually wrong. That’s how they earn their keep.

— Stella Sage