Commit

sudo: the costs run button is named for what it does, the whole nightly analysis

syntaqxcommitted Parentd4dee47Browse files
2 files+11−70/2 viewed
+3−3
2828 export const meta: Route.MetaFunction = () => [{ title: "Costs & margin · sudo" }, { name: "robots", content: "noindex, nofollow" }];
2929
3030 const DONE: Record<string, string> = {
31− run: "Read Cloudflare's bill and reconciled. The figures below are fresh.",
31+ run: "Ran the analysis: read Cloudflare's bill, reconciled the last 31 days and checked the alerts. The figures below are fresh.",
3232 approved: "Approved. A fall applies now; a rise after the notice period, and owners on the plan are emailed.",
3333 rejected: "Rejected, with the note kept for whoever measures it next.",
3434 settings: "Guardrails saved. They apply from the next run.",
152152 <form method="post">
153153 <input type="hidden" name="intent" value="run" />
154154 <Button variant="quiet" type="submit">
155− Read the bill now
155+ Run the analysis now
156156 </Button>
157157 </form>
158158 }
434434 description="Every meter Cloudflare billed or counted in the range, as it named it, and which of g1t's products it is a cost of. Not mapped means no one decided what pays for it."
435435 >
436436 {report.lines.length === 0 ? (
437− <EmptyState title="No lines yet">The bill is read once a day at 04:17 UTC, or now with “Read the bill now”.</EmptyState>
437+ <EmptyState title="No lines yet">The bill is read once a day at 04:17 UTC, or now with “Run the analysis now”.</EmptyState>
438438 ) : (
439439 <div className="-mx-4 overflow-x-auto sm:-mx-5">
440440 <table className="w-full min-w-[48rem] text-sm">
+8−4
4747 2. Permissions: Account · Billing · Read; Account · Account Analytics · Read.
4848 3. Account resources: Include · the g1t account. No zone permissions.
4949 4. `cd services/billing && npx wrangler secret put CLOUDFLARE_BILLING_TOKEN`.
50−5. In sudo, Costs & margin → **Read the bill now**.
50+5. In sudo, Costs & margin → **Run the analysis now**.
5151
5252 Alerts are emailed through the `EMAIL` binding (Cloudflare Email Sending)
5353 to `COSTS_ALERT_EMAIL` (`hey@flagon.io`). An empty value sends none.
6666 replaces, never adds.
6767 2. g1t's own counts for the same days (replaced per day).
6868 3. Snapshot `pending_usage` into `pending_days`.
69− 4. Reconcile those days into `margin_days` and `workspace_costs`
69+ 4. Reconcile the last 31 days (further back after a gap) into
70+ `margin_days` and `workspace_costs`
7071 (replaced per day).
7172 5. Drift over the last 7 days into `cost_drift`.
7273 6. Unit costs over the last 30 days, proposed to the price book.
7475 8. Open, update and close margin alerts; email new ones.
7576 9. Email owners on the plan about rises to come.
7677
77−**Read the bill now** in sudo (`admin_run_costs`) runs step 2 at once.
78+**Run the analysis now** at the top of sudo's Costs & margin page
79+(`admin_run_costs`) runs all of step 2 at once, alerts included, with no
80+need to wait for 04:17 UTC. Running it twice is safe: every step replaces
81+what it wrote.
7882
7983 ## Reconciliation math
8084
169173 Cloudflare's as it took (proposals as above).
170174 - **Drift threshold**.
171175
172−It applies from the next run; **Read the bill now** applies it at once.
176+It applies from the next run; **Run the analysis now** applies it at once.
173177 Every change is in the audit log (`cost_mapping`).
174178
175179 ## Which raw meters are operations