Snippets

Snippet KQL : isoler un 502 Application Gateway vers backend privé

Une requête courte pour distinguer backend indisponible, erreur applicative et blocage WAF quand Application Gateway renvoie des 502 vers un chemin privé.

16 juin 2026 azureapplication-gatewayprivate-endpointwafkqllogsnetworkingrunbookmonitoring

Quand Application Gateway retourne des 502 sur une API privée, commence par corréler le statut client, le statut backend et les éventuels signaux WAF sur la même fenêtre de test.

kusto appgw-private-backend-502.kql
let Window = 2h;
let Host = "api.internal.example.com";
AzureDiagnostics
| where TimeGenerated > ago(Window)
| where ResourceProvider == "MICROSOFT.NETWORK"
| where Category in ("ApplicationGatewayAccessLog", "ApplicationGatewayFirewallLog", "ApplicationGatewayPerformanceLog")
| where host_s has Host or requestUri_s has Host or originalRequestUriWithArgs_s has Host
| project TimeGenerated,
        Category,
        clientIP_s,
        host_s,
        requestUri_s,
        httpStatus_d,
        serverStatus_s,
        backendPoolName_s,
        backendSettingName_s,
        ruleId_s,
        action_s,
        message_s,
        transactionId_g
| order by TimeGenerated desc

Lecture rapide : un httpStatus_d à 502 avec serverStatus_s vide pointe d’abord vers health probe, DNS privé ou routage backend ; un serverStatus_s en 5xx renvoie vers l’application ; une ligne WAF avec Blocked doit être traitée comme un incident de règle, pas comme un problème de pool.