简体   繁体   English

Azure Monitor可以用来跟踪数据库实体的变化吗?

[英]Can Azure Monitor be used to track changes to database entities?

I created Audit Trail in my database by overriding EF Core SaveChanges and SaveChangesAsync methods and storing if entity was Added , Removed , Edited , what columns where edited and what user did it.我通过覆盖 EF Core SaveChangesSaveChangesAsync方法并存储实体是否已AddedRemovedEdited 、编辑了哪些列以及哪些用户进行了编辑,在我的数据库中创建了 Audit Trail。

However, I became aware of Azure Monitor, but I cannot find information is it possible to track changes made to records stored in selected errors using Azure Monitor instead of what I've done?但是,我意识到 Azure Monitor,但我找不到信息是否可以使用 Azure Monitor 而不是我所做的来跟踪对存储在选定错误中的记录所做的更改?

if entity was Added , Removed , Edited ,what columns where edited and what user did it.如果AddedRemovedEdited了实体,编辑了哪些列以及哪些用户进行了编辑。 is it possible to是否有可能
track changes made to records stored in selected errors using Azure使用 Azure 跟踪对存储在选定错误中的记录所做的更改
Monitor instead of what I've done?监视而不是我所做的?

Yes, You can make use of audit logs to get the logs of commands executed in your Azure SQL on Inserting, Selecting, and Creating the data.是的,您可以使用审计日志来获取在您的 Azure SQL 中执行的有关插入、选择和创建数据的命令的日志。 You can make use of Azure Monitor Performance management and SQL Insights to get information and logs on the Top queries and errors on the query execution by the user.您可以使用 Azure Monitor Performance management 和 SQL Insights 获取有关用户执行查询的热门查询和错误的信息和日志。 You can send your Azure SQL Logs to the Log Analytics workspace and query the details.您可以将您的 Azure SQL 日志发送到 Log Analytics 工作区并查询详细信息。

Audit Logs:-审计日志:-

Enable Audit Logs for your Azure SQL server like below and send the data to Log Analytics, You can also store the data in your Storage account.如下所示为您的 Azure SQL 服务器启用审核日志并将数据发送到 Log Analytics,您还可以将数据存储在您的存储帐户中。 :- :-

Enable Azure SQL Server level logging:-启用 Azure SQL 服务器级日志记录:-

在此处输入图像描述

Enable Azure SQL DB level logging for Database events:-为数据库事件启用 Azure SQL 数据库级日志记录:-

在此处输入图像描述

This will create one Log analytics solution for the SQL audit logs in the selected LA workspace and you can find your Azure SQL DB records and logs below:-这将为所选 LA 工作区中的 SQL 审计日志创建一个日志分析解决方案,您可以在下面找到您的 Azure SQL 数据库记录和日志:-

在此处输入图像描述

Solution:-解决方案:-

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

You can also find the Top executed queries and error codes if the queries failed here in the Performance overview:-如果查询失败,您还可以在性能概述中找到执行次数最多的查询和错误代码:-

在此处输入图像描述

在此处输入图像描述

Click on the Top executed query details row and you will find additional details on the query like below:-单击 Top executed query details 行,您将找到有关查询的其他详细信息,如下所示:-

在此处输入图像描述

You can send Azure SQL Logs via diagnostics settings too and send it to Log Analytics Workspace:-您也可以通过诊断设置发送 Azure SQL 日志并将其发送到 Log Analytics Workspace:-

在此处输入图像描述

If you're connected to SSMS, you can import your audit logs to SSMS by storing the audit logs in your storage account first and then importing it like below:-如果您已连接到 SSMS,则可以通过先将审核日志存储在存储帐户中然后将其导入,将审核日志导入 SSMS,如下所示:-

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM