Log Analytics Query for SQL on Azure VM

MS Techie 2,751 Reputation points
2021-08-19T10:44:34.167+00:00

I have SQL installed on Azure VM , which is connected to Log Analytics workspace, for logging/monitoring.

I am aware of the MS-SQL Query that i need to write to achieve this.

But my question is how to write this MS-SQL (T-SQL Query) to query the SQL database on Azure VM, using Log analytics query or Azure monitor ?

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,645 questions
0 comments No comments
{count} votes

Accepted answer
  1. bharathn-msft 5,106 Reputation points Microsoft Employee Moderator
    2021-09-02T02:37:23.077+00:00

    @MS Techie Apologies for delay in getting back to this thread.

    Firstly to query something from Log Analytics workspace , you need to send data to the workspace. Given the current state of the product , features like Azure Diagnostic extensions or the Log Analytics agent will not be collecting the actual SQL tables and sending the data to Log Analytics workspace. You can enable the diagnostic settings for SQL database as stand alone and get below information.
    128380-image.png

    However if you want to do anything custom, you might have to write some automation to read SQL tables and make them as custom logs so that agent can pick it up or send it to Log analytics workspace as customlogs using the data collector api.

    Please be aware that you will be only able to query Log Analytics workspace using Kusto queries not T-SQL Query.

    Note: If your SQL tables are huge or you are running production workload , the custom approaches might not be recommended.

    Hope the above information helps. Please let us know if you need any further information. Thank you

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.