byaan-ai/byaan/cloudwatch-logs
Claude Code and agent skill by byaan-ai/byaan
- community
Checking that the SKILL.md file is still in the repository.
Query and search AWS CloudWatch Logs and run Logs Insights queries
Install
npx vskill@latest install byaan-ai/byaan/cloudwatch-logsSKILL.md
CloudWatch Logs API
Use the AWS CloudWatch Logs API to query log groups, search log events, and run CloudWatch Logs Insights queries.
Setup Guide
This skill requires read-only access to AWS CloudWatch Logs. No write or delete permissions are needed — Byaan only reads your logs, it never modifies them.
Choose an authentication mode
- Instance IAM role (recommended when Byaan runs on AWS) — no keys to create, store, or rotate. Byaan uses the AWS default credential chain (EC2 instance profile / ECS task role / env credentials). Select "Instance IAM role (auto)" and set only the Region.
- Access keys — for Byaan deployments outside AWS. An IAM user with programmatic access (Access Key ID + Secret Access Key) and read-only CloudWatch Logs permissions. Create a dedicated IAM user for Byaan rather than reusing an admin account.
Option A: Instance IAM role
- In the AWS Console → IAM → Roles, create (or reuse) a role for the EC2 instance / ECS task running Byaan
- Attach the
CloudWatchLogsReadOnlyAccessmanaged policy, or the custom read-only policy shown below - Attach the role to the instance (EC2 → Instance → Actions → Security → Modify IAM role) or the ECS task definition
- If Byaan runs in Docker on EC2 (the standard self-hosted setup), the container must be able to reach instance metadata. IMDSv2's default hop limit of 1 blocks containers — raise it once:
- In Byaan, go to Settings > Skills > CloudWatch Logs, choose Instance IAM role (auto), and set the Region
Option B: Access keys — step-by-step
- In the AWS Console → IAM → Users, create a new user (e.g.,
byaan-cloudwatch-reader) - Attach the AWS managed policy
CloudWatchLogsReadOnlyAccess, or create a custom policy with these specific actions:
You can restrict Resource to specific log groups if you want tighter scoping (e.g., "arn:aws:logs:us-east-1:123456789:log-group:/aws/lambda/*").
- Under Security credentials, create an Access Key (select "Third-party service" as the use case)
- Copy the Access Key ID and Secret Access Key
- In Byaan, go to Settings > Skills > CloudWatch Logs and paste:
- Access Key ID — starts with
AKIA... - Secret Access Key — the paired secret
- Region — the AWS region where your logs live (e.g.,
us-east-1). CloudWatch Logs are regional, so pick the region matching your services
How Authentication Works
You do not need to handle authentication manually. When you call execute_skill_api(), the system automatically:
- Retrieves the AWS credentials from the configured skill
- Creates a boto3 CloudWatch Logs client with those credentials
- Calls the specified action with the provided parameters
Just call the API with skill name, action name, and parameters — authentication is handled for you.
How to Call the API
CloudWatch Logs uses action-based invocation. Set endpoint_path to the action name (PascalCase) and body to a JSON string of parameters.
Parameters:
skill_name: Always"cloudwatch_logs"endpoint_path: The action name in PascalCase (e.g.,"FilterLogEvents","DescribeLogGroups")method: Always"POST"body: JSON string of parameters for the action
Key Operations
DescribeLogGroups — List log groups
With prefix filter:
DescribeLogStreams — List streams in a log group
FilterLogEvents — Search logs by pattern
This is the primary way to search for log entries. Supports filter patterns.
Important: startTime and endTime are epoch milliseconds (not seconds). Multiply Unix timestamps by 1000.
GetLogEvents — Read a specific stream
GetLogRecord — Get full log record by pointer
When Insights queries return results, each record includes a @ptr field. Use GetLogRecord to retrieve the complete log event from that pointer.
This is useful for drill-down: run an Insights query to find interesting records, then use @ptr to get the full untruncated log event.
StartQuery + GetQueryResults — CloudWatch Logs Insights
Insights queries are asynchronous. You must start the query, then poll for results.
Step 1: Start the query
Note: For StartQuery, startTime and endTime are epoch seconds (not milliseconds, unlike FilterLogEvents).
This returns a queryId.
Step 2: Get results (poll until status is "Complete")
The response includes a status field. Poll until it is "Complete". Possible values: Scheduled, Running, Complete, Failed, Cancelled, Timeout.
StopQuery — Cancel a running Insights query
If a query is taking too long or the user wants to abort, cancel it with StopQuery:
Returns true if the query was successfully stopped. Use this when GetQueryResults keeps returning Running after multiple polls.
CloudWatch Logs Insights Query Syntax
Insights uses a pipe-delimited query language:
Commands
- fields: Select fields to display —
fields @timestamp, @message - filter: Filter results —
filter @message like /pattern/orfilter statusCode >= 400 - sort: Order results —
sort @timestamp desc - limit: Cap results —
limit 100 - stats: Aggregation —
stats count(*) by bin(1h)orstats avg(duration) by functionName - parse: Extract fields from messages —
parse @message "Duration: * ms" as duration - display: Choose which fields appear in output (after stats)
Built-in Fields
@timestamp— Event timestamp@message— Full log message@logStream— Log stream name@log— Log group identifier@ingestionTime— When CloudWatch received the event
Example Insights Queries
Count errors per hour:
Average Lambda duration:
Top 10 most frequent error messages:
Request tracing by ID:
P99 latency:
Log Analysis Patterns
Use these Insights query recipes for operational analysis. These replicate the kind of analysis that dedicated log analysis tools perform.
Error Pattern Detection
Identify distinct error types and their frequency:
Spike Detection
Compare current error rate against the previous period to detect anomalies:
After retrieving results, compare the most recent bins against the average of earlier bins. A bin with >2x the average signals a spike.
Log Volume Analysis
Detect unusual log volume changes (potential indicator of issues):
Message Pattern Extraction
Extract structured data from unstructured log messages:
Lambda Cold Start Analysis
API Gateway Latency Breakdown
Error Rate as Percentage
Cross-Log-Group Analysis
Query multiple log groups simultaneously by passing an array to logGroupNames in StartQuery:
Operational Troubleshooting Workflow
When a user reports an incident or asks to investigate an issue, follow this structured approach:
Step 1: Gather Context
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingserver/skills/cloudwatch_logs/SKILL.md
Popularity
- Repository stars
- 92
- Repository forks
- 1
- 7-day trend score
- 23
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/byaan-ai/byaan/cloudwatch-logs)