Library

Guides Quick Fixes Scripts Find a Guide

Tools

Error Decoder Assessment Baselines Free Tools Service status What's Changed

More

AI Certifications For MSPs Recommended Gear Field Kit FAQ About Contact Get Assessment

Keep Microsoft Entra Sign-in and Audit Logs Longer with Log Analytics

EntraReady Guides · Practical Microsoft 365 & Entra ID
Last reviewed:
Last verified against Microsoft Learn:

Microsoft Entra ID keeps audit and sign-in logs for 7 days on Free and 30 days on P1 or P2 (Data retention (opens in a new tab)). Compromises and "who changed this?" questions often surface later than that. A diagnostic setting copies the logs to somewhere you control as they're written; it can't recover what has already expired.

Use it when: you're asked for sign-ins older than 30 days and can't produce them, you're setting up a new tenant, or you want alerting and KQL queries over sign-ins.

Pick a destination

From Integration options (opens in a new tab):

Need Destination
Troubleshooting within 30 days Nothing extra: admin center or Microsoft Graph
Keep logs for compliance, rarely query them Azure storage account
Keep and query regularly, no third-party SIEM Log Analytics workspace (Azure Monitor logs); Microsoft Sentinel can build on it
Third-party SIEM Event hub

This guide covers Log Analytics. Other sources Learn describes: archiving to a storage account, and for some E5-class licenses, Microsoft Purview Audit (Premium) retention for Microsoft Entra audit logs (Data retention note (opens in a new tab)).

Before you start

Step by step

  1. Create the workspace in the Azure portal if you don't have one (Create a Log Analytics workspace (opens in a new tab)). Set its retention to what your policy requires.
  2. In the Microsoft Entra admin center, go to Entra ID > Monitoring & health > Diagnostic settings (or Export Settings from Audit logs or Sign-ins) (Send logs to Azure Monitor (opens in a new tab)).
  3. Select + Add diagnostic setting, give it a name (you can't rename it later), and tick the log categories you need. Learn's integration overview lists audit logs, sign-in logs, provisioning logs, risky users and risk detections as supported (Supported reports (opens in a new tab)); the portal shows the exact category names, including separate sign-in categories, and links to a description of each. Start with audit and the sign-in categories you investigate most, since each category adds ingestion.
  4. Under Destination details, tick Send to Log Analytics workspace, choose the subscription and workspace, and Save.
  5. Wait, then query. Data arrives after a delay; Learn links to Azure Monitor's guidance on time to destination. Events are batched at roughly 5-minute intervals.

Read-only KQL queries

These run in Entra ID > Monitoring & health > Log Analytics (at least Reports Reader; a default query runs and the LogManagement category lists sample queries) (Access Log Analytics (opens in a new tab)). They read data only. There is no Microsoft Graph PowerShell cmdlet for Microsoft Entra diagnostic settings, so this guide uses KQL instead of a Graph script; no Graph scopes apply. Not tested against a live workspace.

Top apps by sign-in count, last 7 days (Query activity logs (opens in a new tab)):

SigninLogs
| where CreatedDateTime >= ago(7d)
| summarize signInCount = count() by AppDisplayName
| sort by signInCount desc

Risky sign-ins:

SigninLogs
| where RiskState contains "atRisk"

Top audit operations, last 7 days:

AuditLogs
| where TimeGenerated >= ago(7d)
| summarize auditCount = count() by OperationName
| sort by auditCount desc

Gotchas

Check it worked

After the setting is saved and some time has passed, SigninLogs | take 10 and AuditLogs | take 10 return recent rows in the workspace.

Roll back

Edit or delete the diagnostic setting in Diagnostic settings. Data already in the workspace stays until the workspace retention removes it (or you delete the workspace).

Related on EntraReady: Investigate a sign-in with the sign-in logs, Export sign-in logs, Export directory audit logs, Find out who changed a user, group, app or policy.

← All Guides

Is this still accurate?

Spotted something outdated or wrong on this page? Tell us in a sentence. The page address is sent with it.

Reports go to the EntraReady inbox. Please don’t include passwords or tenant secrets.