Skip to content

FDE-130: AWS Cost and Usage Report (CUR) → Last9 via OTel metrics#177

Open
prathamesh-sonpatki wants to merge 8 commits into
mainfrom
prathamesh/fde-130-aws-cost-dashboard-service-wise-breakdown-on-last9-traya
Open

FDE-130: AWS Cost and Usage Report (CUR) → Last9 via OTel metrics#177
prathamesh-sonpatki wants to merge 8 commits into
mainfrom
prathamesh/fde-130-aws-cost-dashboard-service-wise-breakdown-on-last9-traya

Conversation

@prathamesh-sonpatki
Copy link
Copy Markdown
Member

Summary

  • Adds python/aws-cur/ example that reads AWS Cost and Usage Report (CUR) parquet files from S3 and exports billing metrics to Last9
  • Exports aws.cost.unblended (USD) and aws.usage.quantity grouped by service, account, region, usage_type with correct historical timestamps
  • Handles both CUR v1 (slash column names) and v2 (snake_case) parquet formats
  • Runs as a Docker container, polls hourly, backfills configurable number of billing periods on startup

Metrics

Metric Unit Dimensions
aws.cost.unblended USD aws.service, aws.account.id, aws.region, aws.usage.type
aws.usage.quantity 1 aws.service, aws.account.id, aws.region, aws.usage.type

Test plan

  • Enable CUR in AWS Billing with Parquet format, Daily granularity
  • Set CUR_S3_BUCKET, CUR_S3_PREFIX, CUR_REPORT_NAME in .env
  • docker compose up — confirm logs show Exported N cost + N usage data points to Last9
  • Query aws.cost.unblended{aws.service="AmazonEC2"} in Last9

Linear

FDE-130

🤖 Generated with Claude Code

Exports daily AWS billing data from Cost and Usage Reports (S3 parquet)
to Last9 as gauge metrics with correct historical timestamps.

Metrics: aws.cost.unblended (USD), aws.usage.quantity — grouped by
service, account, region, usage_type. Handles both CUR v1 (slash) and
v2 (snake_case) parquet column naming.

Closes FDE-130

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread python/aws-cur/main.py
manifest = load_manifest(s3, period_prefix)
billing_start = manifest.get("billingPeriod", {}).get("start", period_prefix)
log.info("Billing period: %s (%d file(s))",
billing_start, len(manifest.get("reportKeys", [])))
Comment thread python/aws-cur/main.py

df = read_cur_parquet(s3, manifest)
if df.empty:
log.info(" No data in period %s", period_prefix)
Comment thread python/aws-cur/main.py
send_otlp_metrics(agg)

except s3.exceptions.NoSuchKey:
log.warning("Manifest not found for %s — CUR may still be generating", period_prefix)
Comment thread python/aws-cur/main.py
except s3.exceptions.NoSuchKey:
log.warning("Manifest not found for %s — CUR may still be generating", period_prefix)
except Exception as exc: # noqa: BLE001
log.error("Error processing %s: %s", period_prefix, exc)
prathamesh-sonpatki and others added 7 commits April 24, 2026 14:00
Add aws.cost.amortized metric using per-type effective cost columns
(savings_plan_savings_plan_effective_cost for SP, reservation_effective_cost
for RI) — shows true cost after RI/SP amortization vs unblended.

Add COST_ALLOCATION_TAGS env var: forwards CUR resource_tags_user_* columns
as aws.tag.* metric dimensions for team/env/project cost slicing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Generates 7 days of synthetic CUR rows covering Usage, SavingsPlanCoveredUsage,
DiscountedUsage, and Tax line items. Validates amortized < unblended for SP,
amortized > 0 for RI with $0 unblended, Tax exclusion, and tag forwarding.
Sends real OTLP to Last9 — no AWS account required.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Restructure as numbered setup steps (enable CUR, IAM policy, configure+run).
Add test_local.py to verification section. Fix log line in verification snippet.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Simple alternative to CUR — polls Cost Explorer API (ce:GetCostAndUsage),
no S3 or CUR setup required. Data flows within minutes.

Exports aws.cost.unblended and aws.cost.amortized grouped by service,
account, region with correct historical timestamps via direct OTLP/HTTP JSON.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e schedule

Add lambda_handler to main.py (dual-mode: Lambda + standalone Docker loop).
Add deploy.sh that creates IAM role, packages Lambda, and wires EventBridge
daily schedule via AWS CLI — single command deploy, no servers needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lick deploy

Self-contained template with inline Lambda code (urllib, no external deps).
Creates IAM role, Lambda (Python 3.13, 5min timeout), and EventBridge daily
schedule. Customer uploads to AWS console, fills OtlpHeaders, done.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Neo4j: prometheus receiver scraping port 2004, requires Enterprise Edition
- Cassandra: JMX metrics sidecar (eclipse-temurin:17-jre-jammy) + OTel Collector
  with OTLP receiver; sidecar approach avoids 0.0.0.0 routing issue in Docker
- PostgreSQL (no-Docker): postgresql receiver + filelog for slow queries + systemd unit

Each integration includes docker-compose for local testing, .env.example,
.gitignore, and README with bare-metal production setup instructions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants