SELECT drs.log_send_queue_size as log_send_queue_size,
drs.redo_queue_size as redo_queue_size,
ag.name as group_name,
arcs.replica_server_name as replica_name,
db_name(drs.database_id) as dbname
FROM sys.dm_hadr_database_replica_states drs 
JOIN sys.dm_hadr_availability_replica_cluster_states arcs ON arcs.replica_id = drs.replica_id 
JOIN sys.availability_groups ag ON ag.group_id = arcs.group_id 
JOIN sys.dm_hadr_availability_replica_states ars ON ars.replica_id = arcs.replica_id