@Joseph Harris The current method for identifying a lagging replica involves querying the SYS.DM_DATABASE_REPLICA_STATES view. This allows you to pinpoint the replica_id that is experiencing latency. However, linking this replica_id to its corresponding database name directly from the primary replica is not yet possible. This functionality is under development to enhance the monitoring experience. In the meantime, the DATABASEPROPERTYEX() function can be utilized to map the replica_id to its database name by executing it within the context of each named replica.
Below is the example query that can be executed in context of each named replica to identify the lag, replica_id and database name.
SELECT REPLICA_ID, DB_NAME() AS 'DATABASE NAME',SYNCHRONIZATION_STATE_DESC, LOG_SEND_QUEUE_SIZE/1024.0/1024.0 AS LOG_SEND_QUEUE_SIZE_GB,
LAST_SENT_TIME, LAST_RECEIVED_TIME, LAST_COMMIT_TIME, SECONDARY_LAG_SECONDS FROM SYS.DM_DATABASE_REPLICA_STATES
WHERE REPLICA_ID = DATABASEPROPERTYEX(DB_NAME(),'REPLICAID')
Regards
Geetha