fix(platform): avoid fake redis online keys

This commit is contained in:
lingniu
2026-07-03 22:41:25 +08:00
parent 91c2168cb0
commit 2c24d4734c
5 changed files with 6 additions and 7 deletions

View File

@@ -178,10 +178,11 @@ func (m *MockStore) QualityIssues(_ context.Context, query url.Values) (Page[Qua
func (m *MockStore) OpsHealth(context.Context) (OpsHealth, error) { func (m *MockStore) OpsHealth(context.Context) (OpsHealth, error) {
summary, _ := m.DashboardSummary(context.Background()) summary, _ := m.DashboardSummary(context.Background())
redisOnlineKeys := 92
return OpsHealth{ return OpsHealth{
LinkHealth: summary.LinkHealth, LinkHealth: summary.LinkHealth,
KafkaLag: summary.KafkaLag, KafkaLag: summary.KafkaLag,
RedisOnlineKeys: 92, RedisOnlineKeys: &redisOnlineKeys,
TDengineWritable: true, TDengineWritable: true,
MySQLWritable: true, MySQLWritable: true,
}, nil }, nil

View File

@@ -135,7 +135,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"`
} }

View File

@@ -377,8 +377,6 @@ func (s *ProductionStore) OpsHealth(ctx context.Context) (OpsHealth, error) {
mysqlStatus = "error" mysqlStatus = "error"
mysqlDetail = err.Error() mysqlDetail = err.Error()
} }
var redisKeys int
_ = s.db.QueryRowContext(ctx, `SELECT COUNT(*) FROM vehicle_realtime_snapshot WHERE updated_at >= DATE_SUB(NOW(), INTERVAL 1 MINUTE)`).Scan(&redisKeys)
return OpsHealth{ return OpsHealth{
LinkHealth: []LinkHealth{ LinkHealth: []LinkHealth{
{Name: "MySQL realtime", Status: mysqlStatus, Detail: mysqlDetail}, {Name: "MySQL realtime", Status: mysqlStatus, Detail: mysqlDetail},
@@ -386,8 +384,8 @@ func (s *ProductionStore) OpsHealth(ctx context.Context) (OpsHealth, error) {
{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 监控"}, {Name: "Kafka lag", Status: "warning", Detail: "平台暂未接入 Kafka consumer lag 监控"},
{Name: "Redis online keys", Status: "warning", Detail: "平台暂未接入 Redis 在线 key 读取"},
}, },
RedisOnlineKeys: redisKeys,
TDengineWritable: s.tdengine != nil, TDengineWritable: s.tdengine != nil,
MySQLWritable: mysqlStatus == "ok", MySQLWritable: mysqlStatus == "ok",
}, nil }, nil

View File

@@ -125,7 +125,7 @@ export interface QualityIssueRow {
export interface OpsHealth { export interface OpsHealth {
linkHealth: LinkHealth[]; linkHealth: LinkHealth[];
kafkaLag: number | null; kafkaLag: number | null;
redisOnlineKeys: number; redisOnlineKeys: number | null;
tdengineWritable: boolean; tdengineWritable: boolean;
mysqlWritable: boolean; mysqlWritable: boolean;
} }

View File

@@ -41,7 +41,7 @@ export function Quality() {
<PageHeader title="数据质量" description="断链、VIN 缺失、字段缺失和链路健康的排查入口" /> <PageHeader title="数据质量" description="断链、VIN 缺失、字段缺失和链路健康的排查入口" />
<Row gutter={16}> <Row gutter={16}>
<Col span={8}><Card bordered title="Kafka Lag">{formatLag(health?.kafkaLag)}</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">{formatLag(health?.redisOnlineKeys)}</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>
<Card bordered title="质量问题" style={{ marginTop: 16 }}> <Card bordered title="质量问题" style={{ marginTop: 16 }}>