info@techdevops.com | 437-991-3573 | Data Engineering Services
TechDevOps.com
Resources Tools
Experts in Microsoft SQL Server on Windows, Linux, Containers | Clusters, Always On, FCI | Migrations, Cloud, Performance



Check Always On Availability Groups Health
by BF (Principal Consultant; Architecture; Engineering)
2023-11-04







Check Always On Availability Groups Health


Select
n.group_name as 'AG_Group_Name',
n.Replica_Server_Name,
db_name(drs.database_id) as 'DB_Name',
rs.Role_Desc,
Connected_State_Desc,
drs.Synchronization_State_Desc,
drs.Synchronization_Health_Desc,
drs.Log_Send_Queue_Size,
drs.Log_Send_Rate,
drs.Redo_Queue_Size,
drs.Redo_Rate,
drs.Secondary_Lag_Seconds,
drs.Last_Commit_Time,
GetDate() As 'Data_Collection_Time'
from sys.dm_hadr_availability_replica_cluster_nodes n
join sys.dm_hadr_availability_replica_cluster_states cs on n.replica_server_name = cs.replica_server_name
join sys.dm_hadr_availability_replica_states rs on rs.replica_id = cs.replica_id
join sys.dm_hadr_database_replica_states drs on rs.replica_id=drs.replica_id
Order By Replica_Server_Name Asc