powershellazureazure-sql-databaselog-analysisazure-log-analytics

How to configure the log analytics for single database and server?


I configured log analytics with Azure SQL Analytics (Preview) solution for monitoring the databases, servers and elastic pools.

For that, I followed the below links

Monitor Azure SQL Database using Azure SQL Analytics (Preview) in Log Analytics

Enable Azure resource metrics logging using PowerShell

I used below cmdlet for enable metrics and diagnostics for single database instead of all my databases.

Set-AzureRmDiagnosticSetting -ResourceId “/subscriptions/XXXXXX-XXX-XXX-XXX/resourceGroups/YYYYY/providers/Microsoft.Sql/servers/YYYY/databases/” -WorkspaceId “XXXXXX-XXX-XXX-XXX” -Enabled $True

But when I run the above cmdlet in PowerShell ISE with Administrator mode, I got the below error even I installed the Azure RM Modules.

enter image description here


Solution

  • Please take a look at: https://learn.microsoft.com/en-us/azure/sql-database/sql-database-metrics-diag-logging

    There you have the information about how to configure your database to send the telemetry into Log Analytics. In addition to PowerShell, this can be done through Azure Portal, CLI, REST API, and ARM template.

    When it comes to the PowerShell problem, looks like you missed specifying the database in your ResourceId. You can configure the database or elastic pool to sent the telemetry into Log Analytics, you can't configure the server.