cloudwatch
Skill1.2k starsChanged 3 months agoMITView on GitHub
AWS CloudWatch monitoring for logs, metrics, alarms, and dashboards. Use when setting up monitoring, creating alarms, querying logs with Insights, configuring metric filters, building dashboards, or troubleshooting application issues.
1 other project uses a version of this.
Trending
More talk lately.thin dataabout the whole repository
Most recently taken up by
- torrresagus/cloudwatch-debugger-skilltheir own version, first seen Mar 14, 2026
Who's talking about itsmostafa/aws-agent-skills
- @tom-doerr.bsky.social“https://github.com/itsmostafa/aws-agent-skills”Bluesky · Mar 19, 2026 · 1 likes
- ProSkillsMD/proskills“[Candidate] itsmostafa/aws-agent-skills/skills/api-gateway - api-gateway”GitHub · Oct 4, 2026
- sudosubin/agents.nix“claude-code-plugins.github.itsmostafa.aws-agent-skills: init at 0-unstable-2026-09-15”GitHub · Oct 4, 2026
- sudosubin/agents.nix“claude-code-marketplaces.github.itsmostafa.aws-agent-skills: init at 0-unstable-2026-09-15”GitHub · Oct 4, 2026
- sudosubin/agents.nix“agent-skills.github.itsmostafa.aws-agent-skills: init at 0-unstable-2026-09-15”GitHub · Sep 28, 2026
The biggest 5 of 6 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 6
Talked about on GitHub and Bluesky (6 times).
On GitHub · 5
- Oct 4, 2026[Candidate] itsmostafa/aws-agent-skills/skills/api-gateway - api-gateway — ProSkillsMD/proskills0 reactions · 1 comment
- Oct 4, 2026claude-code-plugins.github.itsmostafa.aws-agent-skills: init at 0-unstable-2026-09-15 — sudosubin/agents.nix0 reactions
- Oct 4, 2026claude-code-marketplaces.github.itsmostafa.aws-agent-skills: init at 0-unstable-2026-09-15 — sudosubin/agents.nix0 reactions
- Sep 28, 2026agent-skills.github.itsmostafa.aws-agent-skills: init at 0-unstable-2026-09-15 — sudosubin/agents.nix0 reactions
- Apr 25, 2026Audit candidate: itsmostafa/aws-agent-skills — xiaolai/nlpm0 reactions · 102 comments
On Bluesky · 1
- Mar 19, 2026https://github.com/itsmostafa/aws-agent-skills — @tom-doerr.bsky.social1 likes and repost
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- torrresagus/cloudwatch-debugger-skill★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository17 other files it gives its agents.
- api-gatewaySkill
- bedrockSkill
- cloudformationSkill
- cognitoSkill
- dynamodbSkill
- ec2Skill
- ecsSkill
- eksSkill
- eventbridgeSkill
- iamSkill
- lambdaSkill
- rdsSkill
- s3Skill
- secrets-managerSkill
- snsSkill
- sqsSkill
- step-functionsSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 344
Use log alarms: instead of metric filter + metric alarm for query-based conditions.
- Distinctive: line 362
Use log subscription filters: instead of polling
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AWS CloudWatch
Amazon CloudWatch provides monitoring and observability for AWS resources and applications. It collects metrics, logs, and events, enabling you to monitor, troubleshoot, and optimize your AWS environment.
Table of Contents
- Core Concepts
- Common Patterns
- CLI Reference
- Best Practices
- Troubleshooting
- References
Core Concepts
Metrics
Time-ordered data points published to CloudWatch. Key components:
- Namespace: Container for metrics (e.g.,
AWS/Lambda) - Metric name: Name of the measurement (e.g.,
Invocations) - Dimensions: Name-value pairs for filtering (e.g.,
FunctionName=MyFunc) - Statistics: Aggregations (Sum, Average, Min, Max, SampleCount, pN)
Logs
Log data from AWS services and applications:
- Log groups: Collections of log streams
- Log streams: Sequences of log events from same source
- Log events: Individual log entries with timestamp and message
Alarms
Automated actions based on metric thresholds:
- States: OK, ALARM, INSUFFICIENT_DATA
- Actions: SNS notifications, Lambda functions, Auto Scaling, EC2 actions, Systems Manager OpsItems
- Types: metric (incl. metric math, anomaly detection, Metrics Insights), composite, log (scheduled Logs Insights query evaluated M-out-of-N on query results)
- Mute rules: scheduled windows that mute actions while alarms keep evaluating
Common Patterns
Create a Metric Alarm
AWS CLI:
# CPU utilization alarm for EC2
aws cloudwatch put-metric-alarm \
--alarm-name "HighCPU-i-1234567890abcdef0" \
--metric-name CPUUtilization \
--namespace AWS/EC2 \
--statistic Average \
--period 300 \
--threshold 80 \
--comparison-operator GreaterThanThreshold \
--evaluation-periods 2 \
--dimensions Name=InstanceId,Value=i-1234567890abcdef0 \
--alarm-actions arn:aws:sns:us-east-1:123456789012:alerts \
--ok-actions arn:aws:sns:us-east-1:123456789012:alertsboto3:
import boto3
cloudwatch = boto3.client('cloudwatch')
cloudwatch.put_metric_alarm(
AlarmName='HighCPU-i-1234567890abcdef0',
MetricName='CPUUtilization',
Namespace='AWS/EC2',
Statistic='Average',
Period=300,
Threshold=80.0,
ComparisonOperator='GreaterThanThreshold',
EvaluationPeriods=2,
Dimensions=[
{'Name': 'InstanceId', 'Value': 'i-1234567890abcdef0'}
],
AlarmActions=['arn:aws:sns:us-east-1:123456789012:alerts'],
OKActions=['arn:aws:sns:us-east-1:123456789012:alerts']
)Lambda Error Rate Alarm
aws cloudwatch put-metric-alarm \
--alarm-name "LambdaErrorRate-MyFunction" \
--metrics '[
{
"Id": "errors",
"MetricStat": {
"Metric": {
"Namespace": "AWS/Lambda",
"MetricName": "Errors",
"Dimensions": [{"Name": "FunctionName", "Value": "MyFunction"}]
},
"Period": 60,
"Stat": "Sum"
},
"ReturnData": false
},
{
"Id": "invocations",
"MetricStat": {
"Metric": {
"Namespace": "AWS/Lambda",
"MetricName": "Invocations",
"Dimensions": [{"Name": "FunctionName", "Value": "MyFunction"}]
},
"Period": 60,
"Stat": "Sum"
},
"ReturnData": false
},
{
"Id": "errorRate",
"Expression": "errors/invocations*100",
"Label": "Error Rate",
"ReturnData": true
}
]' \
--threshold 5 \
--comparison-operator GreaterThanThreshold \
--evaluation-periods 3 \
--alarm-actions arn:aws:sns:us-east-1:123456789012:alertsQuery Logs with Insights
# Find errors in Lambda logs
aws logs start-query \
--log-group-name /aws/lambda/MyFunction \
--start-time $(date -d '1 hour ago' +%s) \
--end-time $(date +%s) \
--query-string '
fields @timestamp, @message
| filter @message like /ERROR/
| sort @timestamp desc
| limit 50
'
# Get query results
aws logs get-query-results --query-id <query-id>boto3:
import boto3
import time
logs = boto3.client('logs')
# Start query
response = logs.start_query(
logGroupName='/aws/lambda/MyFunction',
startTime=int(time.time()) - 3600,
endTime=int(time.time()),
queryString='''
fields @timestamp, @message
| filter @message like /ERROR/
| sort @timestamp desc
| limit 50
'''
)
query_id = response['queryId']
# Wait for results
while True:
result = logs.get_query_results(queryId=query_id)
if result['status'] == 'Complete':
break
time.sleep(1)
for row in result['results']:
print(row)Create Metric Filter
Extract metrics from log patterns:
# Create metric filter for error count
aws logs put-metric-filter \
--log-group-name /aws/lambda/MyFunction \
--filter-name ErrorCount \
--filter-pattern "ERROR" \
--metric-transformations \
metricName=ErrorCount,metricNamespace=MyApp,metricValue=1,defaultValue=0Create a Log Alarm
Alarm directly on a Logs Insights query (no metric filter needed). CloudWatch creates and manages the underlying scheduled query. The ScheduledQueryRoleARN role must trust logs.amazonaws.com and allow logs:StartQuery and logs:GetQueryResults on the log group ARNs, plus logs:StopQuery and logs:DescribeLogGroups on "Resource": "*" (these two support no resource-level permissions, so a log-group-scoped statement never matches them).
# ALARM when >100 errors in 3 of the last 5 query runs
aws cloudwatch put-log-alarm \
--alarm-name "HighErrorCount" \
--comparison-operator GreaterThanThreshold \
--threshold 100 \
--query-results-to-evaluate 5 \
--query-results-to-alarm 3 \
--treat-missing-data notBreaching \
--alarm-actions arn:aws:sns:us-east-1:123456789012:alerts \
--scheduled-query-configuration '{
"QueryString": "fields @timestamp, @message | filter @message like /ERROR/",
"LogGroupIdentifiers": ["/aws/lambda/MyFunction"],
"ScheduledQueryRoleARN": "arn:aws:iam::123456789012:role/ScheduledQueryRole",
"AggregationExpression": "count(*)",
"ScheduleConfiguration": {
"ScheduleExpression": "rate(10 minutes)",
"StartTimeOffset": 600
}
}'
# Log alarms are omitted from describe-alarms unless requested
aws cloudwatch describe-alarms --alarm-types LogAlarmPublish Custom Metrics
import boto3
cloudwatch = boto3.client('cloudwatch')
cloudwatch.put_metric_data(
Namespace='MyApp',
MetricData=[
{
'MetricName': 'OrdersProcessed',
'Value': 1,
'Unit': 'Count',
'Dimensions': [
{'Name': 'Environment', 'Value': 'Production'},
{'Name': 'OrderType', 'Value': 'Standard'}
]
}
]
)Create Dashboard
cat > dashboard.json << 'EOF'
{
"widgets": [
{
"type": "metric",
"x": 0, "y": 0, "width": 12, "height": 6,
"properties": {
"title": "Lambda Invocations",
"metrics": [
["AWS/Lambda", "Invocations", "FunctionName", "MyFunction"]
],
"period": 60,
"stat": "Sum",
"region": "us-east-1"
}
},
{
"type": "log",
"x": 12, "y": 0, "width": 12, "height": 6,
"properties": {
"title": "Recent Errors",
"query": "SOURCE '/aws/lambda/MyFunction' | filter @message like /ERROR/ | limit 20",
"region": "us-east-1"
}
}
]
}
EOF
aws cloudwatch put-dashboard \
--dashboard-name MyAppDashboard \
--dashboard-body file://dashboard.jsonCLI Reference
Metrics Commands
| Command | Description |
aws cloudwatch put-metric-data | Publish custom metrics |
aws cloudwatch get-metric-data | Retrieve metric values |
aws cloudwatch get-metric-statistics | Get aggregated statistics |
aws cloudwatch list-metrics | List available metrics |
Alarms Commands
| Command | Description |
aws cloudwatch put-metric-alarm | Create or update alarm |
aws cloudwatch put-log-alarm | Create or update log query alarm |
aws cloudwatch describe-alarms | List alarms (--alarm-types LogAlarm for log alarms) |
aws cloudwatch describe-alarm-contributors | Show breaching contributors of a multi-contributor alarm |
aws cloudwatch put-alarm-mute-rule | Create or update scheduled mute window |
aws cloudwatch list-alarm-mute-rules | List mute rules (--statuses SCHEDULED ACTIVE EXPIRED) |
aws cloudwatch delete-alarm-mute-rule | Delete mute rule (unmutes immediately) |
aws cloudwatch set-alarm-state | Manually set alarm state |
aws cloudwatch delete-alarms | Delete alarms |
Logs Commands
| Command | Description |
aws logs create-log-group | Create log group |
aws logs put-log-events | Write log events |
aws logs filter-log-events | Search log events |
aws logs start-query | Start Insights query |
aws logs put-metric-filter | Create metric filter |
aws logs put-retention-policy | Set log retention |
Best Practices
Metrics
- Use dimensions wisely — too many creates metric explosion
- Aggregate before publishing — batch custom metrics
- Use high-resolution metrics (1-second) only when needed
- Set meaningful units for custom metrics
Alarms
- Use composite alarms for complex conditions
- Set appropriate evaluation periods to avoid flapping
- Include OK actions to track recovery
- Use anomaly detection for dynamic thresholds
- Use log alarms instead of metric filter + metric alarm for query-based conditions; set
--treat-missing-data notBreachingfor sparse errors,breachingto detect logs that stop arriving - Stagger log alarm schedules — concurrent scheduled query executions per account are capped at 100
- Set
--warm-up-configurationon alarms created alongside new resources (1-2880 min) to avoid noise before metrics publish - Use
--evaluation-window WallClockWindow={Timezone=...}for daily/weekly batch or backup alarms; keep the default sliding window for Auto Scaling - Use mute rules for maintenance, not
disable-alarm-actions;enable-alarm-actionsdoes not unmute an active mute rule
Logs
- Set retention policies — don't keep logs forever
- Use structured logging (JSON) for better querying
- Create metric filters for key events
- Use Contributor Insights for top-N analysis
Cost Optimization
- Delete unused dashboards
- Reduce log retention for non-critical logs
- Avoid high-resolution metrics unless necessary
- Use log subscription filters instead of polling
Troubleshooting
Missing Metrics
Causes:
- Service not publishing yet (wait 1-5 minutes)
- Wrong namespace/dimensions
- Detailed monitoring not enabled (EC2)
Debug:
# List metrics for a namespace
aws cloudwatch list-metrics \
--namespace AWS/Lambda \
--dimensions Name=FunctionName,Value=MyFunctionAlarm Stuck in INSUFFICIENT_DATA
Causes:
- Metric not being published
- Dimensions mismatch
- Evaluation period too short
- Warm-up period still active (ends early once data fills the window unless
OnlyStartEvaluatingAfterWarmUpPeriodEnds=true) - Log alarm: just created/updated (query, schedule, or log group changes reset state), scheduled query role lacks permissions (
EvaluationState=EVALUATION_ERROR, seeStateReason), or ingestion lag (shift window back withEndTimeOffset)
Debug:
# Check if metric has data
aws cloudwatch get-metric-statistics \
--namespace AWS/Lambda \
--metric-name Invocations \
--dimensions Name=FunctionName,Value=MyFunction \
--start-time $(date -d '1 hour ago' -u +%Y-%m-%dT%H:%M:%SZ) \
--end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) \
--period 60 \
--statistics Sum
# Log alarm: check evaluation state and reason
aws cloudwatch describe-alarms --alarm-types LogAlarm --alarm-names HighErrorCount \
--query 'LogAlarms[].[StateValue,EvaluationState,StateReason]'Log Events Not Appearing
Causes:
- IAM permissions missing
- CloudWatch Logs agent not running
- Log group doesn't exist
Debug:
# Check log streams
aws logs describe-log-streams \
--log-group-name /aws/lambda/MyFunction \
--order-by LastEventTime \
--descending \
--limit 5High CloudWatch Costs
Check usage:
# Get PutLogEvents usage
aws cloudwatch get-metric-statistics \
--namespace AWS/Logs \
--metric-name IncomingBytes \
--dimensions Name=LogGroupName,Value=/aws/lambda/MyFunction \
--start-time $(date -d '7 days ago' -u +%Y-%m-%dT%H:%M:%SZ) \
--end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) \
--period 86400 \
--statistics SumReferences
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

