fix(platform): avoid fake kafka lag
This commit is contained in:
@@ -32,12 +32,13 @@ func NewMockStore() *MockStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockStore) DashboardSummary(context.Context) (DashboardSummary, error) {
|
func (m *MockStore) DashboardSummary(context.Context) (DashboardSummary, error) {
|
||||||
|
kafkaLag := 0
|
||||||
return DashboardSummary{
|
return DashboardSummary{
|
||||||
OnlineVehicles: 3,
|
OnlineVehicles: 3,
|
||||||
ActiveToday: 4,
|
ActiveToday: 4,
|
||||||
FrameToday: 1286320,
|
FrameToday: 1286320,
|
||||||
IssueVehicles: 7,
|
IssueVehicles: 7,
|
||||||
KafkaLag: 0,
|
KafkaLag: &kafkaLag,
|
||||||
Protocols: []ProtocolStat{
|
Protocols: []ProtocolStat{
|
||||||
{Protocol: "GB32960", Online: 18, Total: 64},
|
{Protocol: "GB32960", Online: 18, Total: 64},
|
||||||
{Protocol: "JT808", Online: 73, Total: 318},
|
{Protocol: "JT808", Online: 73, Total: 318},
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type DashboardSummary struct {
|
|||||||
ActiveToday int `json:"activeToday"`
|
ActiveToday int `json:"activeToday"`
|
||||||
FrameToday int `json:"frameToday"`
|
FrameToday int `json:"frameToday"`
|
||||||
IssueVehicles int `json:"issueVehicles"`
|
IssueVehicles int `json:"issueVehicles"`
|
||||||
KafkaLag int `json:"kafkaLag"`
|
KafkaLag *int `json:"kafkaLag"`
|
||||||
Protocols []ProtocolStat `json:"protocols"`
|
Protocols []ProtocolStat `json:"protocols"`
|
||||||
LinkHealth []LinkHealth `json:"linkHealth"`
|
LinkHealth []LinkHealth `json:"linkHealth"`
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,7 @@ type QualityIssueRow struct {
|
|||||||
|
|
||||||
type OpsHealth struct {
|
type OpsHealth struct {
|
||||||
LinkHealth []LinkHealth `json:"linkHealth"`
|
LinkHealth []LinkHealth `json:"linkHealth"`
|
||||||
KafkaLag int `json:"kafkaLag"`
|
KafkaLag *int `json:"kafkaLag"`
|
||||||
RedisOnlineKeys int `json:"redisOnlineKeys"`
|
RedisOnlineKeys int `json:"redisOnlineKeys"`
|
||||||
TDengineWritable bool `json:"tdengineWritable"`
|
TDengineWritable bool `json:"tdengineWritable"`
|
||||||
MySQLWritable bool `json:"mysqlWritable"`
|
MySQLWritable bool `json:"mysqlWritable"`
|
||||||
|
|||||||
@@ -385,8 +385,8 @@ func (s *ProductionStore) OpsHealth(ctx context.Context) (OpsHealth, error) {
|
|||||||
{Name: "vehicle_realtime_snapshot", Status: "ok", Detail: "读取实时快照表"},
|
{Name: "vehicle_realtime_snapshot", Status: "ok", Detail: "读取实时快照表"},
|
||||||
{Name: "vehicle_realtime_location", Status: "ok", Detail: "读取实时位置表"},
|
{Name: "vehicle_realtime_location", Status: "ok", Detail: "读取实时位置表"},
|
||||||
{Name: "TDengine raw_frames", Status: tdengineStatus(s.tdengine), Detail: tdengineDetail(s.tdengine)},
|
{Name: "TDengine raw_frames", Status: tdengineStatus(s.tdengine), Detail: tdengineDetail(s.tdengine)},
|
||||||
|
{Name: "Kafka lag", Status: "warning", Detail: "平台暂未接入 Kafka consumer lag 监控"},
|
||||||
},
|
},
|
||||||
KafkaLag: 0,
|
|
||||||
RedisOnlineKeys: redisKeys,
|
RedisOnlineKeys: redisKeys,
|
||||||
TDengineWritable: s.tdengine != nil,
|
TDengineWritable: s.tdengine != nil,
|
||||||
MySQLWritable: mysqlStatus == "ok",
|
MySQLWritable: mysqlStatus == "ok",
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export interface DashboardSummary {
|
|||||||
activeToday: number;
|
activeToday: number;
|
||||||
frameToday: number;
|
frameToday: number;
|
||||||
issueVehicles: number;
|
issueVehicles: number;
|
||||||
kafkaLag: number;
|
kafkaLag: number | null;
|
||||||
protocols: ProtocolStat[];
|
protocols: ProtocolStat[];
|
||||||
linkHealth: LinkHealth[];
|
linkHealth: LinkHealth[];
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ export interface QualityIssueRow {
|
|||||||
|
|
||||||
export interface OpsHealth {
|
export interface OpsHealth {
|
||||||
linkHealth: LinkHealth[];
|
linkHealth: LinkHealth[];
|
||||||
kafkaLag: number;
|
kafkaLag: number | null;
|
||||||
redisOnlineKeys: number;
|
redisOnlineKeys: number;
|
||||||
tdengineWritable: boolean;
|
tdengineWritable: boolean;
|
||||||
mysqlWritable: boolean;
|
mysqlWritable: boolean;
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ const statusColor: Record<string, 'green' | 'orange' | 'red' | 'grey'> = {
|
|||||||
error: 'red'
|
error: 'red'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function formatLag(value?: number | null) {
|
||||||
|
return value == null ? '未接入' : value.toLocaleString();
|
||||||
|
}
|
||||||
|
|
||||||
export function Dashboard({ onOpenVehicle }: { onOpenVehicle: (vin: string) => void }) {
|
export function Dashboard({ onOpenVehicle }: { onOpenVehicle: (vin: string) => void }) {
|
||||||
const [summary, setSummary] = useState<DashboardSummary | null>(null);
|
const [summary, setSummary] = useState<DashboardSummary | null>(null);
|
||||||
const [vehicles, setVehicles] = useState<VehicleRow[]>([]);
|
const [vehicles, setVehicles] = useState<VehicleRow[]>([]);
|
||||||
@@ -104,7 +108,7 @@ export function Dashboard({ onOpenVehicle }: { onOpenVehicle: (vin: string) => v
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Card title="实时积压" bordered style={{ marginTop: 16 }}>
|
<Card title="实时积压" bordered style={{ marginTop: 16 }}>
|
||||||
<Typography.Text>Kafka 当前消费积压:{summary?.kafkaLag ?? 0}</Typography.Text>
|
<Typography.Text>Kafka 当前消费积压:{formatLag(summary?.kafkaLag)}</Typography.Text>
|
||||||
</Card>
|
</Card>
|
||||||
<Card title="车辆服务覆盖" bordered style={{ marginTop: 16 }}>
|
<Card title="车辆服务覆盖" bordered style={{ marginTop: 16 }}>
|
||||||
<Form layout="horizontal" onSubmit={(values) => loadCoverage(values as Record<string, string>)} style={{ marginBottom: 12 }}>
|
<Form layout="horizontal" onSubmit={(values) => loadCoverage(values as Record<string, string>)} style={{ marginBottom: 12 }}>
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import { api } from '../api/client';
|
|||||||
import type { OpsHealth, QualityIssueRow } from '../api/types';
|
import type { OpsHealth, QualityIssueRow } from '../api/types';
|
||||||
import { PageHeader } from '../components/PageHeader';
|
import { PageHeader } from '../components/PageHeader';
|
||||||
|
|
||||||
|
function formatLag(value?: number | null) {
|
||||||
|
return value == null ? '未接入' : value.toLocaleString();
|
||||||
|
}
|
||||||
|
|
||||||
export function Quality() {
|
export function Quality() {
|
||||||
const [issues, setIssues] = useState<QualityIssueRow[]>([]);
|
const [issues, setIssues] = useState<QualityIssueRow[]>([]);
|
||||||
const [health, setHealth] = useState<OpsHealth | null>(null);
|
const [health, setHealth] = useState<OpsHealth | null>(null);
|
||||||
@@ -36,7 +40,7 @@ export function Quality() {
|
|||||||
<div className="vp-page">
|
<div className="vp-page">
|
||||||
<PageHeader title="数据质量" description="断链、VIN 缺失、字段缺失和链路健康的排查入口" />
|
<PageHeader title="数据质量" description="断链、VIN 缺失、字段缺失和链路健康的排查入口" />
|
||||||
<Row gutter={16}>
|
<Row gutter={16}>
|
||||||
<Col span={8}><Card bordered title="Kafka Lag">{health?.kafkaLag ?? 0}</Card></Col>
|
<Col span={8}><Card bordered title="Kafka Lag">{formatLag(health?.kafkaLag)}</Card></Col>
|
||||||
<Col span={8}><Card bordered title="Redis 在线 Key">{health?.redisOnlineKeys ?? 0}</Card></Col>
|
<Col span={8}><Card bordered title="Redis 在线 Key">{health?.redisOnlineKeys ?? 0}</Card></Col>
|
||||||
<Col span={8}><Card bordered title="存储写入">{health?.tdengineWritable && health.mysqlWritable ? '正常' : '异常'}</Card></Col>
|
<Col span={8}><Card bordered title="存储写入">{health?.tdengineWritable && health.mysqlWritable ? '正常' : '异常'}</Card></Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|||||||
Reference in New Issue
Block a user