0

I have set up a SQL Database and enabled the activity log (with a storage account and log analytics workspace). Is there a way within Azure to be able to view realtime or near-realtime queries from the SQL Server? I'm not interested in a performance hit or anything -- now I'm just looking to log all queries so I can make sure that applications are running properly. Here are the resources I have set up:

enter image description here

I am looking to be able to see a history of all queries that have executed and not just "slow queries" or "currently-running queries", etc.. How can I view queries that are executed, or is this not possible inside Azure?

Here is an example from AWS (RDS + Cloudwatch) where I can do it out of the box:

enter image description here

David542
  • 104,438
  • 178
  • 489
  • 842
  • Is is an Azure SQL Database or SQL Server on Azure? If the latter, look at Extended Events. – Thom A Nov 03 '20 at 22:01
  • 1
    Azure SQL Database has Extended Events too: https://learn.microsoft.com/en-us/azure/azure-sql/database/xevent-db-diff-from-svr – David Browne - Microsoft Nov 03 '20 at 22:04
  • @Larnu how can I find out? I know the server name shows something like david.database.windows.net, and I created it on Azure. – David542 Nov 03 '20 at 22:04
  • @DavidBrowne-Microsoft I see -- so there's no built in way to get a query log? I found this, which gives a SQL query to run: https://stackoverflow.com/questions/17920968/how-to-view-history-of-queries-all-or-over-a-long-period-performed-on-database#:~:text=For%20a%20database%20hosted%20on,Manage%20%3E%20Administration%20%3E%20Query%20Performance. The first answer has a few broken links. – David542 Nov 03 '20 at 22:10

1 Answers1

1

You can use Auditing or Extended Events using the "Query Batch Tracking" template to capture queries.

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67