{
    "url": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation",
    "locale": "en",
    "title": "AWS CloudWatch Investigation Skill | DeLaParra Services",
    "description": ">",
    "alternates": {
        "en": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation",
        "nl": "https://delaparra-services.nl/nl/skills/aws-cloudwatch-investigation"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.csv",
        "md": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.md",
        "json": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.json",
        "zip": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.zip",
        "pdf": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.csv",
            "encodingFormat": "text/csv",
            "name": "aws-cloudwatch-investigation.csv"
        },
        {
            "url": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.json",
            "encodingFormat": "application/json",
            "name": "aws-cloudwatch-investigation.json"
        },
        {
            "url": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.md",
            "encodingFormat": "text/markdown",
            "name": "aws-cloudwatch-investigation.md"
        },
        {
            "url": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.pdf",
            "encodingFormat": "application/pdf",
            "name": "aws-cloudwatch-investigation.pdf"
        },
        {
            "url": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.zip",
            "encodingFormat": "application/zip",
            "name": "aws-cloudwatch-investigation.zip"
        },
        {
            "url": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation/download",
            "encodingFormat": "application/zip",
            "name": "aws-cloudwatch-investigation-files.zip"
        }
    ],
    "markdown": "# AWS CloudWatch Investigation Skill\n\n \n\n\\>\n\n \n\n**Licence** MIT\n\n \n\n**Source** github/awesome-copilot\n\n [Download zip](<https://delaparra-services.nl/skills/aws-cloudwatch-investigation/download>)   \n\n# AWS CloudWatch Investigation Skill\n\n \n\nReusable patterns for investigating production incidents using CloudWatch Logs, Metrics, and Alarms. These patterns are designed to be composed together during incident triage.\n\n  \n\n## Pattern 1: Logs Insights Query Templates\n\n \n\n### Error Spike Detection\n\n \n\nFind the top errors in a time window, grouped by error type:\n\n \n\n```\nfields @timestamp, @message, @logStream\n| filter @message like /(?i)(error|exception|fatal|critical)/\n| stats count(*) as errorCount by bin(5m), @logStream\n| sort errorCount desc\n| limit 20\n```\n\n \n\n### P99 Latency Breakdown by Operation\n\n \n\nIdentify which operations are driving latency spikes:\n\n \n\n```\nfields @timestamp, @duration, operation\n| filter ispresent(@duration)\n| stats avg(@duration) as avgMs,\n        pct(@duration, 50) as p50Ms,\n        pct(@duration, 95) as p95Ms,\n        pct(@duration, 99) as p99Ms,\n        count(*) as invocations\n  by operation\n| sort p99Ms desc\n| limit 15\n```\n\n \n\n### Lambda Cold Start Detection\n\n \n\nQuantify cold start impact during an incident:\n\n \n\n```\nfields @timestamp, @duration, @initDuration, @memorySize, @maxMemoryUsed\n| filter ispresent(@initDuration)\n| stats count(*) as coldStarts,\n        avg(@initDuration) as avgInitMs,\n        max(@initDuration) as maxInitMs,\n        avg(@duration) as avgDurationMs\n  by bin(5m)\n| sort @timestamp desc\n```\n\n \n\n### Out-of-Memory (OOM) Detection\n\n \n\nFind Lambda functions or containers killed by memory pressure:\n\n \n\n```\nfields @timestamp, @message, @logStream, @memorySize, @maxMemoryUsed\n| filter @message like /Runtime exited|out of memory|OOMKilled|Cannot allocate memory|MemoryError/\n| stats count(*) as oomEvents by @logStream, bin(10m)\n| sort oomEvents desc\n| limit 10\n```\n\n \n\nFor memory utilization trending before OOM:\n\n \n\n```\nfields @timestamp, @maxMemoryUsed, @memorySize\n| filter ispresent(@maxMemoryUsed)\n| stats max(@maxMemoryUsed / @memorySize * 100) as peakMemPct,\n        avg(@maxMemoryUsed / @memorySize * 100) as avgMemPct\n  by bin(5m)\n| sort @timestamp desc\n```\n\n \n\n### Timeout Detection\n\n \n\nFind invocations that hit the configured timeout:\n\n \n\n```\nfields @timestamp, @duration, @logStream, @requestId\n| filter @message like /Task timed out/ or @duration > 28000\n| stats count(*) as timeouts by @logStream, bin(5m)\n| sort timeouts desc\n```\n\n  \n\n## Pattern 2: Alarm History to Deploy-Event Correlation\n\n \n\n### Process\n\n \n\n1. **Get alarm transition time** — note the exact timestamp when the alarm entered ALARM state. \n1. **Query CloudTrail** for deployment-related events in a window of \\[alarm\\_time - 30min, alarm\\_time\\]:\n\n \n\n```\n# CloudTrail Lake query for deployment events\nSELECT eventTime, eventName, userIdentity.arn, requestParameters\nFROM <event-data-store-id>\nWHERE eventTime > '<alarm_time_minus_30m>'\n  AND eventTime < '<alarm_time>'\n  AND eventName IN (\n    'UpdateFunctionCode', 'UpdateFunctionConfiguration',\n    'UpdateService', 'CreateDeployment', 'RegisterTaskDefinition',\n    'CreateChangeSet', 'ExecuteChangeSet',\n    'StartPipelineExecution', 'PutImage'\n  )\nORDER BY eventTime DESC\n```\n\n \n\n1. **Correlation criteria** — a deploy is \"correlated\" if:\n\n \n\n- It targets the same service/resource as the alarm \n- It completed within 15 minutes before the alarm transition \n- The deployer identity matches a CI/CD role (not a human applying a hotfix) \n1. **Strengthening the correlation:**\n\n \n\n- Check if the same alarm was healthy in the previous deployment cycle \n- Verify no other environmental changes (scaling events, config changes) in the same window \n- Look for canary/synthetic monitor failures that started at the same time\n\n \n\n### Output Format\n\n \n\n```\nDeploy Correlation:\n  Event: UpdateFunctionCode\n  Time: 2024-03-15T14:23:07Z (12 min before alarm)\n  Actor: arn:aws:sts::123456789012:assumed-role/github-actions-deploy/session\n  Resource: arn:aws:lambda:us-east-1:123456789012:function:payment-processor\n  Correlation: STRONG — same resource, CI/CD actor, alarm was OK prior cycle\n```\n\n  \n\n## Pattern 3: Narrow the Blast Radius Decision Tree\n\n \n\nUse this tree to systematically scope an incident from broadest to most specific:\n\n \n\n```\nSTART\n  |\n  v\n[1] ACCOUNT — Which account(s) show the alarm?\n  |  - Check: Are alarms firing in multiple accounts?\n  |  - If yes → suspect shared service (SSO, networking, shared deployment pipeline)\n  |  - If no → proceed to Region\n  v\n[2] REGION — Which region(s) are affected?\n  |  - Check: Same alarm in other regions?\n  |  - If multi-region → suspect global service (IAM, Route53, S3 global)\n  |  - If single-region → proceed to Service\n  v\n[3] SERVICE — Which service namespace shows degradation?\n  |  - Check CloudWatch namespace: AWS/Lambda, AWS/ECS, AWS/ApiGateway, etc.\n  |  - If multiple services → suspect shared dependency (VPC, NAT, DNS, IAM)\n  |  - If single service → proceed to Operation\n  v\n[4] OPERATION — Which API action or function is failing?\n  |  - For Lambda: which function name?\n  |  - For ECS: which service/task definition?\n  |  - For API GW: which stage/resource/method?\n  |  - If all operations → suspect service-level issue (throttling, quota)\n  |  - If specific operation → proceed to Resource\n  v\n[5] RESOURCE — Which specific resource instance?\n     - Function ARN, Task ID, DB instance identifier\n     - This is your investigation target\n     - Proceed to log and trace analysis scoped to this resource\n```\n\n \n\n### Shared Dependency Investigation\n\n \n\nWhen blast radius spans multiple services, investigate in this order:\n\n \n\n1. **VPC/Networking** — NAT Gateway ErrorPortAllocation, packet drops, DNS resolution failures \n1. **IAM/STS** — ThrottlingException on AssumeRole, token vending latency \n1. **Downstream dependency** — shared database, cache, or external API \n1. **Deployment pipeline** — simultaneous deploys across services from same pipeline run \n1. **AWS service event** — check AWS Health Dashboard and Service Health for the region\n\n  \n\n## Pattern 4: PromQL-Style Metric Query Patterns\n\n \n\nThese patterns use CloudWatch metric math and GetMetricData to build composite signals. Express them as metric queries for dashboards or programmatic retrieval.\n\n \n\n### Error Rate as Percentage\n\n \n\n```\nMetricDataQueries:\n  - Id: errors\n    MetricStat:\n      Metric:\n        Namespace: AWS/Lambda\n        MetricName: Errors\n        Dimensions: [{Name: FunctionName, Value: TARGET}]\n      Period: 60\n      Stat: Sum\n  - Id: invocations\n    MetricStat:\n      Metric:\n        Namespace: AWS/Lambda\n        MetricName: Invocations\n        Dimensions: [{Name: FunctionName, Value: TARGET}]\n      Period: 60\n      Stat: Sum\n  - Id: error_rate\n    Expression: \"errors / invocations * 100\"\n    Label: \"Error Rate %\"\n```\n\n \n\n### Latency Anomaly Detection (Compare to Baseline)\n\n \n\n```\nMetricDataQueries:\n  - Id: current_p99\n    MetricStat:\n      Metric:\n        Namespace: AWS/Lambda\n        MetricName: Duration\n        Dimensions: [{Name: FunctionName, Value: TARGET}]\n      Period: 300\n      Stat: p99\n  - Id: baseline_p99\n    MetricStat:\n      Metric:\n        Namespace: AWS/Lambda\n        MetricName: Duration\n        Dimensions: [{Name: FunctionName, Value: TARGET}]\n      Period: 300\n      Stat: p99\n    # Use StartTime/EndTime set to same window last week\n  - Id: anomaly_ratio\n    Expression: \"current_p99 / baseline_p99\"\n    Label: \"Latency vs Baseline (ratio > 2 = anomaly)\"\n```\n\n \n\n### Throttling Pressure Score\n\n \n\nCombine multiple throttling signals into a single pressure metric:\n\n \n\n```\nMetricDataQueries:\n  - Id: lambda_throttles\n    MetricStat:\n      Metric: {Namespace: AWS/Lambda, MetricName: Throttles}\n      Period: 60\n      Stat: Sum\n  - Id: api_gw_429s\n    MetricStat:\n      Metric: {Namespace: AWS/ApiGateway, MetricName: 4XXError, Dimensions: [{Name: ApiName, Value: TARGET}]}\n      Period: 60\n      Stat: Sum\n  - Id: dynamo_throttles\n    MetricStat:\n      Metric: {Namespace: AWS/DynamoDB, MetricName: ThrottledRequests, Dimensions: [{Name: TableName, Value: TARGET}]}\n      Period: 60\n      Stat: Sum\n  - Id: throttle_pressure\n    Expression: \"lambda_throttles + api_gw_429s + dynamo_throttles\"\n    Label: \"Combined Throttle Pressure\"\n```\n\n \n\n### Concurrent Execution Headroom\n\n \n\n```\nMetricDataQueries:\n  - Id: concurrent\n    MetricStat:\n      Metric: {Namespace: AWS/Lambda, MetricName: ConcurrentExecutions}\n      Period: 60\n      Stat: Maximum\n  - Id: headroom\n    Expression: \"1000 - concurrent\"\n    Label: \"Remaining Concurrency (account limit 1000)\"\n```\n\n  \n\n## Pattern 5: Incident Timeline Reconstruction\n\n \n\n### Process\n\n \n\nReconstruct a precise timeline by merging data from multiple sources:\n\n \n\n1. **Collect timestamps:**\n\n    Source Query Yields     CloudWatch Alarms Alarm history API State transition times   CloudWatch Metrics GetMetricData with 1-min period First anomaly point   CloudWatch Logs Logs Insights with ` earliest(@timestamp) ` First error occurrence   CloudTrail LookupEvents filtered by time Deployment/change events   AWS Health DescribeEvents AWS-side incidents    \n\n1. **Build the timeline:**\n\n \n\n```\nfields @timestamp, @message\n| filter @message like /ERROR|WARN|timeout|refused|denied/\n| stats earliest(@timestamp) as firstSeen, latest(@timestamp) as lastSeen, count(*) as occurrences\n  by @message\n| sort firstSeen asc\n| limit 20\n```\n\n \n\n1. **Identify the sequence:**\n\n \n\n```\nTimeline:\n  T-15m: CloudTrail — UpdateFunctionCode by CI/CD role\n  T-12m: Logs — first error \"Connection refused to payments-api.internal\"\n  T-10m: Metrics — Error count crosses 5/min threshold\n  T-8m:  Alarm — PaymentProcessorErrors enters ALARM\n  T-5m:  Metrics — p99 latency spikes to 28s (timeout)\n  T-0:   Current — error rate at 45%, alarm still firing\n```\n\n \n\n1. **Determine root event** — the earliest change that preceded all symptoms. Walk backward from the first symptom to the most recent mutation (deploy, config change, scaling event, or external dependency shift).\n\n \n\n### Gotchas\n\n \n\n- CloudWatch metric timestamps are end-of-period. A 1-minute datapoint at 14:05 covers 14:04-14:05. \n- CloudTrail events can have up to 15-minute delivery delay. Use ` eventTime `, not ingestion time. \n- Log group timestamps depend on the agent/SDK flush interval. Allow for 30-60s of clock skew. \n- Alarm state changes have a built-in evaluation delay (periods x evaluation periods). The actual anomaly started earlier.\n\n \n\n## Files\n\n \n\n- ` LICENSE ` \n- ` SKILL.md ` \n- ` SOURCE.md `\n\n \n\n## Related terms\n\n \n\n- [log](<https://delaparra-services.nl/knowledge-hub/log>) \n- [Monitoring & Observability](<https://delaparra-services.nl/knowledge-hub/monitoring-observability>) \n- [structured logging](<https://delaparra-services.nl/knowledge-hub/structured-logging>)\n\n \n\n[Installing an agent skill in Claude Code, Codex, Cursor and Copilot](<https://delaparra-services.nl/manuals/een-skill-installeren-in-je-ai-assistent>)\n\n[HTML version](https://delaparra-services.nl/skills/aws-cloudwatch-investigation)\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "Organization",
                "@id": "https://delaparra-services.nl/#practice",
                "logo": "https://delaparra-services.nl/logo.png",
                "name": "DeLaParra Services",
                "legalName": "DeLaParra Services",
                "url": "https://delaparra-services.nl/",
                "description": "Bespoke software, web applications and mobile apps, developed in Laravel by a single developer in Groningen. Fixed price agreed in advance, full source code provided upon delivery.",
                "email": "info@delaparra-services.nl",
                "address": {
                    "@type": "PostalAddress",
                    "addressLocality": "Groningen",
                    "addressRegion": "Groningen",
                    "addressCountry": "NL"
                },
                "areaServed": "Groningen, the Netherlands",
                "knowsLanguage": [
                    "en",
                    "nl"
                ],
                "knowsAbout": [
                    "Web design and development",
                    "App development",
                    "Custom software and web applications",
                    "OpenSpec",
                    "AI code review",
                    "Your own coding agent"
                ],
                "founder": {
                    "@id": "https://delaparra-services.nl/#person"
                }
            },
            {
                "@type": "WebPage",
                "@id": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation#webpage",
                "url": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation",
                "name": "AWS CloudWatch Investigation Skill | DeLaParra Services",
                "description": ">",
                "isPartOf": {
                    "@id": "https://delaparra-services.nl/#website"
                },
                "about": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "inLanguage": "en",
                "breadcrumb": {
                    "@id": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation#breadcrumb"
                }
            },
            {
                "@type": "BreadcrumbList",
                "@id": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation#breadcrumb",
                "itemListElement": [
                    {
                        "@type": "ListItem",
                        "position": 1,
                        "name": "Home",
                        "item": "https://delaparra-services.nl/"
                    },
                    {
                        "@type": "ListItem",
                        "position": 2,
                        "name": "AWS CloudWatch Investigation Skill"
                    }
                ]
            },
            {
                "@type": "Person",
                "@id": "https://delaparra-services.nl/#person",
                "name": "Reinier de la Parra",
                "url": "https://delaparra-services.nl/about"
            },
            {
                "@type": "SoftwareSourceCode",
                "@id": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation#skill",
                "url": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation",
                "name": "AWS CloudWatch Investigation Skill",
                "description": ">",
                "inLanguage": "en",
                "license": "https://spdx.org/licenses/MIT.html",
                "subjectOf": {
                    "@id": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation#dataset"
                }
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation#dataset",
                "name": "AWS CloudWatch Investigation Skill",
                "description": "> The files of this skill can be downloaded as a ZIP, licence included.",
                "url": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation",
                "identifier": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation#skill"
                },
                "creditText": "github/awesome-copilot",
                "publisher": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "license": "https://spdx.org/licenses/MIT.html",
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "dateModified": "2026-11-28T14:00:10+00:00",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/knowledge-hub#skills",
                    "name": "Skills for AI coding assistants",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "includedInDataCatalog": {
                    "@type": "DataCatalog",
                    "@id": "https://delaparra-services.nl/knowledge-hub#catalog",
                    "name": "Knowledge hub data catalog",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "distribution": [
                    {
                        "@type": "DataDownload",
                        "name": "aws-cloudwatch-investigation.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.csv",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:10+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "aws-cloudwatch-investigation.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.json",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:10+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "aws-cloudwatch-investigation.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.md",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:10+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "aws-cloudwatch-investigation.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.pdf",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:10+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "aws-cloudwatch-investigation.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:10+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "aws-cloudwatch-investigation-files.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/skills/aws-cloudwatch-investigation/download",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:10+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    }
                ]
            }
        ]
    }
}