mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-01 14:46:36 +08:00
feat(rate-limits): use 1m buckets and 24h/3d ranges
Allow overview bucket_minutes=1; rate-limit analysis uses 1-minute buckets and replaces 7d preset with 3 days.
This commit is contained in:
@@ -9,8 +9,8 @@ export type SearchDraft = {
|
||||
|
||||
export type OverviewRangeHours = 24 | 168 | 360 | 720;
|
||||
|
||||
/** 限流分析等短窗口场景:仅 24 小时 / 7 天 */
|
||||
export type RateLimitRangeHours = 24 | 168;
|
||||
/** 限流分析等短窗口场景:仅 24 小时 / 3 天 */
|
||||
export type RateLimitRangeHours = 24 | 72;
|
||||
|
||||
export const PAGE_SIZE_OPTIONS = [20, 50, 100, 200];
|
||||
|
||||
@@ -29,7 +29,7 @@ export const RATE_LIMIT_RANGE_OPTIONS: {
|
||||
label: string;
|
||||
}[] = [
|
||||
{ value: 24, label: '24 小时' },
|
||||
{ value: 168, label: '7 天' },
|
||||
{ value: 72, label: '3 天' },
|
||||
];
|
||||
|
||||
export const DETAIL_SORT_OPTIONS = [
|
||||
|
||||
@@ -11,10 +11,10 @@ import { calculateNiceAxisMax, formatCompactNumber } from '@/lib/utils/metrics';
|
||||
|
||||
import {
|
||||
formatOverviewTrendLabel,
|
||||
type OverviewRangeHours,
|
||||
type RateLimitRangeHours,
|
||||
} from '../../access-logs/components/access-log-utils';
|
||||
|
||||
const DEFAULT_BUCKET_SECONDS = 300;
|
||||
const DEFAULT_BUCKET_SECONDS = 60;
|
||||
const RPS_COLOR = '#38bdf8';
|
||||
const VISITS_COLOR = '#a78bfa';
|
||||
|
||||
@@ -54,14 +54,14 @@ function formatRps(value: number) {
|
||||
|
||||
type RatePressureChartProps = {
|
||||
data?: AccessLogOverview;
|
||||
hours: OverviewRangeHours;
|
||||
hours: RateLimitRangeHours;
|
||||
};
|
||||
|
||||
export function RatePressureChart({ data, hours }: RatePressureChartProps) {
|
||||
const bucketSeconds =
|
||||
(data?.bucket_minutes && data.bucket_minutes > 0
|
||||
? data.bucket_minutes
|
||||
: 5) * 60 || DEFAULT_BUCKET_SECONDS;
|
||||
: 1) * 60 || DEFAULT_BUCKET_SECONDS;
|
||||
|
||||
const rangeLabel = useMemo(() => {
|
||||
const end = data?.generated_at ? new Date(data.generated_at) : new Date();
|
||||
|
||||
@@ -31,12 +31,12 @@ function RateLimitsPageContent() {
|
||||
const [hosts, setHosts] = useState<string[]>([]);
|
||||
|
||||
const overviewQuery = useQuery({
|
||||
queryKey: ['openflare', 'rate-limits', 'overview', hours, hosts, 5],
|
||||
queryKey: ['openflare', 'rate-limits', 'overview', hours, hosts, 1],
|
||||
queryFn: () =>
|
||||
AccessLogService.getOverview({
|
||||
hours,
|
||||
hosts: hosts.length > 0 ? hosts : undefined,
|
||||
bucket_minutes: 5,
|
||||
bucket_minutes: 1,
|
||||
}),
|
||||
enabled: !!user?.is_admin && tab === 'analysis',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user