Query AWS costs, identify spend patterns, and surface anomalies
The copilot can query AWS Cost Explorer data to break down spend by service, region, and account, identify cost trends, detect anomalies, drill into resource-level costs, and forecast future spend. Use it to answer billing questions, investigate cost spikes, and find optimization opportunities without leaving the chat interface.
Connect an AWS account with Cost Explorer API access enabled. The IAM role used by Kestrel needs ce:GetCostAndUsage, ce:GetCostForecast, and related Cost Explorer permissions.
AWS Cost Explorer data is typically delayed by 24–48 hours. The copilot returns the most recent data available, but today’s costs may not be fully reflected yet.
Drill into specific resources to understand cost drivers.
@cloud:prod-aws Which RDS instances cost the most? Include instance type, storage, and whether they're Multi-AZ.
@cloud:prod-aws Estimate how much we'd save if we right-sized all EC2 instances in us-east-1 that have averaged less than 15% CPU utilization over the last 30 days.
@cloud:prod-aws Which Elastic IPs are allocated but not associated with a running instance? How much are they costing us?
@cloud:prod-aws What are the most expensive EBS volumes? Flag any that are unattached or over-provisioned relative to their utilization.
@cloud:prod-aws How much are we spending on idle or underutilized load balancers?
@cloud:prod-aws @cloud:staging-aws Compare total monthly spend across both accounts for the last 3 months. How much is staging costing relative to production?
@cloud:prod-aws @cloud:staging-aws @cloud:dev-aws What's the cost per environment for EC2 and RDS? Are non-production environments disproportionately expensive?
@cloud:prod-aws @cloud:staging-aws Are we running the same instance types in staging as production? If staging is using larger instances, how much would we save by right-sizing?
@cloud:prod-aws Our AWS bill jumped 30% this month. What’s going on?
Kestrel:
Your total AWS spend for the current month is 47,200,upfrom36,300 last month (+30%). The top 3 drivers of the increase:
EC2 — up $5,800 (+28%). Three new m5.2xlarge instances were launched in us-west-2 on the 15th. They’re running in the analytics account and aren’t part of any Auto Scaling group.
RDS — up $3,100 (+41%). The prod-analytics instance had a storage auto-scaling event that grew it from 500GB to 1.2TB. There was also a class change from db.r5.large to db.r5.2xlarge on the 8th.
NAT Gateway — up $2,000 (+62%). Data processing through the NAT gateway in us-east-1 doubled compared to last month, likely from the new batch processing jobs.
You:
Can we save money on those EC2 instances? They might be over-provisioned.
Kestrel:
Based on CloudWatch metrics for the last 2 weeks, the three m5.2xlarge instances in us-west-2 average 12% CPU utilization and 4.2GB of memory usage (out of 32GB available). You have a few options:
Right-size to m5.large: Saves ~$4,200/month. The instances would still have headroom at 48% average CPU and 8GB memory.
Switch to Spot: These aren’t in an ASG but could tolerate interruption if they’re batch analytics jobs. Spot pricing for m5.2xlarge in us-west-2 is currently 67% cheaper.
Reserved Instances: If you need them long-term, a 1-year no-upfront RI for m5.large would save an additional 30% on top of right-sizing.
You:
Let’s right-size them to m5.large. Can you find the Terraform code?
Kestrel:
The instances are defined in acme/infrastructure/terraform/analytics/ec2.tf. Here’s the proposed change to update all three from m5.2xlarge to m5.large:(displays Terraform diff with Create PR and Copy options)