Search code examples
azure-cdn

Detailed access logs in Azure CDN


Amazon and Google both provide detailed access logs for HTTP requests served by their CDN platforms. As far as I can see there is no such thing in any of Microsoft's CDN solutions (Microsoft, Akamai, Verizon Standard/Premium). There are diagnostic logs and reports for top resources, but I need the individual requests or at least the total number of requests per URL and day.

I have read Azure CDN file download statistics, but it is very old, so something may have changed.

Is it possible to get the access logs we need from a CDN in Azure using a method I have missed, or is this still a dead end?


Solution

  • It can be done now, at least if using "Azure CDN from Microsoft". You need to create a Log Analytics workspace (if you don't have one already), go to Diagnostics settings on your CDN profile (not endpoint) and route the raw logs to that workspace.

    You can also put it in storage, or feed it into an event hub, but I found making reports easiest via log analytics - you can easily create a chart of hit/miss ratio per CDN Point-of-Presence with this:

    AzureDiagnostics
    | where Category == "AzureCdnAccessLog"
    | summarize request_count = count(), totalResponseBytes = sum(toint(responseBytes_s)) by pop_s, cacheStatus_s, sentToOriginShield_b
    | order by request_count desc
    

    Read the whole of that second link - you may need to re-save endpoints not created recently.

    Here's that query used to diagnose that misses from Cape Town (and Johannesburg) were being sent to an origin shield PoP in London before actually being pulled from the origin by the London PoP.

    Query and resulting table showing hit/miss per-POP from the last hour

    Chart of hit/miss per-POP