-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnalytics.jsx
More file actions
334 lines (322 loc) · 9.3 KB
/
Copy pathAnalytics.jsx
File metadata and controls
334 lines (322 loc) · 9.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
import { useState } from "react";
import {
Alert,
Badge,
Card,
Col,
Progress,
Row,
Select,
Space,
Statistic,
Table,
Tag,
Typography,
} from "antd";
import icon from "./favicon.svg";
export const RTIFACT = {
title: "Platform Operations Analytics",
icon,
};
const incidents = [
{
key: "1",
service: "Checkout API",
region: "eu-west",
latency: "842 ms",
change: "+18%",
health: "Degraded",
},
{
key: "2",
service: "Event ingest",
region: "us-east",
latency: "118 ms",
change: "−4%",
health: "Healthy",
},
{
key: "3",
service: "Search index",
region: "ap-south",
latency: "390 ms",
change: "+7%",
health: "Watching",
},
{
key: "4",
service: "Identity",
region: "global",
latency: "76 ms",
change: "−12%",
health: "Healthy",
},
];
const metrics = [
{
title: "Requests",
value: 28.4,
suffix: "M",
precision: 1,
delta: "+12.8%",
},
{
title: "Availability",
value: 99.982,
suffix: "%",
precision: 3,
delta: "+0.014%",
},
{
title: "p95 latency",
value: 184,
suffix: "ms",
delta: "−8.2%",
},
{
title: "Open incidents",
value: 3,
delta: "−2 today",
},
];
const columns = [
{
title: "Service",
dataIndex: "service",
render: (value) => <strong>{value}</strong>,
},
{
title: "Region",
dataIndex: "region",
render: (value) => <code>{value}</code>,
},
{ title: "p95 latency", dataIndex: "latency" },
{
title: "24h",
dataIndex: "change",
render: (value) => (
<Typography.Text type={value.startsWith("+") ? "danger" : "success"}>
{value}
</Typography.Text>
),
},
{
title: "Health",
dataIndex: "health",
render: (value) => (
<Badge
status={
value === "Healthy"
? "success"
: value === "Degraded"
? "error"
: "warning"
}
text={value}
/>
),
},
];
function SparkBars({ values }) {
return (
<div
className="flex h-24 items-end gap-1"
role="img"
aria-label="Illustrative request volume rises overall with several short dips."
>
{values.map((value, index) => (
<span
key={index}
aria-hidden="true"
className="min-w-1 flex-1 rounded-t-sm bg-primary opacity-70"
style={{ height: `${value}%` }}
/>
))}
</div>
);
}
export default function Analytics() {
const [health, setHealth] = useState("All");
const visibleServices =
health === "All"
? incidents
: incidents.filter((service) => service.health === health);
return (
<main className="min-h-screen p-4 sm:p-6 lg:p-8">
<article className="mx-auto max-w-7xl">
<header className="mb-6">
<div className="flex flex-wrap items-start justify-between gap-4">
<Space orientation="vertical" size={2}>
<Typography.Text
type="secondary"
className="text-xs uppercase tracking-[0.16em]"
>
Illustrative 24-hour snapshot
</Typography.Text>
<Typography.Title className="m-0">
Platform operations
</Typography.Title>
<Typography.Paragraph
type="secondary"
className="mb-0 max-w-2xl text-base leading-relaxed"
>
A static example of how a portable operations report can surface
the conclusion first, then preserve the evidence for review.
</Typography.Paragraph>
</Space>
<Tag color="blue">Example data · not live</Tag>
</div>
</header>
<section aria-labelledby="summary-heading">
<Typography.Title id="summary-heading" level={2} className="sr-only">
Operations summary
</Typography.Title>
<Alert
type="warning"
showIcon
title="Checkout latency needs attention"
description="Checkout API is the only degraded service shown: p95 latency is 842 ms, up 18% in this illustrative snapshot. Search index remains on watch."
className="mb-4"
/>
<Row gutter={[16, 16]}>
{metrics.map(({ title, value, suffix, precision, delta }) => (
<Col key={title} xs={24} sm={12} xl={6}>
<Card className="h-full">
<Statistic
title={title}
value={value}
precision={precision}
suffix={suffix}
/>
<Typography.Text
type={
delta.startsWith("−") || title === "Availability"
? "success"
: undefined
}
className="mt-3 block text-sm"
>
{delta}{" "}
<Typography.Text type="secondary">
vs previous 24h
</Typography.Text>
</Typography.Text>
</Card>
</Col>
))}
</Row>
</section>
<div className="mt-4 grid gap-4 xl:grid-cols-[1.55fr_0.75fr]">
<section aria-labelledby="traffic-heading">
<Card
className="h-full"
title={
<Typography.Title
id="traffic-heading"
level={2}
className="m-0"
>
Request volume
</Typography.Title>
}
extra={<Tag>24 hours</Tag>}
>
<figure className="m-0 grid gap-5 md:grid-cols-[1fr_180px]">
<div>
<SparkBars
values={[
28, 35, 31, 42, 48, 44, 53, 61, 58, 67, 74, 69, 77, 84,
72, 88, 82, 91, 87, 76, 83, 89, 94, 90,
]}
/>
<figcaption className="mt-2 text-sm text-muted-foreground">
Relative volume by hour; bars show shape, not an exact
scale.
</figcaption>
</div>
<dl className="grid grid-cols-2 gap-3 text-sm md:grid-cols-1">
<div>
<dt className="text-muted-foreground">Peak</dt>
<dd className="m-0 text-xl font-semibold">1.42k/s</dd>
</div>
<div>
<dt className="text-muted-foreground">Average</dt>
<dd className="m-0 text-xl font-semibold">986/s</dd>
</div>
</dl>
</figure>
</Card>
</section>
<section aria-labelledby="budget-heading">
<Card
className="h-full"
title={
<Typography.Title id="budget-heading" level={2} className="m-0">
Error budget
</Typography.Title>
}
>
<div className="flex items-center justify-center py-2">
<Progress
type="dashboard"
percent={73}
aria-label="73 percent of error budget remaining"
/>
</div>
<dl className="grid grid-cols-2 gap-4 text-center">
<div>
<dt className="text-sm text-muted-foreground">Remaining</dt>
<dd className="m-0 font-semibold">6h 34m</dd>
</div>
<div>
<dt className="text-sm text-muted-foreground">Burn rate</dt>
<dd className="m-0 font-semibold">2.1%</dd>
</div>
</dl>
</Card>
</section>
</div>
<section aria-labelledby="health-heading" className="mt-4">
<Card
title={
<div>
<Typography.Title id="health-heading" level={2} className="m-0">
Service health
</Typography.Title>
</div>
}
>
<div className="mb-4 flex flex-wrap items-center justify-between gap-3">
<Typography.Text type="secondary">
{visibleServices.length} of {incidents.length} illustrative
services shown
</Typography.Text>
<div>
<label htmlFor="health-filter" className="sr-only">
Filter services by health
</label>
<Select
id="health-filter"
value={health}
onChange={setHealth}
aria-label="Filter services by health"
className="w-36"
options={["All", "Degraded", "Watching", "Healthy"].map(
(value) => ({ value, label: value }),
)}
/>
</div>
</div>
<Table
columns={columns}
dataSource={visibleServices}
pagination={false}
scroll={{ x: 760 }}
rowKey="key"
/>
</Card>
</section>
</article>
</main>
);
}