root@labsdb1012.eqiad.wmnet[heartbeat]> SELECT shard, greatest(0, TIMESTAMPDIFF(MICROSECOND, max(ts), UTC_TIMESTAMP(6)) - 500000)/1000000 AS lag FROM heartbeat.heartbeat WHERE datacenter='eqiad' GROUP BY shard HAVING shard like 's%' -> ; +-------+--------+ | shard | lag | +-------+--------+ | s1 | 0.0000 | | s2 | 0.0000 | | s3 | 0.0000 | | s4 | 0.0000 | | s5 | 0.0000 | | s6 | 0.0000 | | s7 | 0.0000 | | s8 | 0.0000 | +-------+--------+ 8 rows in set (0.001 sec) root@labsdb1012.eqiad.wmnet[heartbeat]> SELECT shard, greatest(0, TIMESTAMPDIFF(MICROSECOND, max(ts), UTC_TIMESTAMP(6)) - 500000)/1000000 AS lag FROM heartbeat.heartbeat WHERE datacenter='codfw' GROUP BY shard HAVING shard like 's%' -> ; +-------+-------------+ | shard | lag | +-------+-------------+ | s1 | 277237.2624 | | s2 | 0.2624 | | s3 | 7.2623 | | s4 | 0.2623 | | s5 | 0.2624 | | s6 | 0.2624 | | s7 | 0.2622 | | s8 | 278333.2622 | +-------+-------------+ 8 rows in set (0.001 sec)