DE//AGENT
Explore
Tutorial Lesson 7 of 10 · The Reliability Series community intermediate

Attribute spend with the Cost Lens plugin

Install the Cost Lens plugin and use its three commands to attribute spend, compute unit economics, and guard cost-per-run. The plugin pairs the unit-economics skill with the Spark cost regression guard, and ships the hooks that enforce the guard in CI.

At a glance

When You need spend attributed to pipelines without writing attribution SQL by hand; A team wants unit-economics alerts wired into the agent
Where Cost Engineering
Why The plugin bundles attribution, unit economics and the cost guard, so a 4x regression shows up as a cost-per-run number instead of an invoice.

Learning objectives

  • Attribute warehouse/cluster spend with /cost-by-pipeline
  • Compute unit economics with /unit-cost
  • Guard cost-per-run regressions with /cost-guard

What you need

  • [object Object]
  • An agent host with plugin support
  • [object Object]

Steps

  1. Install the plugin: `amp plugin add de-agent/cost-lens`. (from plugin-cost-lens )
  2. Confirm the two capabilities you are wiring — cost-attribution and unit-economics. (from plugin-cost-lens )
  3. Run `/cost-by-pipeline` to attribute warehouse/cluster spend to pipelines. (from plugin-cost-lens )
  4. Run `/unit-cost` to compute unit economics. (from plugin-cost-lens )
  5. Run `/cost-guard` to alert on cost-per-run regressions rather than on total spend. (from plugin-cost-lens )
  6. Set an alert on cost-per-run, not on total spend. (from skill-cost-unit-economics )

Check yourself

  • `/cost-by-pipeline` returns spend attributed per pipeline, not one lump sum.
  • `/cost-guard` alerts on a cost-per-run regression and stays quiet when total spend grows with traffic.

Worked example

Install the plugin — from plugin-cost-lens

amp plugin add de-agent/cost-lens

The three commands — from plugin-cost-lens

/cost-by-pipeline   # attribute warehouse/cluster spend to pipelines
/unit-cost          # compute unit economics ($ per run, per 1M rows)
/cost-guard         # alert on cost-per-run regressions, not total spend

What the wired guard enforces — from hook-spark-cost-check

After the job's test run, read shuffle/spill/scan metrics from the event log,
compare against the stored baseline (median of last 5), and fail if any metric
grew by more than 25%. Emit the offending stage and metric.

Example: shuffle write grows 3.9x after a join change → build fails with the stage id.

Sourced from

Security scan

Last sweep 2026-10-24: 0 finding(s), 0 marked as examples.

Common gotchas

  • The plugin needs billing-read credentials and billing+catalog network access — without them /cost-by-pipeline has nothing to attribute.
  • Alerts fire on cost-per-run regressions, not total spend — do not 'fix' the alert by watching the invoice instead.
  • Its hook-spark-cost-check needs prior runs to build its 5-run baseline — a cold start has nothing to compare against.

Production considerations

  • Pair /cost-guard with hook-spark-cost-check so regressions fail CI before the invoice.
  • Keep the underlying skills (cost-unit-economics, spark-cost-regression-guard) for the deeper analysis.

Diagram

billing export
   |
   |- /cost-by-pipeline --> spend per pipeline
   |
   |- /unit-cost --> $ per run / per 1M rows
   |
   |- /cost-guard --> regression vs baseline --> alert --> fix in CI

Registry stats

Verification community · Oct 21, 2026
Completeness 81
Trust multiplier ×1.25
Composite 34.15 · adequate
Freshness 3 days since last source check
Difficulty intermediate
Version 0.1.0
License CC-BY-4.0
Security flags none