Random Musings

Sporadic thoughts on tech, economics, business, finance and trading

Setting up a Log Analytics Workspace in Azure

, ,

Yes, setting up a Log Analytics Workspace is essential for collecting and analyzing data for Azure Monitor Workbooks. Without it, you cannot query AVD session data or other logs. Here’s a step-by-step guide to ensure your Log Analytics Workspace is correctly set up:


Step 1: Create a Log Analytics Workspace

  1. Log in to the Azure portal.
  2. In the search bar, type Log Analytics Workspaces and select it.
  3. Click + Create to create a new workspace.
  4. Provide the following information:
    • Subscription: Choose the subscription to associate the workspace.
    • Resource Group: Select an existing resource group or create a new one.
    • Name: Give your workspace a meaningful name (e.g., AVD-Workspace).
    • Region: Select the same region as your AVD environment for optimal performance.
  5. Click Review + Create, then Create.

Step 2: Enable Diagnostics Settings for AVD

  1. Navigate to your Azure Virtual Desktop (AVD) host pool or session host in the Azure portal.
  2. Under Monitoring, select Diagnostics settings.
  3. Click + Add Diagnostic Setting.
  4. Configure the diagnostic settings:
    • Name: Provide a name (e.g., AVD-Diagnostics).
    • Log Analytics Workspace: Select the Log Analytics Workspace you just created.
  5. Select the specific logs to send to the workspace:
    • ConnectionLogs
    • ManagementLogs
    • ErrorLogs
  6. Save the diagnostic settings.

Step 3: Verify Data Collection

  1. Go to your Log Analytics Workspace in the Azure portal.
  2. Under General, select Logs.
  3. Run a simple query to verify data is being collected. For example: WVDConnections | limit 10
    • If the query returns results, data collection is working correctly.
    • If no results are returned, ensure:
      • Diagnostics are enabled for the AVD resources.
      • Logs are being sent to the correct workspace.

Step 4: Optimize Log Retention (Optional)

  1. In the Log Analytics Workspace, go to Usage and estimated costs.
  2. Adjust the Retention Period to balance cost and data retention needs.

Step 5: Use the Workspace in Azure Monitor Workbook

  1. Open Monitor in the Azure portal.
  2. Select Workbooks and start creating your workbook.
  3. When adding queries, ensure you select the Log Analytics Workspace where your AVD data is stored.

Step 6: Automate Log Analytics Setup (Optional)

For repeated deployments, you can use Azure Resource Manager (ARM) templates, Bicep, or Terraform to automate the setup of Log Analytics and diagnostics.