mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-08 00:26:37 +08:00
修复节点详情 OpenResty 连接数与吞吐显示为「—」:节点可观测 API 将 OpenResty 观测数据合并进 metric_snapshots;指标文案改为「请求/分钟」(近 60 秒窗口),连接数为 0 时正常显示 0。
This commit is contained in:
@@ -31,6 +31,7 @@ import {
|
||||
aggregateTrafficBreakdown,
|
||||
formatBytes,
|
||||
formatBytesPerSecond,
|
||||
formatMetricCount,
|
||||
formatPercent,
|
||||
formatRelativeTime,
|
||||
formatUptime,
|
||||
@@ -455,11 +456,7 @@ export function NodeObservability({
|
||||
/>
|
||||
<MetricBar
|
||||
label="连接数"
|
||||
value={
|
||||
latestMetric.openresty_connections
|
||||
? String(latestMetric.openresty_connections)
|
||||
: '—'
|
||||
}
|
||||
value={formatMetricCount(latestMetric.openresty_connections)}
|
||||
progress={null}
|
||||
hint={connectionHint}
|
||||
/>
|
||||
@@ -521,11 +518,11 @@ export function NodeObservability({
|
||||
}
|
||||
/>
|
||||
<SummaryStat
|
||||
label="当前窗口请求"
|
||||
value={trafficSummary ? trafficSummary.request_count.toLocaleString('zh-CN') : '—'}
|
||||
label="请求/分钟"
|
||||
value={formatMetricCount(trafficSummary?.request_count)}
|
||||
hint={
|
||||
trafficSummary
|
||||
? `QPS ${trafficSummary.estimated_qps.toFixed(1)} · 错误率 ${trafficSummary.error_rate_percent.toFixed(1)}%`
|
||||
? `近 60 秒 · 错误率 ${trafficSummary.error_rate_percent.toFixed(1)}%`
|
||||
: '当前没有可展示的请求窗口摘要'
|
||||
}
|
||||
/>
|
||||
@@ -594,11 +591,7 @@ export function NodeObservability({
|
||||
/>
|
||||
<MetricBar
|
||||
label="连接数"
|
||||
value={
|
||||
latestMetric.openresty_connections
|
||||
? String(latestMetric.openresty_connections)
|
||||
: '—'
|
||||
}
|
||||
value={formatMetricCount(latestMetric.openresty_connections)}
|
||||
progress={null}
|
||||
hint={connectionHint}
|
||||
/>
|
||||
@@ -661,25 +654,23 @@ export function NodeObservability({
|
||||
<div className="grid gap-3 sm:grid-cols-2">
|
||||
<div className="rounded-lg border px-3 py-3">
|
||||
<p className="text-xs text-muted-foreground uppercase tracking-wide">
|
||||
最近窗口请求
|
||||
请求/分钟
|
||||
</p>
|
||||
<p className="mt-3 text-2xl font-semibold">
|
||||
{trafficSummary
|
||||
? trafficSummary.request_count.toLocaleString('zh-CN')
|
||||
: '—'}
|
||||
{formatMetricCount(trafficSummary?.request_count)}
|
||||
</p>
|
||||
<p className="mt-2 text-sm text-muted-foreground">
|
||||
{trafficSummary
|
||||
? `QPS ${trafficSummary.estimated_qps.toFixed(1)} · UV ${trafficSummary.unique_visitor_count}`
|
||||
? `近 60 秒 · UV ${formatMetricCount(trafficSummary.unique_visitor_count)}`
|
||||
: '暂无窗口流量摘要'}
|
||||
</p>
|
||||
</div>
|
||||
<div className="rounded-lg border px-3 py-3">
|
||||
<p className="text-xs text-muted-foreground uppercase tracking-wide">
|
||||
最近窗口错误
|
||||
近 60 秒错误
|
||||
</p>
|
||||
<p className="mt-3 text-2xl font-semibold">
|
||||
{trafficSummary ? trafficSummary.error_count.toLocaleString('zh-CN') : '—'}
|
||||
{formatMetricCount(trafficSummary?.error_count)}
|
||||
</p>
|
||||
<p className="mt-2 text-sm text-muted-foreground">
|
||||
{trafficSummary
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
import type {
|
||||
ApplyResult,
|
||||
NodeItem,
|
||||
NodeStatus,
|
||||
NodeTrafficReport,
|
||||
OpenrestyStatus,
|
||||
} from '@/lib/services/openflare';
|
||||
import type {ApplyResult, NodeItem, NodeStatus, NodeTrafficReport, OpenrestyStatus,} from '@/lib/services/openflare';
|
||||
|
||||
export const WS_CONNECTED_LAST_SEEN = '__OPENFLARE_WS_CONNECTED__';
|
||||
export const FLARED_WS_CONNECTED_LAST_SEEN = '__OPENFLARE_FLARED_WS_CONNECTED__';
|
||||
@@ -176,6 +170,13 @@ export function formatPercent(value?: number | null) {
|
||||
return `${value.toFixed(1)}%`;
|
||||
}
|
||||
|
||||
export function formatMetricCount(value?: number | null) {
|
||||
if (value === undefined || value === null || !Number.isFinite(value)) {
|
||||
return '—';
|
||||
}
|
||||
return value.toLocaleString('zh-CN');
|
||||
}
|
||||
|
||||
export function formatBytesPerSecond(
|
||||
value?: number | null,
|
||||
windowSeconds = 1,
|
||||
|
||||
Reference in New Issue
Block a user