修改判断逻辑,从1分钟判断改成3分钟。并且判断规则从产生数据时间改为入库时间

This commit is contained in:
2026-02-11 10:01:03 +08:00
parent aa835bbe47
commit ccf4473a57

View File

@@ -446,12 +446,21 @@ namespace AutoNotificatPhone.Models
await using var connection = new NpgsqlConnection(connectionString); await using var connection = new NpgsqlConnection(connectionString);
await connection.OpenAsync(); await connection.OpenAsync();
const string sql = "select ts_ms from heartbeat.heartbeat_events order by ts_ms desc limit 1"; const string sql = @"SELECT write_ts_ms
FROM (
SELECT write_ts_ms
FROM heartbeat.heartbeat_events
ORDER BY ts_ms DESC
LIMIT 3000
) AS recent_events
ORDER BY write_ts_ms DESC
LIMIT 1;";
await using var command = new NpgsqlCommand(sql, connection); await using var command = new NpgsqlCommand(sql, connection);
object? result = await command.ExecuteScalarAsync(); object? result = await command.ExecuteScalarAsync();
if (result == null || result == DBNull.Value) if (result == null || result == DBNull.Value)
{ {
logger.Error("Kafka入库心跳ts_ms查询结果为空");
ExecuteKafkaDbConnectionAlert(); ExecuteKafkaDbConnectionAlert();
return; return;
} }
@@ -464,8 +473,9 @@ namespace AutoNotificatPhone.Models
} }
long nowMs = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); long nowMs = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
if (nowMs - lastTsMs > TimeSpan.FromMinutes(2).TotalMilliseconds) if (nowMs - lastTsMs > TimeSpan.FromMinutes(5).TotalMilliseconds)
{ {
logger.Error("Kafka入库心跳超过5分钟未更新");
ExecuteKafkaInactiveAlert(); ExecuteKafkaInactiveAlert();
} }
} }
@@ -533,8 +543,8 @@ namespace AutoNotificatPhone.Models
private void ExecuteKafkaInactiveAlert() private void ExecuteKafkaInactiveAlert()
{ {
SendAlert( SendAlert(
smsContent: "[BLV运维提示] BLS数据库1分钟内入库数据为0。", smsContent: "[BLV运维提示] BLS数据库3分钟内入库数据为0。",
callContent: "BLV运维提示 BLS数据库1分钟内入库数据为0", callContent: "BLV运维提示 BLS数据库3分钟内入库数据为0",
alertType: "BLS-数据库入库警报", alertType: "BLS-数据库入库警报",
extendedDeadline: true extendedDeadline: true
); );