# Troubleshooting AlwaysOn availability groups

> Collect the SQL Server logs, the AlwaysOn_health files and the WSFC logs (Get-ClusterLog) to troubleshoot an availability group.
>
> Source : https://www.pachadata.com/en/docs/howtos/hadr/troubleshooting/
> Author : Rudi Bruchez · updated 2026-10-14
> Markdown version of the page, for tools and LLMs. The HTML page is the reference.


## Diagnosing the availability groups

1. Collect the SQL Server error logs from the SQL Server log directory.
2. Collect the files of the `AlwaysOn_health` event session: the `alwayson_health*.xel` files, in the same SQL Server log directory.

You can find the SQL Server log directory with this query:

```sql
SELECT
	LEFT(CAST(SERVERPROPERTY('ErrorLogFileName') as nvarchar(max)),
		LEN(CAST(SERVERPROPERTY('ErrorLogFileName') as nvarchar(max))) - LEN('ERRORLOG'));
```

## Diagnosing WSFC

You can export the cluster logs with the `Get-ClusterLog` cmdlet:

```powershell
Import-Module FailoverClusters
Get-ClusterLog -UseLocalTime -Destination C:\temp\
```

Microsoft also provides a tool that collects the cluster diagnostics and logs. You can install it by following [these instructions](https://learn.microsoft.com/azure-stack/hci/manage/collect-diagnostic-data#installing-get-sddcdiagnosticinfo-with-powershell).

```powershell
Install-PackageProvider NuGet -Force
Install-Module PrivateCloud.DiagnosticInfo -Force
Import-Module PrivateCloud.DiagnosticInfo -Force
Install-Module -Name MSFT.Network.Diag
```

Then call the cmdlet to generate the report into a directory:

```powershell
New-Item -Name clusterdiag -Path c:\temp -ItemType Directory -Force
Get-SddcDiagnosticInfo -ClusterName cluster -WriteToPath c:\temp\clusterdiag
```


---

## About the author

Rudi Bruchez, independent SQL Server consultant since 2006: performance audits, tuning, migrations, high availability and training. For an audit or hands-on help on your server: https://www.pachadata.com/en/contact/ (remote audit: https://www.pachadata.com/en/services/remote-sql-server-audit/).
