Microsoft Graph Activity Logs

Earn 25 points (50 with Pro) in two steps

  1. ① Read through the lesson — each section gets a ✓ as you scroll through it.
  2. ② When every section has a ✓, tap Complete lesson.

0 of 11 read · keep scrolling

✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro

Monitoring and Maintaining Microsoft Entra ID: Microsoft Graph Activity Logs

Introduction: The Critical Role of Visibility in Identity Governance

In the modern digital workplace, identity is the new perimeter. Organizations no longer rely solely on firewalls and network segmentation to protect their resources; instead, they rely on robust identity providers like Microsoft Entra ID (formerly Azure Active Directory). As you manage these identities, you are essentially managing the keys to your organization's kingdom. However, having the keys is only half the battle. You must also know exactly who is using those keys, when they are using them, and whether those actions align with your security policies. This is where Microsoft Graph Activity Logs come into play.

Microsoft Graph is the unified API endpoint for accessing data across the Microsoft 365 ecosystem. Because so many administrative tasks, application integrations, and automated workflows interact with your environment through this API, the activity logs generated by Microsoft Graph are arguably the most important audit trail you possess. These logs capture the "who, what, and when" of every programmatic interaction with your directory. Without this visibility, you are essentially flying blind, unable to detect unauthorized configuration changes, suspicious application behavior, or potential data exfiltration attempts.

This lesson explores how to effectively monitor and maintain your Microsoft Entra ID environment by leveraging Microsoft Graph Activity Logs. We will move beyond the basic concepts and dive into the mechanics of log collection, analysis, and alerting. By the end of this guide, you will understand how to transform raw, noisy log data into actionable security intelligence, ensuring that your identity governance strategy is not just a document on a shelf, but a living, breathing component of your security posture.


Not read yet

Understanding Microsoft Graph Activity Logs

At its core, a Microsoft Graph activity log is a detailed record of a request made to the Microsoft Graph API. When an application, a script, or an administrator uses a tool that talks to Microsoft Graph, the service records specific details about that transaction. This includes the identity that performed the action, the specific API endpoint called, the user agent string of the client, the response status code, and the timestamp.

Why Are These Logs Different from Standard Audit Logs?

While Microsoft Entra ID provides standard audit logs for user sign-ins and directory changes, Microsoft Graph Activity Logs provide a granular look at the API layer. Many administrative actions performed in the Entra admin center or via PowerShell are actually just wrappers for underlying Graph API calls. By monitoring the Graph logs, you gain visibility into the "behind-the-scenes" activity that might not be explicitly detailed in standard UI-based audit logs.

Callout: Audit Logs vs. Graph Activity Logs Audit logs are generally focused on business-level changes (e.g., "User X was added to Group Y"). Graph activity logs are focused on the technical execution of those changes (e.g., "Application Z performed a PATCH request on the /groups/{id}/members endpoint"). Audit logs tell you the outcome; Graph logs tell you the method and the actor's technical footprint.

Key Components of an Activity Log Entry

To effectively monitor these logs, you must understand the structure of the data. Every log entry contains specific fields that are vital for forensic analysis:

  • Correlation ID: A unique identifier that allows you to track a request across multiple services or log sources.
  • Request ID: The specific ID assigned to the individual API call.
  • Actor/Identity: The service principal or user account that initiated the call.
  • Request Path: The exact API endpoint accessed (e.g., /v1.0/users/{id}/memberOf).
  • HTTP Method: The action performed (GET, POST, PATCH, DELETE, etc.).
  • Status Code: The result of the request (e.g., 200 OK, 403 Forbidden, 401 Unauthorized).
  • User Agent: The tool or library used to make the call, which is essential for identifying unauthorized scripts or compromised automation tools.

Not read yet

Setting Up Log Streaming to Azure Monitor

Microsoft Entra ID does not keep activity logs indefinitely in the portal. To maintain a long-term audit trail and perform deep analysis, you must stream these logs to a destination that supports advanced querying, such as a Log Analytics Workspace in Azure Monitor.

Step-by-Step Configuration

  1. Create a Log Analytics Workspace: Navigate to the Azure portal, search for "Log Analytics workspaces," and create a new instance. Choose a region that complies with your data residency requirements.
  2. Configure Diagnostic Settings: Within the Microsoft Entra ID blade, navigate to the "Monitoring" section and select "Diagnostic settings."
  3. Add a New Setting: Click "Add diagnostic setting." Give it a descriptive name like Stream-Graph-Logs.
  4. Select Log Categories: Ensure that AuditLogs and SignInLogs are selected. Note that specific Graph activity logging might be bundled within these categories or require specific licensing (like Microsoft Entra ID P1 or P2).
  5. Set the Destination: Select "Send to Log Analytics workspace" and choose the workspace you created in step 1.
  6. Save and Verify: Click Save. It may take up to 15 minutes for the first logs to appear in your workspace.

Tip: Always enable "Resource specific" destination tables in your Diagnostic Settings. This allows you to query the logs using the exact schema provided by Microsoft, which makes writing Kusto Query Language (KQL) queries much simpler and more consistent.


Not read yet

Analyzing Logs with Kusto Query Language (KQL)

Once your logs are flowing into Log Analytics, the real work begins. KQL is the engine room of log analysis. It is a powerful, read-only query language that allows you to filter, aggregate, and visualize your data.

Example 1: Identifying Unauthorized API Access Attempts

If an application or user tries to access resources they don't have permissions for, they will generate a 403 Forbidden error. You can track these to identify potential reconnaissance or misconfigured applications.

AuditLogs
| where Result == "failure"
| where ResultReason contains "Forbidden" or ResultReason contains "Unauthorized"
| project TimeGenerated, InitiatedBy, OperationName, ResultReason, TargetResources
| sort by TimeGenerated desc

Example 2: Tracking Administrative Actions via Graph API

If you suspect an administrator is making bulk changes using a script, you can filter for specific high-privilege operations.

AuditLogs
| where OperationName has_any ("Add member to group", "Update user", "Delete user")
| extend Actor = InitiatedBy.app.displayName
| summarize count() by Actor, OperationName
| render barchart

Example 3: Analyzing User-Agent Strings for Anomalies

Sometimes, an attacker might use a custom script that identifies itself with a suspicious User-Agent string. Monitoring these can help you flag non-standard tools being used against your environment.

SignInLogs
| summarize count() by UserAgent
| where count_ > 100
| sort by count_ desc

Not read yet

Best Practices for Monitoring and Maintenance

Effective identity governance requires a proactive approach. Simply collecting logs is not enough; you must maintain them and act on the information they provide.

1. Retention Policies

Do not store logs forever in a "hot" tier. Configure your Log Analytics workspace to move logs to an "Archive" tier after 30 or 90 days. This significantly reduces costs while keeping the data accessible for compliance audits.

2. Alerting on High-Risk Events

Do not wait for a security incident to look at the logs. Create alert rules in Azure Monitor that trigger emails or automated workflows (via Logic Apps) when specific thresholds are met. For example, alert immediately if a "Global Administrator" role is assigned to a new user.

3. Reviewing Service Principal Activity

Service principals are often the most overlooked identity type. They can be created, granted permissions, and forgotten. Regularly audit the logs for any service principal that has not been active in the last 90 days and consider disabling it.

4. Regular Security Reviews

Schedule a monthly review of the "top 10" most active applications in your environment. If an application is performing an unexpectedly high number of API calls, investigate whether it is a sign of a bug in your code or a potential security compromise.


Not read yet

Common Pitfalls and How to Avoid Them

Even with the best tools, it is easy to fall into traps that undermine your monitoring efforts.

Pitfall 1: "Log Blindness" from Too Much Data

If you enable logging for every single minor event, your logs will become noisy and expensive. Avoid this by filtering out low-value events at the Diagnostic Setting level if possible, or by creating specific saved searches that focus only on critical administrative actions.

Pitfall 2: Relying Solely on the Portal

The Entra portal is great for ad-hoc investigations, but it is not a long-term monitoring solution. Always use Log Analytics or a dedicated SIEM (like Microsoft Sentinel) to aggregate, correlate, and visualize your data.

Pitfall 3: Ignoring Service Principal Secrets

Often, logs show an application acting suspiciously, but the culprit is a leaked client secret. Always rotate your service principal secrets on a regular cadence, and use Managed Identities whenever possible to eliminate the need for secrets entirely.

Warning: Never hard-code client secrets or service principal credentials in your scripts or source code. If these are committed to a public or even private repository, they are effectively compromised. Always use Azure Key Vault to store and retrieve these credentials at runtime.


Not read yet

Comparison Table: Monitoring Tools and Capabilities

Tool Capability Best For
Entra Portal Real-time view, basic filters Ad-hoc, quick troubleshooting
Log Analytics KQL querying, long-term storage Deep forensic analysis, dashboards
Microsoft Sentinel SIEM/SOAR integration, AI-driven alerts Large-scale security operations
PowerShell (MgGraph) Automated log extraction Periodic reporting, compliance audits

Implementing Automated Remediation (The Next Level)

Monitoring is only half of the governance equation. The other half is remediation. When your logs indicate a potential security risk—for example, a user account suddenly making hundreds of Graph API calls—you can automate a response.

Using Logic Apps for Automated Response

  1. Create a Trigger: In Azure Logic Apps, select the "When a Log Analytics query returns results" trigger.
  2. Define the Query: Use a KQL query that detects the suspicious behavior (e.g., unauthorized API calls).
  3. Define the Action: Configure the Logic App to disable the compromised account or revoke its active sessions using the Microsoft Graph connector.
  4. Notify: Send an alert to your security operations team via Microsoft Teams or email with the details of the incident.

This approach moves your organization from "passive monitoring" to "active defense." It allows you to contain threats in seconds rather than hours, which is critical when dealing with identity-based attacks.


Not read yet

Detailed Walkthrough: Auditing "High-Privilege" App Usage

Let’s look at a common scenario: auditing applications that have Directory.ReadWrite.All or User.ReadWrite.All permissions. These are high-value targets for attackers.

Step 1: Querying for App Permissions

You can use the following KQL to see which applications have been granted sensitive scopes in your tenant.

ServicePrincipals
| mv-expand AppRoleAssignments
| where AppRoleAssignments.resourceDisplayName == "Microsoft Graph"
| project AppDisplayName, AppRoleAssignments.claimValue
| where AppRoleAssignments.claimValue in ("Directory.ReadWrite.All", "User.ReadWrite.All", "AppRoleAssignment.ReadWrite.All")

Step 2: Correlating Permissions with Activity

Once you have the list of "high-privilege" applications, check their actual activity logs to see if they are exercising those permissions.

AuditLogs
| where InitiatedBy.app.displayName in ("App-Name-1", "App-Name-2")
| project TimeGenerated, OperationName, Result, TargetResources
| order by TimeGenerated desc

If you see an application with "ReadWrite" permissions that only ever performs "Read" operations, you should consider reducing its scope. This follows the Principle of Least Privilege, a fundamental pillar of identity governance.


Not read yet

Frequently Asked Questions (FAQ)

Q: How much does it cost to stream these logs? A: Costs are based on the volume of data ingested into your Log Analytics workspace and the retention period you choose. To control costs, be selective about which logs you stream and use the "Basic" log ingestion tier for logs that don't require high-performance querying.

Q: Can I stream logs to a third-party SIEM like Splunk? A: Yes. You can use Azure Event Hubs as an intermediary. Stream your Entra logs to an Event Hub, and then configure your third-party SIEM to consume data from that Event Hub.

Q: How often should I review my logs? A: Critical alerts should be reviewed in real-time. A general "health check" of administrative activity should be performed at least weekly, while a comprehensive compliance audit should occur quarterly.

Q: What if I don't see any logs for a specific application? A: Ensure the application is actually making calls to the Microsoft Graph API. If it is using legacy APIs or direct connections to other services, it will not appear in the Microsoft Graph Activity Logs.


Not read yet

Best Practices Checklist for Identity Governance

  1. Standardize Logging: Ensure all production tenants have Diagnostic Settings configured to send logs to a central Log Analytics workspace.
  2. Use Managed Identities: Shift away from client secrets; use Managed Identities for all Azure-hosted applications.
  3. Establish Baseline Activity: Understand what "normal" looks like. If you don't know the typical daily API volume for your apps, you can't detect an anomaly.
  4. Automate Alerts: If a human has to manually check the logs to find a breach, you are already too late. Use automated alerting for high-risk operations.
  5. Review Permissions Regularly: Conduct a "permission pruning" exercise every six months to remove unused or overly permissive app registrations.
  6. Secure the Log Store: Ensure that access to your Log Analytics workspace is restricted using Role-Based Access Control (RBAC). Only security administrators should have access to read these logs.
  7. Document Everything: Maintain a simple registry of what each service principal does and why it needs the permissions it has.

Not read yet

Key Takeaways

As we conclude this lesson on Microsoft Graph Activity Logs, keep these essential principles in mind:

  • Visibility is Foundation: You cannot govern what you cannot see. Microsoft Graph Activity Logs are the primary source of truth for programmatic identity interactions.
  • Context is King: A log entry by itself is just data. By correlating it with User-Agent strings, IP addresses, and operational context, you turn that data into security intelligence.
  • Proactive over Reactive: Relying on manual portal checks is a recipe for failure. Build automated pipelines that stream, analyze, and alert based on the data in your logs.
  • Principle of Least Privilege: Use the logs to identify apps that have excessive permissions and aggressively prune those scopes to minimize your attack surface.
  • Lifecycle Management: Identity governance is not a one-time project. It is a continuous cycle of monitoring, analyzing, remediating, and reviewing that must be maintained as your organization evolves.
  • Tooling Integration: Leverage the power of KQL and Azure Monitor to scale your monitoring efforts. Do not try to manage logs at scale using manual methods.
  • Automated Response: The ultimate goal of identity governance is to reach a state where your environment can defend itself against common threats through automated workflows triggered by log analysis.

By mastering these concepts, you transition from being a simple administrator to an identity architect, capable of securing your environment against the increasingly sophisticated threats facing modern organizations. Take the time to implement these practices in a test environment, experiment with KQL, and build the alerts that matter most to your specific business requirements. The effort you invest in monitoring today will prevent catastrophic security failures tomorrow.

Not read yet

Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.