diff --git a/Models/TimerClass.cs b/Models/TimerClass.cs index b96cd19..38dcea7 100644 --- a/Models/TimerClass.cs +++ b/Models/TimerClass.cs @@ -446,12 +446,21 @@ namespace AutoNotificatPhone.Models await using var connection = new NpgsqlConnection(connectionString); 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); object? result = await command.ExecuteScalarAsync(); if (result == null || result == DBNull.Value) { + logger.Error("Kafka入库心跳ts_ms查询结果为空"); ExecuteKafkaDbConnectionAlert(); return; } @@ -464,8 +473,9 @@ namespace AutoNotificatPhone.Models } long nowMs = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - if (nowMs - lastTsMs > TimeSpan.FromMinutes(2).TotalMilliseconds) + if (nowMs - lastTsMs > TimeSpan.FromMinutes(5).TotalMilliseconds) { + logger.Error("Kafka入库心跳超过5分钟未更新"); ExecuteKafkaInactiveAlert(); } } @@ -533,8 +543,8 @@ namespace AutoNotificatPhone.Models private void ExecuteKafkaInactiveAlert() { SendAlert( - smsContent: "[BLV运维提示] BLS数据库1分钟内入库数据为0。", - callContent: "BLV运维提示 BLS数据库1分钟内入库数据为0", + smsContent: "[BLV运维提示] BLS数据库3分钟内入库数据为0。", + callContent: "BLV运维提示 BLS数据库3分钟内入库数据为0", alertType: "BLS-数据库入库警报", extendedDeadline: true );