CloudWatch Logs Anomaly Detection: Ignore Deploy Noise, Catch Novel Errors

CloudWatch Logs Anomaly Detection: Ignore Deploy Noise, Catch Novel Errors
9 views
CloudWatch Logs anomaly detection is noisy the week you ship structured logging. The unfair advantage is teaching detectors what “normal deploy churn” looks like—suppression windows, baseline freezes, and focused metric filters—so novel ECONNRESET shapes still page while expected field additions do not.
⚡ TL;DR: Baseline on steady traffic; suppress or retrain across known deploys; alert on anomaly + error-rate composite; keep a Logs Insights saved query for novel message clusters. Pair with CI Failure Triage Bots and Lambda Log Buffering.

CloudWatch Logs Anomaly Detection: production guidance

text
Deploy → new fields / renamed codes → anomaly spike (benign)
Regression → new exception class / surge of rare code → anomaly + SLO burn (page)
Technique Effect
Suppression window around CodeDeploy/ECS events Ignore expected shape change
Metric filter on level=error rate Cheap primary signal
Anomaly on rare error codes only High precision
Embed deploy marker in logs Correlates false positives
python
# ✅ Emit explicit deploy marker once per task start
import logging, os
logging.getLogger("boot").info(
 "deploy_marker",
 extra={"git_sha": os.environ["GIT_SHA"], "task_def": os.environ["TASK_DEFINITION"]},
)

Composite alarms beat raw anomaly

bash
# ✅ Alarm when: anomaly detector state ALARM
# AND error_rate > 1% for 5m
# AND NOT within 15m of a successful ECS deployment event
sql
-- ✅ Logs Insights: novel messages after deploy (sample)
fields @timestamp, msg, error_code
| filter level = "error"
| stats count() as c by error_code, msg
| sort c desc
| limit 50
❌ Paging on every anomaly without a human-tuned denylist — on-call will silence the detector permanently.

Retrain discipline

After intentional log schema changes, retrain/baseline for 24–48h of normal traffic. Document the change in the same PR as the schema bump. Keep canaries (Continuous Path Verification) as the source of truth for business path health.

Closing checklist

✅ Dos – ✅ Use composite alarms (anomaly ∩ error-rate ∩ not-deploying) – ✅ Log deploy markers with git SHA – ✅ Maintain denylist for known noisy messages – ✅ Retrain after structured-log migrations – ✅ Review anomaly FP/FN weekly for two sprints after enablement ❌ Don’ts – ❌ Don’t alert solely on anomaly score – ❌ Don’t change log schemas without notifying detectors – ❌ Don’t sample away all errors before detection – ❌ Don’t let silenced detectors stay silenced

Related reading

Last updated on September 11, 2026 Related: AWS CloudWatch Insights Queries That Actually Find Production Bugs; Python typing Module: Generics and Protocols That Catch Real Bugs at Compile Time; AI-Powered Code Review: Catch Security Issues and Architecture Violations Automatically.

Watch: 100 Days of AI on YouTube

Short videos from CheatCoders, one AI engineering topic per day.

Open the playlist on YouTube · CheatCoders on YouTube

Deep-dive PDF

Get the expanded guide for this post — extra diagrams-style checklists, failure modes, and a production walkthrough. Free when you subscribe to CheatCoders.

Already subscribed? or open the subscribe page.


Discover more from CheatCoders

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

Leave a comment

No account needed. Name and email are optional.