@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 681 lines 27.1 KB
Raw
1 import * as Axiom from "@alchemy.run/axiom";
2 import * as Alchemy from "alchemy";
3 import type { Input } from "alchemy/Input";
4 import * as Output from "alchemy/Output";
5 import { Effect } from "effect";
6 import { Traces } from "./Datasets.ts";
7
8 /**
9 * `${stage} alchemy CLI overview` — a single dashboard answering the
10 * four questions we actually care about, laid out on a 12-column grid:
11 *
12 * 1. **How many active users are working on a project?**
13 * Distinct `alchemy.user.id` per `alchemy.git.origin_hash`.
14 * 2. **How many distinct projects are there?**
15 * Distinct `alchemy.git.origin_hash`.
16 * 3. **How many projects use CI/CD?**
17 * Distinct `alchemy.git.origin_hash` where `alchemy.ci=true`.
18 * 4. **What state stores are people using?**
19 * Sourced from `state_store.init` spans tagged with
20 * `alchemy.state_store.id` (the open-ended `StateService.id`
21 * slug; built-ins are `local` / `inmemory` / `http` /
22 * `cloudflare-http`, third-party stores get tracked automatically
23 * by setting their own slug). Emitted once per process via
24 * `recordStateStoreInit` at every `Layer.effect(State, …)` site.
25 *
26 * Project identity uses `alchemy.git.origin_hash` rather than
27 * `alchemy.user.id`: ephemeral CI runners regenerate `~/.alchemy/id`
28 * every job, which dramatically inflates the user count. The git
29 * origin hash is stable across runs of the same repo and is the
30 * closest proxy we have for "a project".
31 *
32 * All queries target `${stage}-traces` — Axiom's metrics datasets
33 * cannot be queried via APL, but every metric we emit has an
34 * equivalent span (`cli.<command>`, `provider.<op>`,
35 * `state_store.deploy`, `state_store.init`).
36 *
37 * Each chart's APL query is built with `Output.interpolate` against
38 * `traces.name` so Alchemy sequences the dashboard after the dataset
39 * exists. Otherwise Axiom would reject creation with
40 * `BadRequest: failed to validate ... entity not found`.
41 */
42 export const CliOverviewDashboard = Axiom.Dashboard(
43 "CliOverview",
44 Effect.gen(function* () {
45 const stack = yield* Alchemy.Stack;
46 const traces = yield* Traces;
47 const t = traces.name;
48 const isProd = stack.stage === "prod";
49 const prodTracesName: Input<string> = isProd
50 ? t
51 : (yield* Axiom.Dataset.ref("Traces", { stage: "prod" })).name;
52 // Global filter bar — a `SmartFilter` chart drives every other
53 // chart's APL via `declare query_parameters` parameters:
54 //
55 // - `alchemy_version` (every stage) narrows every chart to a
56 // single alchemy version. An explicit "All" row with an empty
57 // value short-circuits the filter via
58 // `isempty(alchemy_version)`. APL-sourced filters don't get
59 // the auto-"All" that `list` filters do, so the source query
60 // unions one in.
61 //
62 // - `dataset_filter` (non-prod stages only) lets us preview
63 // dashboard changes against `prod-traces` while defaulting to
64 // the current stage's own dataset. Charts reference the
65 // dataset via `table(dataset_filter)` instead of a literal
66 // `['<name>']` so the parameter binding takes effect. On prod
67 // we skip the filter entirely and hardcode `['prod-traces']`.
68 //
69 // Fresh stages have no spans yet, so `service.version` may not
70 // exist as a column. `column_ifexists` lets the queries parse
71 // against an empty dataset (otherwise APL rejects them with
72 // `invalid field: "service.version"`).
73 // `bin_size` drives every TimeSeries chart's bucket width so a
74 // single filter flips the whole dashboard between hourly / daily /
75 // weekly aggregation. Queries reference it as
76 // `bin(_time, totimespan(bin_size))`.
77 const declarations: Input<string> = isProd
78 ? `declare query_parameters (alchemy_version:string = "", bin_size:string = "1h");`
79 : Output.interpolate`declare query_parameters (dataset_filter:string = "${t}", alchemy_version:string = "", bin_size:string = "1h");`;
80 const datasetExpr: Input<string> = isProd
81 ? Output.interpolate`['${t}']`
82 : "table(dataset_filter)";
83 const versionFilterWhere = `\n | where isempty(alchemy_version) or tostring(column_ifexists("service.version", "")) == alchemy_version`;
84
85 const charts: Input<Axiom.DashboardProps["dashboard"]["charts"]> = [
86 {
87 id: "filter-bar",
88 type: "SmartFilter",
89 name: "Filters",
90 filters: [
91 ...(isProd
92 ? []
93 : [
94 {
95 id: "dataset_filter",
96 type: "select" as const,
97 name: "dataset",
98 active: true,
99 selectType: "list" as const,
100 options: [
101 {
102 key: `${stack.stage} (this stage)`,
103 value: t,
104 default: true,
105 },
106 {
107 key: "prod (production data)",
108 value: prodTracesName,
109 },
110 ],
111 },
112 ]),
113 {
114 id: "bin_size",
115 type: "select",
116 name: "aggregation period",
117 active: true,
118 selectType: "list",
119 options: [
120 { key: "1 hour", value: "1h", default: true },
121 { key: "6 hours", value: "6h" },
122 { key: "1 day", value: "1d" },
123 { key: "7 days", value: "7d" },
124 ],
125 },
126 {
127 id: "alchemy_version",
128 type: "select",
129 name: "alchemy version",
130 active: true,
131 selectType: "query",
132 options: [],
133 query: {
134 apl: Output.interpolate`
135 ${declarations}
136 let opts = ${datasetExpr}
137 | extend sv = tostring(column_ifexists("service.version", ""))
138 | where sv != ""
139 | distinct sv
140 | sort by sv desc
141 | project key=sv, value=sv;
142 let all = print key="All", value="";
143 union all, opts
144 `,
145 },
146 },
147 ],
148 },
149 // Row 1 — top-line counts answering Qs 1, 2, 3.
150 {
151 id: "distinct-projects",
152 name: "Distinct projects (7d)",
153 type: "Statistic",
154 query: {
155 apl: Output.interpolate`
156 ${declarations}
157 ${datasetExpr}${versionFilterWhere}
158 | extend project=tostring(['resource.custom']['alchemy.git.origin_hash'])
159 | where project != ""
160 | summarize projects=dcount(project)
161 `,
162 },
163 },
164 {
165 id: "projects-using-ci",
166 name: "Projects using CI/CD (7d)",
167 type: "Statistic",
168 query: {
169 apl: Output.interpolate`
170 ${declarations}
171 ${datasetExpr}${versionFilterWhere}
172 | extend project=tostring(['resource.custom']['alchemy.git.origin_hash']),
173 ci=tostring(['resource.custom']['alchemy.ci'])
174 | where project != "" and ci == "true"
175 | summarize projects=dcount(project)
176 `,
177 },
178 },
179 {
180 id: "active-users-7d",
181 name: "Active users — non-CI (7d)",
182 type: "Statistic",
183 query: {
184 apl: Output.interpolate`
185 ${declarations}
186 ${datasetExpr}${versionFilterWhere}
187 | extend uid=tostring(['resource.custom']['alchemy.user.id']),
188 ci=tostring(['resource.custom']['alchemy.ci'])
189 | where ci != "true"
190 | summarize users=dcount(uid)
191 `,
192 },
193 },
194 // Row 2 — Q1 broken out per-project, plus solo-vs-team split.
195 {
196 id: "users-per-project",
197 name: "Active users per project (7d)",
198 type: "Table",
199 query: {
200 apl: Output.interpolate`
201 ${declarations}
202 ${datasetExpr}${versionFilterWhere}
203 | extend project=tostring(['resource.custom']['alchemy.git.origin_hash']),
204 uid=tostring(['resource.custom']['alchemy.user.id']),
205 ci=tostring(['resource.custom']['alchemy.ci'])
206 | where project != ""
207 | summarize users_total=dcount(uid),
208 users_local=dcountif(uid, ci != "true"),
209 users_ci=dcountif(uid, ci == "true"),
210 events=count()
211 by project
212 | order by users_total desc
213 | take 100
214 `,
215 },
216 },
217 {
218 id: "project-team-size-distribution",
219 name: "Project team-size distribution (local users / project)",
220 type: "Table",
221 query: {
222 apl: Output.interpolate`
223 ${declarations}
224 ${datasetExpr}${versionFilterWhere}
225 | extend project=tostring(['resource.custom']['alchemy.git.origin_hash']),
226 uid=tostring(['resource.custom']['alchemy.user.id']),
227 ci=tostring(['resource.custom']['alchemy.ci'])
228 | where project != "" and ci != "true"
229 | summarize users=dcount(uid) by project
230 | extend bucket = case(
231 users == 1, "1 (solo)",
232 users <= 3, "2-3",
233 users <= 10, "4-10",
234 "11+")
235 | summarize projects=count() by bucket
236 | order by bucket asc
237 `,
238 },
239 },
240 // Row 3 — Q4: state-store breakdown.
241 {
242 id: "state-store-projects-by-id",
243 name: "Projects by state store (7d)",
244 type: "Table",
245 query: {
246 apl: Output.interpolate`
247 ${declarations}
248 ${datasetExpr}${versionFilterWhere}
249 | where name == "state_store.init"
250 | extend store=tostring(['attributes.custom']['alchemy.state_store.id']),
251 project=tostring(['resource.custom']['alchemy.git.origin_hash']),
252 uid=tostring(['resource.custom']['alchemy.user.id'])
253 | summarize projects=dcountif(project, project != ""),
254 users=dcount(uid),
255 inits=count()
256 by store
257 | order by projects desc
258 `,
259 },
260 },
261 {
262 id: "state-store-by-id-over-time",
263 name: "State store init by store / hour",
264 type: "TimeSeries",
265 query: {
266 apl: Output.interpolate`
267 ${declarations}
268 ${datasetExpr}${versionFilterWhere}
269 | where name == "state_store.init"
270 | extend store=tostring(['attributes.custom']['alchemy.state_store.id'])
271 | summarize count=count() by store, bin(_time, totimespan(bin_size))
272 | order by _time asc
273 `,
274 },
275 },
276 // Row 4 — adoption shape: project growth + CI-vs-local split.
277 {
278 id: "projects-over-time",
279 name: "Distinct projects per day",
280 type: "TimeSeries",
281 query: {
282 apl: Output.interpolate`
283 ${declarations}
284 ${datasetExpr}${versionFilterWhere}
285 | extend project=tostring(['resource.custom']['alchemy.git.origin_hash'])
286 | where project != ""
287 | summarize projects=dcount(project) by bin(_time, totimespan(bin_size))
288 | order by _time asc
289 `,
290 },
291 },
292 {
293 id: "active-users-over-time-hourly",
294 name: "Active users (non-CI)",
295 type: "TimeSeries",
296 query: {
297 apl: Output.interpolate`
298 ${declarations}
299 ${datasetExpr}${versionFilterWhere}
300 | extend uid=tostring(['resource.custom']['alchemy.user.id']),
301 ci=tostring(['resource.custom']['alchemy.ci'])
302 | where ci != "true" and uid != ""
303 | summarize users=dcount(uid) by bin(_time, totimespan(bin_size))
304 | order by _time asc
305 `,
306 },
307 },
308 {
309 id: "active-users-over-time-daily",
310 name: "Active users (CI vs local)",
311 type: "TimeSeries",
312 query: {
313 apl: Output.interpolate`
314 ${declarations}
315 ${datasetExpr}${versionFilterWhere}
316 | extend uid=tostring(['resource.custom']['alchemy.user.id']),
317 ci=tostring(['resource.custom']['alchemy.ci'])
318 | where uid != ""
319 | extend bucket=iff(ci == "true", "ci", "local")
320 | summarize users=dcount(uid) by bucket, bin(_time, totimespan(bin_size))
321 | order by _time asc
322 `,
323 },
324 },
325 {
326 id: "ci-vs-local-projects",
327 name: "Projects: CI vs local per day",
328 type: "TimeSeries",
329 query: {
330 apl: Output.interpolate`
331 ${declarations}
332 ${datasetExpr}${versionFilterWhere}
333 | extend project=tostring(['resource.custom']['alchemy.git.origin_hash']),
334 ci=tostring(['resource.custom']['alchemy.ci'])
335 | where project != ""
336 | extend bucket=iff(ci == "true", "ci", "local")
337 | summarize projects=dcount(project) by bucket, bin(_time, totimespan(bin_size))
338 | order by _time asc
339 `,
340 },
341 },
342 // Row 5 — keep the state-store deploy health signals for the
343 // Cloudflare-hosted store (not just init, but actual deploys).
344 {
345 id: "state-store-deploys",
346 name: "Cloudflare state store deploys (success vs error)",
347 type: "TimeSeries",
348 query: {
349 apl: Output.interpolate`
350 ${declarations}
351 ${datasetExpr}${versionFilterWhere}
352 | where name == "state_store.deploy"
353 | extend status=iff(tobool(['error']), "error", "success")
354 | summarize count=count() by status, bin(_time, totimespan(bin_size))
355 | order by _time asc
356 `,
357 },
358 },
359 {
360 id: "active-users-by-version",
361 name: "Active users by alchemy version (7d)",
362 type: "Table",
363 query: {
364 apl: Output.interpolate`
365 ${declarations}
366 ${datasetExpr}${versionFilterWhere}
367 | extend uid=tostring(['resource.custom']['alchemy.user.id']),
368 version=tostring(['resource.custom']['alchemy.version']),
369 ci=tostring(['resource.custom']['alchemy.ci'])
370 | summarize users_total=dcount(uid),
371 users_local=dcountif(uid, ci != "true"),
372 users_ci=dcountif(uid, ci == "true")
373 by version
374 | order by users_total desc
375 `,
376 },
377 },
378 // ─── Cloudflare State Store ────────────────────────────────
379 //
380 // Two span sources feed this section:
381 //
382 // - **CLI spans** (`state_store.init`, `state_store.bootstrap`,
383 // `state_store.deploy`, ...) — emitted from the user's
384 // terminal/CI. Carry `alchemy.cloudflare.account_hash` (a
385 // SHA-256 of the CF accountId) so we can count distinct
386 // deployments without leaking raw account IDs.
387 //
388 // - **Worker handler spans** (`state_store.{getVersion,
389 // listStacks,listStages,listResources,getState,setState,
390 // deleteState,getReplacedResources,deleteStack}`) — emitted
391 // from inside the deployed `alchemy-state-store` worker.
392 // Distinguished by the `alchemy.state_store.script_name`
393 // **resource** attribute (set on the worker's OTLP tracer
394 // resource); CLI spans do not carry that resource attr.
395 //
396 // Worker handler spans carry `alchemy.state_store.{op,stack,
397 // stage,fqn}` as span attributes plus a `duration` field —
398 // that's what powers the latency / op-rate / stack-count
399 // charts. Account-hash sits on CLI spans only (worker-side
400 // injection would need a separate deploy-time env-var pass).
401 {
402 id: "state-store-distinct-cloudflare-stores",
403 name: "Distinct Cloudflare state-store deployments (7d)",
404 type: "Statistic",
405 query: {
406 apl: Output.interpolate`
407 ${declarations}
408 ${datasetExpr}${versionFilterWhere}
409 | where name == "state_store.init"
410 | extend hash=tostring(['attributes.custom']['alchemy.cloudflare.account_hash'])
411 | where hash != ""
412 | summarize stores=dcount(hash)
413 `,
414 },
415 },
416 {
417 id: "state-store-distinct-stacks",
418 name: "Distinct stacks tracked (7d)",
419 type: "Statistic",
420 query: {
421 apl: Output.interpolate`
422 ${declarations}
423 ${datasetExpr}${versionFilterWhere}
424 | where ['resource.custom']['alchemy.state_store.script_name'] != ""
425 | extend stack=tostring(['attributes.custom']['alchemy.state_store.stack'])
426 | where stack != ""
427 | summarize stacks=dcount(stack)
428 `,
429 },
430 },
431 {
432 id: "state-store-total-ops",
433 name: "Cloudflare state store ops (7d)",
434 type: "Statistic",
435 query: {
436 apl: Output.interpolate`
437 ${declarations}
438 ${datasetExpr}${versionFilterWhere}
439 | where ['resource.custom']['alchemy.state_store.script_name'] != ""
440 | extend op=tostring(['attributes.custom']['alchemy.state_store.op'])
441 | where op != ""
442 | summarize ops=count()
443 `,
444 },
445 },
446 {
447 id: "state-store-op-latency",
448 name: "State store op latency (p50 / p95 / p99, 7d)",
449 type: "Table",
450 query: {
451 apl: Output.interpolate`
452 ${declarations}
453 ${datasetExpr}${versionFilterWhere}
454 | where ['resource.custom']['alchemy.state_store.script_name'] != ""
455 | extend op=tostring(['attributes.custom']['alchemy.state_store.op'])
456 | where op != ""
457 | summarize p50=percentile(duration, 50),
458 p95=percentile(duration, 95),
459 p99=percentile(duration, 99),
460 calls=count()
461 by op
462 | order by calls desc
463 `,
464 },
465 },
466 {
467 id: "state-store-ops-over-time",
468 name: "State store ops over time (by op)",
469 type: "TimeSeries",
470 query: {
471 apl: Output.interpolate`
472 ${declarations}
473 ${datasetExpr}${versionFilterWhere}
474 | where ['resource.custom']['alchemy.state_store.script_name'] != ""
475 | extend op=tostring(['attributes.custom']['alchemy.state_store.op'])
476 | where op != ""
477 | summarize count=count() by op, bin(_time, totimespan(bin_size))
478 | order by _time asc
479 `,
480 },
481 },
482 {
483 id: "state-store-error-rate",
484 name: "State store error rate by op (7d)",
485 type: "Table",
486 query: {
487 apl: Output.interpolate`
488 ${declarations}
489 ${datasetExpr}${versionFilterWhere}
490 | where ['resource.custom']['alchemy.state_store.script_name'] != ""
491 | extend op=tostring(['attributes.custom']['alchemy.state_store.op']),
492 err=tobool(['error'])
493 | where op != ""
494 | summarize errors=countif(err == true),
495 total=count()
496 by op
497 | extend error_rate=todouble(errors) / todouble(total)
498 | order by total desc
499 `,
500 },
501 },
502 {
503 id: "state-store-top-stacks",
504 name: "Top stacks by activity (7d)",
505 type: "Table",
506 query: {
507 apl: Output.interpolate`
508 ${declarations}
509 ${datasetExpr}${versionFilterWhere}
510 | where ['resource.custom']['alchemy.state_store.script_name'] != ""
511 | extend stack=tostring(['attributes.custom']['alchemy.state_store.stack'])
512 | where stack != ""
513 | summarize ops=count() by stack
514 | order by ops desc
515 | take 25
516 `,
517 },
518 },
519 {
520 id: "state-store-deployments-over-time",
521 name: "Distinct Cloudflare state-store deployments per day",
522 type: "TimeSeries",
523 query: {
524 apl: Output.interpolate`
525 ${declarations}
526 ${datasetExpr}${versionFilterWhere}
527 | where name == "state_store.init"
528 | extend hash=tostring(['attributes.custom']['alchemy.cloudflare.account_hash'])
529 | where hash != ""
530 | summarize stores=dcount(hash) by bin(_time, totimespan(bin_size))
531 | order by _time asc
532 `,
533 },
534 },
535 // ─── Resource usage & reliability ──────────────────────────
536 //
537 // Every provider lifecycle invocation is wrapped in a
538 // `provider.<op>` span (see `instrumentLifecycle` in Apply.ts)
539 // carrying `alchemy.resource.type` and `alchemy.resource.op`
540 // (precreate/create/update/delete/read). `error` is set when
541 // the lifecycle effect fails.
542 {
543 id: "resource-usage-ranked",
544 name: "Resource usage — ranked by lifecycle ops (7d)",
545 type: "Table",
546 query: {
547 apl: Output.interpolate`
548 ${declarations}
549 ${datasetExpr}${versionFilterWhere}
550 | where name startswith "provider."
551 | extend resource_type=tostring(['attributes.custom']['alchemy.resource.type']),
552 project=tostring(['resource.custom']['alchemy.git.origin_hash'])
553 | where resource_type != ""
554 | summarize ops=count(),
555 projects=dcountif(project, project != ""),
556 errors=countif(tobool(['error']) == true)
557 by resource_type
558 | order by ops desc
559 | take 200
560 `,
561 },
562 },
563 {
564 id: "resource-error-rate-by-type",
565 name: "Resource error rate by resource type (7d)",
566 type: "Table",
567 query: {
568 apl: Output.interpolate`
569 ${declarations}
570 ${datasetExpr}${versionFilterWhere}
571 | where name startswith "provider."
572 | extend resource_type=tostring(['attributes.custom']['alchemy.resource.type']),
573 err=tobool(['error'])
574 | where resource_type != ""
575 | summarize errors=countif(err == true),
576 total=count()
577 by resource_type
578 | extend error_rate=todouble(errors) / todouble(total)
579 | order by error_rate desc, total desc
580 | take 200
581 `,
582 },
583 },
584 {
585 id: "resource-error-rate-by-op",
586 name: "Resource error rate by lifecycle method (7d)",
587 type: "Table",
588 query: {
589 apl: Output.interpolate`
590 ${declarations}
591 ${datasetExpr}${versionFilterWhere}
592 | where name startswith "provider."
593 | extend op=tostring(['attributes.custom']['alchemy.resource.op']),
594 err=tobool(['error'])
595 | where op != ""
596 | summarize errors=countif(err == true),
597 total=count()
598 by op
599 | extend error_rate=todouble(errors) / todouble(total)
600 | order by total desc
601 `,
602 },
603 },
604 ];
605
606 const layout: Axiom.DashboardProps["dashboard"]["layout"] = [
607 // Row 0 — filter bar (full width, narrow)
608 { i: "filter-bar", x: 0, y: 0, w: 12, h: 2 },
609 // Row 1
610 { i: "distinct-projects", x: 0, y: 2, w: 4, h: 4 },
611 { i: "projects-using-ci", x: 4, y: 2, w: 4, h: 4 },
612 { i: "active-users-7d", x: 8, y: 2, w: 4, h: 4 },
613 // Row 2 — active users over time
614 { i: "active-users-over-time-hourly", x: 0, y: 6, w: 6, h: 6 },
615 { i: "active-users-over-time-daily", x: 6, y: 6, w: 6, h: 6 },
616 // Row 3
617 { i: "users-per-project", x: 0, y: 12, w: 8, h: 8 },
618 { i: "project-team-size-distribution", x: 8, y: 12, w: 4, h: 8 },
619 // Row 4
620 { i: "state-store-projects-by-id", x: 0, y: 20, w: 6, h: 6 },
621 { i: "state-store-by-id-over-time", x: 6, y: 20, w: 6, h: 6 },
622 // Row 5
623 { i: "projects-over-time", x: 0, y: 26, w: 6, h: 6 },
624 { i: "ci-vs-local-projects", x: 6, y: 26, w: 6, h: 6 },
625 // Row 6
626 { i: "state-store-deploys", x: 0, y: 32, w: 6, h: 6 },
627 { i: "active-users-by-version", x: 6, y: 32, w: 6, h: 6 },
628 // Row 7 — Cloudflare State Store: top-line stats
629 {
630 i: "state-store-distinct-cloudflare-stores",
631 x: 0,
632 y: 38,
633 w: 4,
634 h: 4,
635 },
636 { i: "state-store-distinct-stacks", x: 4, y: 38, w: 4, h: 4 },
637 { i: "state-store-total-ops", x: 8, y: 38, w: 4, h: 4 },
638 // Row 8 — performance: latency table (full width)
639 { i: "state-store-op-latency", x: 0, y: 42, w: 12, h: 8 },
640 // Row 9 — ops over time + error rate
641 { i: "state-store-ops-over-time", x: 0, y: 50, w: 8, h: 6 },
642 { i: "state-store-error-rate", x: 8, y: 50, w: 4, h: 6 },
643 // Row 10 — distribution + adoption shape
644 { i: "state-store-top-stacks", x: 0, y: 56, w: 6, h: 8 },
645 { i: "state-store-deployments-over-time", x: 6, y: 56, w: 6, h: 8 },
646 // Row 11 — Resource usage ranking (full width)
647 { i: "resource-usage-ranked", x: 0, y: 64, w: 12, h: 10 },
648 // Row 12 — Error rate broken down by resource type and lifecycle method
649 { i: "resource-error-rate-by-type", x: 0, y: 74, w: 8, h: 10 },
650 { i: "resource-error-rate-by-op", x: 8, y: 74, w: 4, h: 10 },
651 ];
652
653 return {
654 dashboard: {
655 name: `${stack.stage} alchemy CLI overview`,
656 // Empty owner = X-AXIOM-EVERYONE (org-shared). API tokens
657 // can't create per-user "private" dashboards.
658 owner: "",
659 description: [
660 "Adoption telemetry: distinct projects, active users per project, ",
661 "CI vs local usage, and state-store backend breakdown. Plus ",
662 "Cloudflare State Store ops: distinct deployments, stack count, ",
663 "per-op latency / error rate. ",
664 "Resource usage: ranked list of resource types by lifecycle ops, ",
665 "with error rates broken down by resource type and by lifecycle method. ",
666 "Project identity = alchemy.git.origin_hash (stable across CI runs); ",
667 "user identity = alchemy.user.id (ephemeral in CI); ",
668 "Cloudflare deployment identity = alchemy.cloudflare.account_hash ",
669 "(SHA-256 of accountId, set on CLI state_store.* spans).",
670 ].join(""),
671 refreshTime: 60 as const,
672 schemaVersion: 2 as const,
673 // Axiom requires the `qr-now-{duration}` form for relative times.
674 timeWindowStart: "qr-now-7d",
675 timeWindowEnd: "qr-now",
676 charts,
677 layout,
678 },
679 };
680 }),
681 );