预配与 Azure Monitor 日志和 Log Analytics 集成。 借助 Azure 监视,可以创建工作簿(也称为仪表板)、将预配日志存储 30 天以上,以及创建自定义查询和警报等。 本文介绍预配日志与 Azure Monitor 日志的集成方式。 要详细了解预配日志的一般工作原理,请参阅预配日志。
启用预配日志集成
如果你还不熟悉 Azure Monitor 和 Log Analytics,请探索以下资源,然后再回来了解如何将应用程序预配日志与 Azure Monitor 日志集成。
要将预配日志与 Azure Monitor 日志集成:
至少以安全管理员身份登录到 Microsoft Entra 管理中心。
浏览到 Entra ID>监视和运行状况>诊断设置。
选择要流式传输的日志,选择“发送到 Log Analytics工作区”选项,然后填写字段。
浏览到 Entra ID>监控与健康状况>Log Analytics 然后开始查询数据。
注意
首次启用集成后,日志可能需要一些时间才会显示在 Log Analytics 中。 如果收到错误提示订阅未注册以使用 microsoft.insights,请在几分钟后再检查。
了解数据
预配发送给日志查看器的基础数据流几乎完全相同。 Azure Monitor 日志获取的流与 Microsoft Entra 管理中心和 Microsoft Graph API 几乎相同。 如下表所述,日志字段存在一些差异。 Log Analytics 可能会显示比 Microsoft Entra 管理中心中的日志更多的事件。 要详细了解这些字段,请参阅列出 provisioningObjectSummary。
| Azure Monitor 日志 | Azure 门户 UI | Azure API |
|---|---|---|
| errorDescription | 原因 | resultDescription |
| 状态 | 结果类型 | 结果类型 |
| activityDateTime | TimeGenerated | TimeGenerated |
Microsoft Entra 工作簿
Microsoft Entra 标识工作簿为数据分析提供了灵活的画布。 它们还提供在 Azure 门户中创建丰富的可视化报表的功能。 要了解更多信息,请参阅 Microsoft Entra 工作簿。
预配分析和预配见解是两个可用的预生成工作簿。 要查看数据,请确保已填充所有筛选器(timeRange、jobID、appName)。 此外,请确认已预配应用,否则日志中将不存在任何数据。
自定义查询
你可以创建自定义查询并在工作簿中显示数据。 要了解如何操作,请参阅 Azure Monitor 中的日志查询入门和 Azure Monitor 中的日志查询。
以下是一些应用程序预配日志查询的入门示例。
根据用户在源系统中的 ID 查询其日志:
AADProvisioningLogs
| extend SourceIdentity = parse_json(SourceIdentity)
| where tostring(SourceIdentity.Id) == "49a4974bb-5011-415d-b9b8-78caa7024f9a"
按 ErrorCode 汇总计数:
AADProvisioningLogs
| summarize count() by ErrorCode = ResultSignature
按操作汇总每天的事件计数:
AADProvisioningLogs
| where TimeGenerated > ago(7d)
| summarize count() by Action, bin(TimeGenerated, 1d)
采用 100 个事件和项目关键属性:
AADProvisioningLogs
| extend SourceIdentity = parse_json(SourceIdentity)
| extend TargetIdentity = parse_json(TargetIdentity)
| extend ServicePrincipal = parse_json(ServicePrincipal)
| where tostring(SourceIdentity.identityType) == "Group"
| project tostring(ServicePrincipal.Id), tostring(ServicePrincipal.Name), ModifiedProperties, JobId, Id, CycleId, ChangeId, Action, SourceIdentity.identityType, SourceIdentity.details, TargetIdentity.identityType, TargetIdentity.details, ProvisioningSteps
| take 100
检索具有因解决引用问题而跳过成员的组。
AADProvisioningLogs
| where TimeGenerated >= ago(10d)
| where JobId == "Azure2Azure.73f0883f-d67d-4af1-ac8a-45367f8982e0.5ef3be57-f45f-451g-88c4-68a7fda680bb" // Customize by adding a specific app JobId
| extend SourceIdentity = parse_json(SourceIdentity)
| extend ProvisioningSteps = parse_json(ProvisioningSteps)
| where tostring(SourceIdentity.identityType) == "Group"
| where ProvisioningSteps matches regex "UnableToResolveReferenceAttributeValue"
| parse tostring(ProvisioningSteps.[2].description) with "We were unable to assign " userObjectId " as the members of " groupDisplayName "." *
| project groupDisplayName, userObjectId, JobId
| take 100
按应用程序汇总操作。
AADProvisioningLogs
| where TimeGenerated > ago(30d)
| where JobId == "Azure2Azure.73f0883f-d67d-4af1-ac8a-45367f8982e0.5ef3be57-f45f-451g-88c4-68a7fda680bb" // Customize by adding a specific app JobId
| extend ProvisioningSteps = parse_json(ProvisioningSteps)
| extend eventName = tostring(ProvisioningSteps.[-1].name)
| summarize count() by eventName, JobId
| order by JobId asc
| take 5
确定特定操作中的峰值。
AADProvisioningLogs
| where TimeGenerated > ago(30d)
| where JobId == "scim.73f0883f-d67d-4af1-ac8a-45367f8982e0.5ef3be57-f45f-451g-88c4-68a7fda680bb" // Customize by adding a specific app JobId
| extend ProvisioningSteps = parse_json(ProvisioningSteps)
| extend eventName = tostring(ProvisioningSteps.[-1].name)
| summarize count() by eventName, bin(TimeGenerated, 1d)
| render timechart
自定义警报
通过 Azure Monitor,可以配置自定义警报,以便可以收到有关与预配相关的关键事件的通知。 例如,你可能希望在失败次数激增、禁用或删除次数激增时收到警报。 如果没有任何预配活动,这可能表明存在问题,你可能也希望收到警报。
有关警报的详细信息,请参阅 Azure Monitor 日志警报。 有许多选项和配置,因此请查看完整的文档。 但从高层次来说,以下是创建警报的方法:
- 在 Log Analytics 中,选择“+ 新建警报规则”。
- 在“条件”选项卡上,选择“在日志中查看结果并编辑查询”链接。
- 输入要对其发出警报的查询,并完成创建警报所需的字段。
若要在失败次数激增时创建警报,请执行以下步骤:
AADProvisioningLogs
| where JobId == "string" // Customize by adding a specific app JobId
| where ResultType == "Failure"
可能存在导致预配服务停止运行的问题。 使用以下查询检测在给定时间间隔内是否缺少预配事件。
AADProvisioningLogs
| take 1
要在禁用或删除次数激增时创建警报:
AADProvisioningLogs
| where Action in ("Disable", "Delete")
社区参与
我们正在为应用程序预配查询和仪表板采用一种开源的、基于社区的方法。 生成你认为对其他人有用的查询、警报或工作簿,然后将其发布到 AzureMonitorCommunity GitHub 存储库。 向我们发送带有链接的电子邮件。 我们会查看查询和仪表板并将其发布到服务,以便其他人也能从中受益。 请通过 provisioningfeedback@microsoft.com 联系我们。