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
| 1 | import * as Axiom from "@alchemy.run/axiom"; |
| 2 | import * as Alchemy from "alchemy"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | |
| 5 | /** Shorty's service dashboard, declared next to the code it observes. */ |
| 6 | export const Dashboard = Effect.gen(function* () { |
| 7 | const { stage } = yield* Alchemy.Stack; |
| 8 | const dataset = `['shorty-${stage}-traces']`; |
| 9 | |
| 10 | const charts: Axiom.DashboardProps["dashboard"]["charts"] = [ |
| 11 | { |
| 12 | id: "requests", |
| 13 | name: "Requests by route", |
| 14 | type: "TimeSeries", |
| 15 | query: { |
| 16 | apl: `${dataset} | where kind == 'server' | summarize count() by bin_auto(_time), ['attributes.http.route']`, |
| 17 | }, |
| 18 | }, |
| 19 | { |
| 20 | id: "latency", |
| 21 | name: "p95 latency (ms)", |
| 22 | type: "Statistic", |
| 23 | query: { |
| 24 | apl: `${dataset} | where kind == 'server' | summarize percentile(duration / 1ms, 95)`, |
| 25 | }, |
| 26 | }, |
| 27 | { |
| 28 | id: "clicks", |
| 29 | name: "Clicks by link", |
| 30 | type: "Table", |
| 31 | query: { |
| 32 | apl: `${dataset} | where name == 'clicks.record' | summarize clicks = sum(toint(['attributes.custom']['n'])) by link = tostring(['attributes.custom']['code']) | order by clicks desc`, |
| 33 | }, |
| 34 | }, |
| 35 | { |
| 36 | id: "errors", |
| 37 | name: "Errors", |
| 38 | type: "TimeSeries", |
| 39 | query: { |
| 40 | apl: `${dataset} | where ['status.code'] == 'ERROR' | summarize count() by bin_auto(_time), name`, |
| 41 | }, |
| 42 | }, |
| 43 | ]; |
| 44 | |
| 45 | return yield* Axiom.Dashboard("Dashboard", { |
| 46 | dashboard: { |
| 47 | name: `Shorty (${stage})`, |
| 48 | owner: "", |
| 49 | description: "Requests, latency, clicks and errors for the Shorty API", |
| 50 | refreshTime: 15, |
| 51 | schemaVersion: 2, |
| 52 | timeWindowStart: "qr-now-30m", |
| 53 | timeWindowEnd: "qr-now", |
| 54 | charts, |
| 55 | layout: [ |
| 56 | { i: "requests", x: 0, y: 0, w: 8, h: 6 }, |
| 57 | { i: "latency", x: 8, y: 0, w: 4, h: 6 }, |
| 58 | { i: "clicks", x: 0, y: 6, w: 6, h: 6 }, |
| 59 | { i: "errors", x: 6, y: 6, w: 6, h: 6 }, |
| 60 | ], |
| 61 | }, |
| 62 | }); |
| 63 | }); |