Why most monitoring alerts arrive too late
The Nagios alert lands in Slack at 3:47 AM. Your API is already timing out. Customers are complaining on Twitter. By the time you SSH in, the damage is done—the metric that triggered the alert was a lagging indicator, not a leading one.
I've seen this pattern in hundreds of support tickets. Teams monitor disk space and get paged when it hits 95%, but the real problem started two hours earlier when I/O wait spiked and writes began queuing. The standard "is it up?" check misses the pressure building inside the system.
Eight specific metrics correlate with imminent failure if you know what thresholds matter. Let's walk through each one, the failure mode it predicts, and how to instrument it.
CPU steal time: the hypervisor tax
Steal time measures CPU cycles your VM requested but the hypervisor gave to another tenant. It shows up in top as %st or in /proc/stat as the steal column. On a healthy VPS, steal time sits below 5%. When it climbs past 10% for sustained periods, your workload is starved.
The failure signature looks like this: API response times increase by 50-200ms even though your application metrics show normal CPU usage. Database queries that usually take 10ms now take 40ms. The problem isn't your code—it's that the hypervisor is scheduling your vCPU less often than you paid for.
Check current steal time:
mpstat 1 5 | grep -i average
Look at the %steal column. Anything consistently above 8% means you're in a noisy neighbor situation or your host is oversubscribed. Some cloud providers let this happen; others are better about isolation.
Set an alert at 10% sustained for five minutes. The remediation is usually vertical scaling to a host with better performance, or switching instance families to one with dedicated CPU credits.
Disk I/O wait: when writes queue faster than they drain
I/O wait is the percentage of time your CPU is idle but waiting on disk operations to complete. You'll see it as %iowait in top or iostat. On SSDs, normal I/O wait runs under 5%. Spinning disks might sit at 10-15% under load.
When iowait climbs past 20%, your disk subsystem is the bottleneck. Applications waiting on writes will start timing out. Databases will slow down. Log writes will queue. The failure usually manifests as:
- Slow SSH logins (PAM writes to wtmp and lastlog)
- Application timeouts on file uploads
- Database commits taking longer than query execution
- Backup scripts that used to finish in an hour now taking four
Check it:
iostat -x 2 5
The %util column shows disk saturation; the await column shows average wait time in milliseconds. If await is consistently above 50ms on an SSD or 20ms on NVMe, you have a problem.
Common causes: undersized IOPS on cloud volumes, a runaway process writing massive logs, or a database checkpoint flush hitting a slow disk. I've seen WordPress sites bring down entire VMs because a plugin decided to write 10GB of debug logs in an hour.
Alert on iowait above 25% for three minutes. Investigate with iotop -o to see which processes are writing.
Network retransmits: the canary in the wire
TCP retransmits happen when a packet is lost or acknowledged too slowly. A small percentage of retransmits is normal—the internet is messy. But when retransmits climb above 1% of total segments, you're looking at congestion, packet loss, or a failing network interface.
The symptom is subtle at first. API calls succeed but take 500ms instead of 50ms. MySQL replication lag grows even though the replica isn't busy. HTTP downloads stall mid-transfer.
Pull retransmit stats:
netstat -s | grep -i retrans
or
ss -ti
The second command shows per-connection stats. Look for retrans counts above zero on active connections.
Calculate retransmit rate:
watch -n 2 'cat /proc/net/snmp | grep Tcp'
Divide RetransSegs by OutSegs. If it's above 0.01 (1%), you have a problem. Causes include:
- MTU mismatches between your server and upstream gateway
- Overloaded NAT gateways or firewalls dropping packets under load
- Bad network cards (I've seen this twice; the NIC firmware was corrupted)
- Congested uplinks at your hosting provider
Alert on retransmit rates above 2% sustained. Remediation depends on where the loss happens—inside your subnet, at the gateway, or upstream.
Memory pressure: when the kernel starts making hard choices
Linux will use all available RAM for caching. That's fine. The problem starts when the kernel's out-of-memory killer (OOM) gets involved or when swap thrashing begins. Both are late-stage symptoms—memory pressure warnings come earlier.
Check pressure stall information (PSI), a kernel feature since 4.20:
cat /proc/pressure/memory
You'll see three lines: some, full, and totals. The some line shows the percentage of time at least one task was stalled waiting for memory. The full line shows when all non-idle tasks were stalled.
If some avg10 is above 10 or full avg10 is above 1, you're in trouble. The kernel is swapping, reclaiming pages aggressively, or about to invoke the OOM killer.
Another angle is monitoring the MemAvailable field in /proc/meminfo. When it drops below 10% of total memory, allocations start to hurt. Applications will slow down as the kernel tries harder to free pages.
OOM kills are catastrophic. The kernel picks a process—often your database or application server—and terminates it. Check dmesg | grep -i oom to see if it's happened recently. If you see "Out of memory: Killed process," you've already had an outage.
Set two alerts: one when PSI memory some avg10 exceeds 5 (early warning), another when MemAvailable drops below 512MB (critical).
API error rates: when 200s become 500s
HTTP status codes are a direct signal. A spike in 500-series errors means your application or its dependencies are failing. But the leading indicator isn't the 500s—it's the subtle rise in 429s (rate limiting) and 503s (service unavailable) before everything falls over.
If you log all HTTP responses, calculate error rate as:
(5xx_count + 429_count) / total_requests
Healthy APIs run at 0.01% error rate or lower. When it climbs to 0.1%, something is degrading. At 1%, you're in an incident.
The failure modes vary:
- Database connection pool exhaustion (your app gets a 500 trying to connect)
- Upstream API timeouts (third-party services are slow)
- Memory pressure causing the app to restart or refuse requests
- Rate limits from a dependency starting to bite
Group errors by endpoint and status code. If one endpoint suddenly jumps from 0.1% errors to 2%, that's your smoking gun. Drill into logs for that endpoint to find the root cause.
Alert on error rate above 0.5% for two minutes. Pair it with p99 latency—if errors are spiking and latency is climbing, you're about to have a bad time.
DNS resolution time: the invisible bottleneck
Every outbound request your application makes usually starts with a DNS lookup. If your resolver is slow or unreachable, every HTTP call, database connection, and API request stalls waiting for name resolution.
Normal DNS queries resolve in under 10ms. When resolution time climbs past 100ms, you're either hitting a slow upstream resolver, experiencing packet loss to your DNS server, or overwhelming your local caching resolver.
Test resolution time:
dig +stats example.com @8.8.8.8 | grep "Query time"
or use nslookup with timing. Run this against your configured resolvers (check /etc/resolv.conf).
If queries take longer than 50ms on average, investigate:
- Is your resolver responding? (
pingthe DNS server IP) - Is the resolver under load? (check query rate if you control it)
- Are you hitting rate limits? (some public resolvers throttle per source IP)
- Is there a firewall between you and the resolver causing packet loss?
Application symptoms include intermittent timeouts, slow startup times (apps often do many DNS lookups on boot), and cascading failures when one slow service call delays ten others.
Run a synthetic DNS check every minute and alert when the average query time exceeds 100ms over five consecutive checks.
Load balancer queue depth: when requests start piling up
A load balancer maintains a queue of incoming requests waiting for a backend to become available. Under normal load, this queue is nearly empty—requests arrive, get dispatched immediately, and complete. When backends slow down or become unavailable, requests queue.
Queue depth is the number of requests waiting. Healthy load balancers run at queue depth zero most of the time. Spikes to 10-20 during traffic bursts are fine if they drain quickly. Sustained queue depths above 50 mean backends can't keep up.
The failure progression:
- Queue depth grows as backends slow down
- New requests wait longer for a backend
- Client timeouts start firing (most HTTP clients wait 30-60 seconds)
- Queue depth hits the limit and the LB starts rejecting requests (503 errors)
How you check this depends on your load balancer. For HAProxy:
echo "show stat" | socat stdio /var/run/haproxy.sock | grep -i qcur
For AWS ALB, check the TargetResponseTime and RequestCount CloudWatch metrics. If average response time is climbing and request count is flat, backends are slow. If you see RejectedConnectionCount increasing, you've already hit the queue limit.
Set alerts at two levels: queue depth above 20 for one minute (warning) and above 100 for 30 seconds (critical). When you get the warning, scale backends or investigate what's slowing them down. By the time you hit critical, users are seeing errors.
Database connection pool saturation: the invisible queue
Most application servers use a connection pool to talk to the database—preallocated connections that get reused for each query. A typical pool holds 10-50 connections. When all connections are busy, new queries wait in the pool's internal queue.
Pool saturation happens when queries take longer than usual (slow query, lock contention, I/O wait on the DB) or when request volume increases without scaling the pool. The symptom is API endpoints timing out even though the database server shows low CPU usage.
Check pool stats in your application logs or metrics. Look for:
- Active connections (how many are in use right now)
- Pool size (maximum connections allowed)
- Queue depth (queries waiting for a connection)
- Wait time (how long queries wait to acquire a connection)
When active connections equal pool size, you're at capacity. If queue depth is above zero for more than a few seconds, queries are blocked waiting for a connection to free up.
A common mistake is setting the pool size too high. Each connection consumes memory on the database server. If 50 app servers each hold 50 connections, that's 2,500 simultaneous connections to your database. Most RDBMSs don't handle that well.
The fix depends on the bottleneck:
- If queries are slow, optimize them or add indexes
- If the database is CPU-bound, scale vertically or horizontally
- If the pool is genuinely undersized, grow it—but check database max connections first
Alert when pool utilization exceeds 80% (active / max) for two minutes. Pair it with query latency; if both are climbing, the database is the bottleneck.
What to instrument first
If you're starting from scratch, prioritize in this order:
- API error rates and latency — catches application-level failures immediately
- Memory pressure (PSI or MemAvailable) — gives you warning before the OOM killer strikes
- Disk I/O wait — prevents the "why is everything slow?" mystery
- Database connection pool saturation — stops the most common app failure mode
- CPU steal time — tells you if your cloud provider is the problem
- Network retransmits — catches network degradation early
- DNS resolution time — prevents invisible latency
- Load balancer queue depth — guards the front door
You don't need expensive tooling. Start with Prometheus and node_exporter for host metrics, plus custom instrumentation in your app to expose pool stats and error counts. Write a simple script to check DNS resolution time every minute. Export everything to a time-series database and build dashboards.
The goal isn't to collect more data. It's to watch the right eight signals so you see problems forming instead of reacting to the aftermath.
Frequently asked questions
How often should I check these metrics?
Sample host-level metrics (CPU, memory, disk, network) every 10-30 seconds. Application metrics (error rates, pool saturation) every 5-10 seconds. DNS checks can run every 60 seconds since resolution time doesn't change that fast.
What if I'm on shared hosting and can't see steal time?
You probably can't. Shared hosting providers don't expose hypervisor stats. If your site is consistently slow despite low resource usage, the problem might be noisy neighbors. The only fix is moving to a VPS or dedicated instance where you control the environment.
Should I alert on every metric or just the critical ones?
Alert on critical thresholds only—memory below 10%, iowait above 25%, error rate above 0.5%. Use dashboards to watch trends on the rest. Too many alerts train you to ignore them.
Can I monitor all of this with cPanel's built-in tools?
cPanel shows basic resource usage but doesn't expose steal time, PSI, retransmits, or application-level metrics like connection pool saturation. You'll need to install additional monitoring (Prometheus, Netdata, or a commercial agent) to see the full picture.
Watch the pressure build, not the explosion
Outages don't appear out of nowhere. A database doesn't go from healthy to dead in one second. The connection pool fills up over five minutes. I/O wait climbs for twenty minutes before the disk fully saturates. Memory pressure builds for an hour before the OOM killer strikes.
The difference between a team that firefights constantly and one that prevents incidents is watching these eight signals and acting when they cross the early thresholds. Check your monitoring setup today. If you're not tracking CPU steal, memory pressure, and connection pool saturation, you're flying blind through the most common failure modes. Fix that first.
