0

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.

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?

Yoda
  • 17,363
  • 67
  • 204
  • 344

1 Answers1

2

if entity was Added, Removed, Edited,what columns where edited and what user did it. is it possible to
track changes made to records stored in selected errors using 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. 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. You can send your Azure SQL Logs to the Log Analytics workspace and query the details.

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. :-

Enable Azure SQL Server level logging:-

enter image description here

Enable Azure SQL DB level logging for Database events:-

enter image description here

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 :-

enter image description here

Solution :-

enter image description here

enter image description here

enter image description here

enter image description here

You can also find the Top executed queries and error codes if the queries failed here in the Performance overview:-

enter image description here

enter image description here

Click on the Top executed query details row and you will find additional details on the query like below :-

enter image description here

You can send Azure SQL Logs via diagnostics settings too and send it to Log Analytics Workspace:-

enter image description here

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 :-

enter image description here

SiddheshDesai
  • 3,668
  • 1
  • 2
  • 11
  • Is it possible to see actual changed values (before and after state) instead of queries? – Yoda Jan 27 '23 at 13:26
  • Have a look at the answer provided in this SO post -https://stackoverflow.com/questions/17920968/how-to-view-history-of-queries-all-or-over-a-long-period-performed-on-database – SiddheshDesai Jan 27 '23 at 14:43