FDE-130: AWS Cost and Usage Report (CUR) → Last9 via OTel metrics#177
Open
prathamesh-sonpatki wants to merge 8 commits into
Open
Conversation
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>
| 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", []))) |
|
|
||
| df = read_cur_parquet(s3, manifest) | ||
| if df.empty: | ||
| log.info(" No data in period %s", period_prefix) |
| send_otlp_metrics(agg) | ||
|
|
||
| except s3.exceptions.NoSuchKey: | ||
| log.warning("Manifest not found for %s — CUR may still be generating", period_prefix) |
| 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) |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
python/aws-cur/example that reads AWS Cost and Usage Report (CUR) parquet files from S3 and exports billing metrics to Last9aws.cost.unblended(USD) andaws.usage.quantitygrouped by service, account, region, usage_type with correct historical timestampsMetrics
aws.cost.unblendedaws.service,aws.account.id,aws.region,aws.usage.typeaws.usage.quantityaws.service,aws.account.id,aws.region,aws.usage.typeTest plan
CUR_S3_BUCKET,CUR_S3_PREFIX,CUR_REPORT_NAMEin.envdocker compose up— confirm logs showExported N cost + N usage data points to Last9aws.cost.unblended{aws.service="AmazonEC2"}in Last9Linear
FDE-130
🤖 Generated with Claude Code