Skip to content

Commit 0bebc5b

Browse files
authored
Merge pull request #102142 from msaburnley/aj-elm-loganalytics
[Azure AD] [ELM] Archiving logs and reporting
2 parents c75153d + 46f60f0 commit 0bebc5b

File tree

8 files changed

+163
-0
lines changed

8 files changed

+163
-0
lines changed

articles/active-directory/governance/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
href: entitlement-management-external-users.md
4949
- name: View reports and logs
5050
href: entitlement-management-reports.md
51+
- name: Archive logs and reporting
52+
href: entitlement-management-logs-and-reporting.md
5153
- name: Troubleshoot
5254
href: entitlement-management-troubleshoot.md
5355
- name: Catalog owners
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
---
2+
title: Archive & report with Azure Monitor - Azure AD entitlement management
3+
description: Learn how to archive logs and create reports with Azure Monitor in Azure Active Directory entitlement management.
4+
services: active-directory
5+
documentationCenter: ''
6+
author: msaburnley
7+
manager: daveba
8+
editor:
9+
ms.service: active-directory
10+
ms.workload: identity
11+
ms.tgt_pltfrm: na
12+
ms.devlang: na
13+
ms.topic: conceptual
14+
ms.subservice: compliance
15+
ms.date: 02/27/2020
16+
ms.author: ajburnle
17+
ms.reviewer:
18+
ms.collection: M365-identity-device-management
19+
20+
21+
#Customer intent: As an administrator, I want to extend data retention in entitlement management past the default period by using Azure Monitor.
22+
23+
---
24+
# Archive logs and reporting on Azure AD entitlement management in Azure Monitor
25+
26+
Azure AD stores audit events for up to 30 days in the audit log. However, you can keep the audit data for longer than the default retention period, outlined in [How long does Azure AD store reporting data?](../reports-monitoring/reference-reports-data-retention.md), by routing it to an Azure Storage account or using Azure Monitor. You can then use workbooks and custom queries and reports on this data.
27+
28+
29+
## Configure Azure AD to use Azure Monitor
30+
Before using the Azure Monitor workbooks, you must configure Azure AD to send a copy of its audit logs to Azure Monitor.
31+
32+
Archiving Azure AD audit logs requires you to have Azure Monitor in an Azure subscription. You can read more about the prerequisites and estimated costs of using Azure Monitor in [Azure AD activity logs in Azure Monitor](../reports-monitoring/concept-activity-logs-azure-monitor.md).
33+
34+
**Prerequisite role**: Global Admin
35+
36+
1. Sign in to the Azure portal as a user who is a Global Admin. Make sure you have access to the resource group containing the Azure Monitor workspace.
37+
38+
1. Select **Azure Active Directory** then click **Diagnostic settings** under Monitoring in the left navigation menu. Check if there's already a setting to send the audit logs to that workspace.
39+
40+
1. If there isn't already a setting, click **Add diagnostic setting**. Use the instructions in the article [Integrate Azure AD logs with Azure Monitor logs](../reports-monitoring/howto-integrate-activity-logs-with-log-analytics.md#send-logs-to-azure-monitor)
41+
to send the Azure AD audit log to the Azure Monitor workspace.
42+
43+
![Diagnostics settings pane](./media/entitlement-management-logs-and-reporting/audit-log-diagnostics-settings.png)
44+
45+
46+
1. After the log is sent to Azure Monitor, select **Log Analytics workspaces**, and select the workspace that contains the Azure AD audit logs.
47+
48+
1. Select **Usage and estimated costs** and click **Data Retention**. Change the slider to the number of days you want to keep the data to meet your auditing requirements.
49+
50+
![Log Analytics workspaces pane](./media/entitlement-management-logs-and-reporting/log-analytics-workspaces.png)
51+
52+
## Create custom Azure Monitor queries using the Azure portal
53+
You can create your own queries on Azure AD audit events, including entitlement management events.
54+
55+
1. In Azure Active Directory of the Azure portal, click **Logs** under the Monitoring section in the left navigation menu to create a new query page.
56+
57+
1. Your workspace should be shown in the upper left of the query page. If you have multiple Azure Monitor workspaces, and the workspace you're using to store Azure AD audit events isn't shown, click **Select Scope**. Then, select the correct subscription and workspace.
58+
59+
1. Next, in the query text area, delete the string “search *” and replace it with the following query:
60+
61+
```
62+
AuditLogs | where Category == "EntitlementManagement"
63+
```
64+
65+
1. Then click **Run**.
66+
67+
![Click Run to start query](./media/entitlement-management-logs-and-reporting/run-query.png)
68+
69+
The table will show the Audit log events for entitlement management from the last hour by default. You can change the “Time range” setting to view older events. However, changing this setting will only show events that occurred after Azure AD was configured to send events to Azure Monitor.
70+
71+
If you would like to know the oldest and newest audit events held in Azure Monitor, use the following query:
72+
73+
```
74+
AuditLogs | where TimeGenerated > ago(3653d) | summarize OldestAuditEvent=min(TimeGenerated), NewestAuditEvent=max(TimeGenerated) by Type
75+
```
76+
77+
For more information on the columns that are stored for audit events in Azure Monitor, see [Interpret the Azure AD audit logs schema in Azure Monitor](../reports-monitoring/reference-azure-monitor-audit-log-schema.md).
78+
79+
## Create custom Azure Monitor queries using Azure PowerShell
80+
81+
You can access logs through PowerShell after you've configured Azure AD to send logs to Azure Monitor. Then, send queries from scripts or the PowerShell command line, without needing to be a Global Admin in the tenant.
82+
83+
### Ensure the user or service principal has the correct role assignment
84+
85+
Make sure you, the user or service principal that will authenticate to Azure AD, are in the appropriate Azure role in the Log Analytics workspace. The role options are either Log Analytics Reader or the Log Analytics Contributor. If you're already in one of those roles, then skip to [Retrieve Log Analytics ID with one Azure subscription](#retrieve-log-analytics-id-with-one-azure-subscription).
86+
87+
To set the role assignment and create a query, do the following steps:
88+
1. In the Azure portal, locate the [Log Analytics workspace](https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.OperationalInsights%2Fworkspaces
89+
).
90+
91+
1. Select **Access Control (IAM)**.
92+
93+
1. Then click **Add** to add a role assignment.
94+
95+
![Add a role assignment](./media/entitlement-management-logs-and-reporting/workspace-set-role-assignment.png)
96+
97+
### Install Azure PowerShell module
98+
99+
Once you have the appropriate role assignment, launch PowerShell, and [install the Azure PowerShell module](/powershell/azure/install-az-ps?view=azps-3.3.0) (if you haven’t already), by typing:
100+
101+
```azurepowershell
102+
install-module -Name az -allowClobber -Scope CurrentUser
103+
```
104+
105+
Now you're ready to authenticate to Azure AD, and retrieve the id of the Log Analytics workspace you’re querying.
106+
107+
### Retrieve Log Analytics ID with one Azure subscription
108+
If you have only a single Azure subscription, and a single Log Analytics workspace, then type the following to authenticate to Azure AD, connect to that subscription, and retrieve that workspace:
109+
110+
```azurepowershell
111+
Connect-AzAccount
112+
$wks = Get-AzOperationalInsightsWorkspace
113+
```
114+
115+
### Retrieve Log Analytics ID with multiple Azure subscriptions
116+
117+
[Get-AzOperationalInsightsWorkspace](/powershell/module/Az.OperationalInsights/Get-AzOperationalInsightsWorkspace) operates in one subscription at a time. So, if you have multiple Azure subscriptions, you'll want to make sure you connect to the one that has the Log Analytics workspace with the Azure AD logs.
118+
119+
The following cmdlets display a list of subscriptions, and find the id of the subscription that has the Log Analytics workspace:
120+
121+
```azurepowershell
122+
Connect-AzAccount
123+
$subs = Get-AzSubscription
124+
$subs | ft
125+
```
126+
127+
You can reauthenticate and associate your PowerShell session to that subscription using a command such as `Connect-AzAccount –Subscription $subs[0].id`. To learn more about how to authenticate to Azure from PowerShell, including non-interactively, see [Sign in with Azure PowerShell](/powershell/azure/authenticate-azureps?view=azps-3.3.0&viewFallbackFrom=azps-2.5.0
128+
).
129+
130+
If you have multiple Log Analytics workspaces in that subscription, then the cmdlet [Get-AzOperationalInsightsWorkspace](/powershell/module/Az.OperationalInsights/Get-AzOperationalInsightsWorkspace) returns the list of workspaces. Then you can find the one that has the Azure AD logs. The `CustomerId` field returned by this cmdlet is the same as the value of the "Workspace id" displayed in the Azure portal in the Log Analytics workspace overview.
131+
132+
```powershell
133+
$wks = Get-AzOperationalInsightsWorkspace
134+
$wks | ft CustomerId, Name
135+
```
136+
137+
### Send the query to the Log Analytics workspace
138+
Finally, once you have a workspace identified, you can use [Invoke-AzOperationalInsightsQuery](/powershell/module/az.operationalinsights/Invoke-AzOperationalInsightsQuery?view=azps-3.3.0
139+
) to send a Kusto query to that workspace. These queries are written in [Kusto query language](https://docs.microsoft.com/azure/kusto/query/).
140+
141+
For example, you can retrieve the date range of the audit event records from the Log Analytics workspace, with PowerShell cmdlets to send a query like:
142+
143+
```powershell
144+
$aQuery = "AuditLogs | where TimeGenerated > ago(3653d) | summarize OldestAuditEvent=min(TimeGenerated), NewestAuditEvent=max(TimeGenerated) by Type"
145+
$aResponse = Invoke-AzOperationalInsightsQuery -WorkspaceId $wks[0].CustomerId -Query $aQuery
146+
$aResponse.Results |ft
147+
```
148+
149+
You can also retrieve entitlement management events using a query like:
150+
151+
```azurepowershell
152+
$bQuery = = 'AuditLogs | where Category == "EntitlementManagement"'
153+
$bResponse = Invoke-AzOperationalInsightsQuery -WorkspaceId $wks[0].CustomerId -Query $Query
154+
$bResponse.Results |ft
155+
```
156+
157+
## Next steps:
158+
- [Create interactive reports with Azure Monitor workbooks](../../azure-monitor/app/usage-workbooks.md)
159+

articles/active-directory/governance/entitlement-management-reports.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,6 @@ When the user's access package assignment expires, is canceled by the user, or r
108108

109109
## Next steps
110110

111+
- [Archive reports and Logs](entitlement-management-logs-and-reporting.md)
111112
- [Troubleshoot Azure AD entitlement management](entitlement-management-troubleshoot.md)
112113
- [Common scenarios](entitlement-management-scenarios.md)

articles/active-directory/governance/entitlement-management-scenarios.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ There are several ways that you can configure entitlement management for your or
143143

144144
1. Open an access package
145145
1. [View assignments](entitlement-management-access-package-assignments.md#view-who-has-an-assignment)
146+
1. [Archive reports and logs](entitlement-management-logs-and-reporting.md)
146147

147148
### Administrator: View resources assigned to users
148149

Loading
49.9 KB
Loading
47.1 KB
Loading
Loading

0 commit comments

Comments
 (0)