agentsclimarketplace

Aws cloudwatch

Skill Mikask1/fix-error-skill/skills/aws-cloudwatch

Retrieve and query AWS CloudWatch logs using the AWS CLI. Use when you need to fetch log groups, log streams, log events, or run CloudWatch Insights queries to find errors, filter by pattern, or analyze log volume.From its SKILL.md

Install
npx -y skills add Mikask1/fix-error-skill --skill aws-cloudwatch

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

4.2 KB, as published. Nobody here has run it

AWS CloudWatch Logs

Retrieve logs from AWS CloudWatch using the AWS CLI.

Pre-flight: verify credentials

aws sts get-caller-identity

If this fails, the CLI is not configured. Tell the user to run aws configure or aws configure sso and retry. Do not proceed until credentials are confirmed.

Add --region <region> to any command below when logs are in a non-default region.


Operations

List log groups

# All log groups
aws logs describe-log-groups --query 'logGroups[*].logGroupName' --output table

# Filtered by prefix
aws logs describe-log-groups --log-group-name-prefix "/aws/lambda/my-service" \
  --query 'logGroups[*].logGroupName' --output table

List recent log streams

aws logs describe-log-streams \
  --log-group-name "<LOG_GROUP>" \
  --order-by LastEventTime \
  --descending \
  --max-items 10 \
  --query 'logStreams[*].{name:logStreamName,last:lastEventTimestamp}'

Fetch log events from a stream

aws logs get-log-events \
  --log-group-name "<LOG_GROUP>" \
  --log-stream-name "<LOG_STREAM>" \
  --limit 200 \
  --query 'events[*].{time:timestamp,msg:message}'

Add --start-time <epoch-ms> and --end-time <epoch-ms> to restrict the window.

Filter log events by pattern (across a group)

aws logs filter-log-events \
  --log-group-name "<LOG_GROUP>" \
  --filter-pattern "ERROR" \
  --start-time $(date -d '1 hour ago' +%s000) \
  --end-time $(date +%s000) \
  --limit 100

Pattern syntax: "ERROR" (substring), ?"ERROR" ?"WARN" (OR), { $.level = "ERROR" } (JSON field).

CloudWatch Insights query (best for large volumes)

Step 1 — Start the query:

aws logs start-query \
  --log-group-name "<LOG_GROUP>" \
  --start-time $(date -d '1 hour ago' +%s) \
  --end-time $(date +%s) \
  --query-string 'fields @timestamp, @message
    | filter @message like /ERROR|Exception|FATAL/
    | sort @timestamp desc
    | limit 50'

Save the returned queryId.

Step 2 — Poll for results:

aws logs get-query-results --query-id "<QUERY_ID>"

Re-run until status is Complete. Results are in the results array.

Useful Insights query patterns:

# Top error messages by frequency
fields @message
| filter @message like /ERROR/
| stats count() as hits by @message
| sort hits desc
| limit 20

# Error rate over time
fields @timestamp
| filter @message like /ERROR/
| stats count() as errors by bin(5m)

# Latency p99 (for structured logs with a duration field)
fields @timestamp, duration
| filter ispresent(duration)
| stats pct(duration, 99) as p99 by bin(1h)

Epoch time helpers

# 1 hour ago (seconds)
date -d '1 hour ago' +%s

# 1 hour ago (milliseconds — needed for filter-log-events)
date -d '1 hour ago' +%s000

# Specific time to epoch
date -d '2026-05-04 14:00:00' +%s

On macOS use date -v-1H +%s instead of date -d.


Common log group patterns

PatternService type
/aws/lambda/<env>-<service>Lambda functions
/ecs/<cluster>/<service>ECS tasks
/aws/apigateway/<api-id>API Gateway access logs
/aws/rds/instance/<id>/errorRDS error logs
<service>-<env>Custom application groups

IAM permissions required

ActionPermission
List log groupslogs:DescribeLogGroups
List log streamslogs:DescribeLogStreams
Fetch eventslogs:GetLogEvents
Filter eventslogs:FilterLogEvents
Insights querieslogs:StartQuery, logs:GetQueryResults

If you hit AccessDeniedException, tell the user which permission is missing.


Critical Rules

  • NEVER print or log AWS credentials — if they appear in output, redact them immediately
  • Always use --limit when fetching events — unbounded fetches on high-volume groups are slow and expensive
  • Prefer Insights for groups > 1GB — get-log-events is inefficient at scale
  • Use milliseconds for filter-log-events time flags, seconds for Insights

Keep looking

Skills are one crate of 608,475. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.