mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-28 05:46:36 +08:00
a4dd5ca9e1
- 24 小时请求趋势拆分展示请求总量与 200/400/500 状态码请求量,独占一行; 时间桶聚合新增 status_200/400/500_count(CH countIf、PG FILTER), 请求趋势改为基于原始桶聚合(小时 rollup 无状态码口径) - 首页移除宿主机磁盘指标,容量趋势(CPU/内存)并入业务流量卡片展示 - 压缩协议 traffic_24h 扩展为 7 元组,前端归一化同步更新
66 lines
1.8 KiB
TypeScript
66 lines
1.8 KiB
TypeScript
'use client';
|
|
|
|
import { TrendChart } from '@/components/data/trend-chart';
|
|
import {
|
|
Card,
|
|
CardContent,
|
|
CardDescription,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from '@/components/ui/card';
|
|
import type { TrafficTrendPoint } from '@/lib/services/openflare';
|
|
|
|
import { formatTrendHour } from './dashboard-utils';
|
|
|
|
export function TrafficTrendChart({
|
|
points,
|
|
title = '24 小时请求趋势',
|
|
description = '按小时拆分请求总量与 2xx/4xx/5xx 状态码请求量,判断各状态是否异常抬升。',
|
|
}: {
|
|
points: TrafficTrendPoint[];
|
|
title?: string;
|
|
description?: string;
|
|
}) {
|
|
return (
|
|
<Card className='border-dashed shadow-none'>
|
|
<CardHeader>
|
|
<CardTitle className='text-sm font-semibold'>{title}</CardTitle>
|
|
<CardDescription className='text-xs'>{description}</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<TrendChart
|
|
labels={points.map((point) =>
|
|
formatTrendHour(point.bucket_started_at),
|
|
)}
|
|
summaryScope='total'
|
|
summaryHint='近 24 小时'
|
|
series={[
|
|
{
|
|
label: '请求量',
|
|
color: '#f59e0b',
|
|
fillColor: 'rgba(245, 158, 11, 0.18)',
|
|
variant: 'area',
|
|
values: points.map((point) => point.request_count),
|
|
},
|
|
{
|
|
label: '2xx 请求',
|
|
color: '#22c55e',
|
|
values: points.map((point) => point.status_2xx_count),
|
|
},
|
|
{
|
|
label: '4xx 请求',
|
|
color: '#f97316',
|
|
values: points.map((point) => point.status_4xx_count),
|
|
},
|
|
{
|
|
label: '5xx 请求',
|
|
color: '#ef4444',
|
|
values: points.map((point) => point.status_5xx_count),
|
|
},
|
|
]}
|
|
/>
|
|
</CardContent>
|
|
</Card>
|
|
);
|
|
}
|