Manages CloudWatch metrics and alarms: metric retrieval, alarm creation, anomaly detection, and dashboard publishing.
Agentic Workflow: Read -> Reason -> Act (aws-cloudwatch)
You are Aws Cloudwatch (api/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — api context for aws-cloudwatch
- Domain: Manages CloudWatch metrics and alarms: metric retrieval, alarm creation, anomaly detection, and dashboard publishing.
- metrics: List, query, and publish metrics. —
aws cloudwatch list-metrics --namespace AWS/ApiGateway
- alarms: Create and manage CloudWatch alarms. —
aws cloudwatch put-metric-alarm --alarm-name api-5xx --alarm-description "API 5x
- Check
knowledge and prerequisites: aws
2. Reason — think for aws-cloudwatch
- For
metrics: List, query, and publish metrics. — decide which checks to run
- For
alarms: Create and manage CloudWatch alarms. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with aws-cloudwatch tools
- Tools:
Glob, Grep, Read, Aws (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
aws-cloudwatch:629ef3fe
AWS CloudWatch
What this skill does
Manages CloudWatch metrics and alarms: listing/querying metric namespaces, computing statistics over time windows, publishing custom metrics, and creating/test alarms.
When to use
- Verifying an API's error rate or latency trend
- Creating an alarm for a new service
- Publishing custom application metrics
Real commands
# Available metrics
aws cloudwatch list-metrics --namespace AWS/ApiGateway
# Query a metric over the last hour
aws cloudwatch get-metric-statistics --namespace AWS/ApiGateway --metric-name 4XXError --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ) --end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) --period 300 --statistics Sum
# Publish a custom metric
aws cloudwatch put-metric-data --namespace Custom --metric-name latency --value 120 --unit Milliseconds
# Create an alarm
aws cloudwatch put-metric-alarm --alarm-name api-5xx --metric-name 5XXError --namespace AWS/ApiGateway --statistic Sum --period 60 --evaluation-periods 3 --threshold 10 --comparison-operator GreaterThanOrEqualToThreshold
# Check alarm state
aws cloudwatch describe-alarms --state-value ALARM
Note: eaws is a typo for aws; always use aws cloudwatch ....
Testing
- Trigger an alarm intentionally with set-alarm-state, then reset to OK
- Verify period and evaluation-periods match your SLO window
Best practices
- Use Sum for error counts, Average for utilization
- Attach SNS actions for actionable alerts
- Publish custom metrics with consistent units
Capabilities
metrics
List, query, and publish metrics.
Parameters:
namespace (string): Metric namespace (AWS/... or Custom)
metric_name (string): Metric name
statistics (string): Sum, Average, Maximum, Minimum, SampleCount
Commands:
aws cloudwatch list-metrics --namespace AWS/ApiGateway
aws cloudwatch get-metric-statistics --namespace AWS/ApiGateway --metric-name 4XXError --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ) --end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) --period 300 --statistics Sum
aws cloudwatch put-metric-data --namespace Custom --metric-name latency --value 120 --unit Milliseconds
aws cloudwatch list-metrics --metric-name CPUUtilization --dimensions Name=InstanceId,Value=i-12345
aws cloudwatch get-metric-data --metric-data-queries file://queries.json --start-time ... --end-time ...
Examples:
- aws cloudwatch get-metric-statistics --namespace AWS/ApiGateway --metric-name 5XXError --period 60 --statistics Sum --start-time $(date -u -d '1h ago' +%Y-%m-%dT%H:%M:%SZ) --end-time $(date -u +%Y-%m-%dT%H:%M:%SZ)
- aws cloudwatch put-metric-data --namespace Custom --metric-name order.count --value 42 --timestamp $(date -u +%Y-%m-%dT%H:%M:%SZ)
- aws cloudwatch list-metrics --namespace AWS/Lambda --query 'Metrics[].MetricName' | sort -u
alarms
Create and manage CloudWatch alarms.
Parameters:
threshold (number): Alarm threshold
period (number): Evaluation period in seconds
evaluation_periods (number): Consecutive periods before firing
Commands:
aws cloudwatch put-metric-alarm --alarm-name api-5xx --alarm-description "API 5xx errors" --metric-name 5XXError --namespace AWS/ApiGateway --statistic Sum --period 60 --evaluation-periods 3 --threshold 10 --comparison-operator GreaterThanOrEqualToThreshold
aws cloudwatch describe-alarms --state-value ALARM
aws cloudwatch describe-alarms --alarm-names api-5xx
aws cloudwatch set-alarm-state --alarm-name api-5xx --state-value ALARM --state-reason "test"
aws cloudwatch delete-alarms --alarm-names api-5xx
Examples:
- aws cloudwatch put-metric-alarm --alarm-name api-5xx --metric-name 5XXError --namespace AWS/ApiGateway --statistic Sum --period 60 --evaluation-periods 3 --threshold 10 --comparison-operator GreaterThanOrEqualToThreshold --alarm-actions arn:aws:sns:us-east-1:123456789012:oncall
- aws cloudwatch describe-alarms --state-value ALARM --query 'MetricAlarms[].AlarmName'
- aws cloudwatch describe-alarms-for-metric --metric-name 5XXError --namespace AWS/ApiGateway
References
1---2name: "aws-cloudwatch"3description: "Manages CloudWatch metrics and alarms: metric retrieval, alarm creation, anomaly detection, and dashboard publishing. Use when working with metrics, alarms, api or when the user mentions metrics, alarms, api."4license: "MIT"5compatibility: "Requires aws."6metadata:7 source: https://skillmd.com/skills/opknock/aws-cloudwatch8 author: Kdesk9 version: 2.0.010 category: api11allowed-tools: "Glob Grep Read Bash(aws:*)"12---1314Manages CloudWatch metrics and alarms: metric retrieval, alarm creation, anomaly detection, and dashboard publishing.1516## Agentic Workflow: Read -> Reason -> Act (aws-cloudwatch)1718You are **Aws Cloudwatch** (api/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — api context for `aws-cloudwatch`21- Domain: Manages CloudWatch metrics and alarms: metric retrieval, alarm creation, anomaly detection, and dashboard publishing.22- **metrics**: List, query, and publish metrics. — `aws cloudwatch list-metrics --namespace AWS/ApiGateway`23- **alarms**: Create and manage CloudWatch alarms. — `aws cloudwatch put-metric-alarm --alarm-name api-5xx --alarm-description "API 5x`24- Check `knowledge` and `prerequisites: aws`2526### 2. Reason — think for `aws-cloudwatch`27- For `metrics`: List, query, and publish metrics. — decide which checks to run28- For `alarms`: Create and manage CloudWatch alarms. — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `aws-cloudwatch` tools32- Tools: `Glob`, `Grep`, `Read`, `Aws` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `aws-cloudwatch:629ef3fe`3536# AWS CloudWatch3738## What this skill does3940Manages CloudWatch metrics and alarms: listing/querying metric namespaces, computing statistics over time windows, publishing custom metrics, and creating/test alarms.4142## When to use4344- Verifying an API's error rate or latency trend45- Creating an alarm for a new service46- Publishing custom application metrics4748## Real commands4950```bash51# Available metrics52aws cloudwatch list-metrics --namespace AWS/ApiGateway5354# Query a metric over the last hour55aws cloudwatch get-metric-statistics --namespace AWS/ApiGateway --metric-name 4XXError --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ) --end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) --period 300 --statistics Sum5657# Publish a custom metric58aws cloudwatch put-metric-data --namespace Custom --metric-name latency --value 120 --unit Milliseconds5960# Create an alarm61aws cloudwatch put-metric-alarm --alarm-name api-5xx --metric-name 5XXError --namespace AWS/ApiGateway --statistic Sum --period 60 --evaluation-periods 3 --threshold 10 --comparison-operator GreaterThanOrEqualToThreshold6263# Check alarm state64aws cloudwatch describe-alarms --state-value ALARM65```6667Note: `eaws` is a typo for `aws`; always use `aws cloudwatch ...`.6869## Testing7071- Trigger an alarm intentionally with set-alarm-state, then reset to OK72- Verify period and evaluation-periods match your SLO window7374## Best practices7576- Use Sum for error counts, Average for utilization77- Attach SNS actions for actionable alerts78- Publish custom metrics with consistent units7980## Capabilities8182### metrics83List, query, and publish metrics.8485**Parameters:**86- `namespace` (string): Metric namespace (AWS/... or Custom)87- `metric_name` (string): Metric name88- `statistics` (string): Sum, Average, Maximum, Minimum, SampleCount8990**Commands:**91- `aws cloudwatch list-metrics --namespace AWS/ApiGateway`92- `aws cloudwatch get-metric-statistics --namespace AWS/ApiGateway --metric-name 4XXError --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ) --end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) --period 300 --statistics Sum`93- `aws cloudwatch put-metric-data --namespace Custom --metric-name latency --value 120 --unit Milliseconds`94- `aws cloudwatch list-metrics --metric-name CPUUtilization --dimensions Name=InstanceId,Value=i-12345`95- `aws cloudwatch get-metric-data --metric-data-queries file://queries.json --start-time ... --end-time ...`9697**Examples:**98- aws cloudwatch get-metric-statistics --namespace AWS/ApiGateway --metric-name 5XXError --period 60 --statistics Sum --start-time $(date -u -d '1h ago' +%Y-%m-%dT%H:%M:%SZ) --end-time $(date -u +%Y-%m-%dT%H:%M:%SZ)99- aws cloudwatch put-metric-data --namespace Custom --metric-name order.count --value 42 --timestamp $(date -u +%Y-%m-%dT%H:%M:%SZ)100- aws cloudwatch list-metrics --namespace AWS/Lambda --query 'Metrics[].MetricName' | sort -u101102### alarms103Create and manage CloudWatch alarms.104105**Parameters:**106- `threshold` (number): Alarm threshold107- `period` (number): Evaluation period in seconds108- `evaluation_periods` (number): Consecutive periods before firing109110**Commands:**111- `aws cloudwatch put-metric-alarm --alarm-name api-5xx --alarm-description "API 5xx errors" --metric-name 5XXError --namespace AWS/ApiGateway --statistic Sum --period 60 --evaluation-periods 3 --threshold 10 --comparison-operator GreaterThanOrEqualToThreshold`112- `aws cloudwatch describe-alarms --state-value ALARM`113- `aws cloudwatch describe-alarms --alarm-names api-5xx`114- `aws cloudwatch set-alarm-state --alarm-name api-5xx --state-value ALARM --state-reason "test"`115- `aws cloudwatch delete-alarms --alarm-names api-5xx`116117**Examples:**118- aws cloudwatch put-metric-alarm --alarm-name api-5xx --metric-name 5XXError --namespace AWS/ApiGateway --statistic Sum --period 60 --evaluation-periods 3 --threshold 10 --comparison-operator GreaterThanOrEqualToThreshold --alarm-actions arn:aws:sns:us-east-1:123456789012:oncall119- aws cloudwatch describe-alarms --state-value ALARM --query 'MetricAlarms[].AlarmName'120- aws cloudwatch describe-alarms-for-metric --metric-name 5XXError --namespace AWS/ApiGateway121122## References123- [CloudWatch Monitoring Docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/)124- [AWS CLI cloudwatch Reference](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudwatch/index.html)125- [API Gateway Metrics](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-metrics-and-dimensions.html)