0
0
Azurecloud~10 mins

Diagnostic settings for resources in Azure - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Diagnostic settings for resources
Start: Select Resource
Create Diagnostic Setting
Choose Logs & Metrics
Select Destination(s)
Save Configuration
Diagnostic Data Sent
Monitor & Analyze Data
This flow shows how to set up diagnostic settings on a resource to collect logs and metrics and send them to chosen destinations for monitoring.
Execution Sample
Azure
az monitor diagnostic-settings create \
  --resource /subscriptions/123/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/myVM \
  --name myDiagSetting \
  --logs '[{"category": "Administrative", "enabled": true}]' \
  --metrics '[{"category": "AllMetrics", "enabled": true}]' \
  --workspace /subscriptions/123/resourceGroups/myRG/providers/Microsoft.OperationalInsights/workspaces/myWorkspace
Creates a diagnostic setting on a VM resource to send logs and metrics to a Log Analytics workspace.
Process Table
StepActionInput/ParameterResult/State
1Select Resource/subscriptions/123/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/myVMResource identified for diagnostics
2Create Diagnostic SettingName: myDiagSettingDiagnostic setting object created
3Configure LogsCategory: Administrative, Enabled: trueLogs collection enabled for Administrative category
4Configure MetricsCategory: AllMetrics, Enabled: trueMetrics collection enabled for all metrics
5Set DestinationWorkspace: myWorkspaceDestination set to Log Analytics workspace
6Save ConfigurationApply settingsDiagnostic settings saved and active
7Data FlowLogs and metrics sentData flows to workspace for monitoring
8EndN/ASetup complete, monitoring enabled
💡 Diagnostic settings saved and data flow started; monitoring active
Status Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 5Final
resourceNone/subscriptions/123/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/myVM/subscriptions/123/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/myVM/subscriptions/123/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/myVM/subscriptions/123/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/myVM/subscriptions/123/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/myVM
diagnosticSettingNameNonemyDiagSettingmyDiagSettingmyDiagSettingmyDiagSettingmyDiagSetting
logsConfigNoneNone[{"category": "Administrative", "enabled": true}][{"category": "Administrative", "enabled": true}][{"category": "Administrative", "enabled": true}][{"category": "Administrative", "enabled": true}]
metricsConfigNoneNoneNone[{"category": "AllMetrics", "enabled": true}][{"category": "AllMetrics", "enabled": true}][{"category": "AllMetrics", "enabled": true}]
destinationNoneNoneNoneNone/subscriptions/123/resourceGroups/myRG/providers/Microsoft.OperationalInsights/workspaces/myWorkspace/subscriptions/123/resourceGroups/myRG/providers/Microsoft.OperationalInsights/workspaces/myWorkspace
Key Moments - 3 Insights
Why do we need to specify both logs and metrics categories separately?
Logs and metrics are different types of data; enabling one does not automatically enable the other. See execution_table rows 3 and 4 where logs and metrics are configured separately.
What happens if we do not specify a destination for diagnostic data?
Without a destination, diagnostic data has nowhere to go and will not be collected or stored. Execution_table row 5 shows setting the destination is essential before saving.
Can we send diagnostic data to multiple destinations at once?
Yes, diagnostic settings support multiple destinations like Log Analytics, Event Hub, and Storage. This example shows one destination, but you can add more before saving (see step 5).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step are logs enabled for the resource?
AStep 3
BStep 2
CStep 4
DStep 5
💡 Hint
Check the 'Action' and 'Result/State' columns in execution_table row 3.
According to variable_tracker, what is the value of 'destination' after step 4?
A/subscriptions/123/resourceGroups/myRG/providers/Microsoft.OperationalInsights/workspaces/myWorkspace
BNone
CmyDiagSetting
DAdministrative
💡 Hint
Look at the 'destination' row and the column 'After Step 4' in variable_tracker.
If we skip setting the destination, what will happen according to the key moments?
AOnly metrics will be collected, not logs.
BDiagnostic data will still be collected and stored automatically.
CDiagnostic data will not be collected or stored.
DThe diagnostic setting will fail to save.
💡 Hint
Refer to key_moments question 2 about the importance of setting a destination.
Concept Snapshot
Diagnostic settings collect logs and metrics from Azure resources.
You configure categories of logs and metrics separately.
Set one or more destinations like Log Analytics workspace.
Save settings to start sending diagnostic data.
This helps monitor and analyze resource health and activity.
Full Transcript
Diagnostic settings in Azure allow you to collect logs and metrics from resources. The process starts by selecting the resource, then creating a diagnostic setting with a name. You enable specific log categories and metric categories separately. Next, you choose where to send this data, such as a Log Analytics workspace. After saving, the diagnostic data flows to the destination for monitoring. Variables like resource, diagnosticSettingName, logsConfig, metricsConfig, and destination change step-by-step as you configure. Key points include the need to enable logs and metrics separately, the necessity of specifying a destination, and the option to send data to multiple destinations. This setup helps you keep track of resource health and troubleshoot issues effectively.