Replication lag measured with a heartbeat, not Seconds_Behind

Seconds_Behind_Source is derived from the timestamp of the event being applied, so an idle source reports zero lag on a replica that is minutes behind.

-- on the source, every second
REPLACE INTO heartbeat (id, ts) VALUES (1, NOW(6));

-- on the replica: wall-clock staleness, which cannot lie
SELECT TIMESTAMPDIFF(MICROSECOND, ts, NOW(6)) / 1000 AS lag_ms
FROM heartbeat WHERE id = 1;

-- and it also survives a broken IO thread, where
-- Seconds_Behind_Source reports NULL

The failure that matters is a stalled replica during a quiet period: no new events means no new timestamps, so the built-in metric reads zero right up until traffic resumes and it jumps to several minutes. The heartbeat measures the thing you actually care about, which is how stale a read from this replica can be. Clock skew between the two servers is the one caveat, and it is a good reason to have NTP monitored as well.