Forum Discussion
Matty1231
Feb 23, 2024Copper Contributor
KQL for checking for checking "Could not find any Session Hosts available"
Hi,
Is there a KQL that can be used to check for connection errors based on there not being enough session hosts available in a specific host pool?
This can checked through AVD Insights under Connection Diagnostics, however I'd like to get this into KQL so an email alert could potentially created for auto scaling not kicking in quick enough or for an influx of user connections to a specific host pool.
Thanks.
- tommykneetzIron Contributor
I used this in an alert rule
// Active sessions on SessionHost
// Display a graph of active sessions.
let GranularityInterval = 30m; // Time resolution for query results (min value is 30s).
WVDAgentHealthStatus // Fires every ~30s
// Ensure only one data point is provided per host in the pool
| summarize PeakSessionsByHost=max(toint(ActiveSessions)) by SessionHostName, bin(TimeGenerated, 30s), _ResourceId
// Sum up the values for all of the hosts in each pool
| summarize SessionsByHostPool=sum(PeakSessionsByHost) by TimeGenerated, _ResourceId
// Reduce time resolution to desired GranularityInterval and report the peak session count for each pool in that time window
| summarize max(SessionsByHostPool) by bin(TimeGenerated, GranularityInterval), _ResourceId
| render timechart