About This Page
This page is part of the Azure documentation. It contains code examples and configuration instructions for working with Azure services.
Bias Analysis
Bias Types:
⚠️
powershell_heavy
⚠️
windows_first
⚠️
windows_tools
Summary:
The documentation demonstrates a Windows bias in several ways: PowerShell is presented as the primary scripted method for enabling Azure Monitor Agent integration, with detailed PowerShell examples and references to Windows-specific tools and documentation. The PowerShell approach is described before the Azure CLI approach, and references to 'Set up the Azure Monitor agent on Windows client devices' are included. There is no mention of Linux shell scripting or Linux-specific tools (other than Azure CLI and jq), and no explicit Linux/Unix shell examples are provided, despite HDInsight clusters often running on Linux.
Recommendations:
- Provide Linux shell/bash examples alongside or before PowerShell examples, especially for steps that can be performed on Linux-based HDInsight clusters.
- Avoid referencing Windows-specific documentation (such as 'Set up the Azure Monitor agent on Windows client devices') when the process is OS-agnostic or primarily relevant for Linux clusters.
- Clarify that Azure CLI and REST API steps are cross-platform and can be run from Linux, macOS, or Windows environments.
- Include explicit notes or sections for Linux users, especially for common operations like downloading files, editing JSON, or using tools like jq.
- Consider reordering the approaches so that the Azure CLI (cross-platform) method is presented before PowerShell, or present both methods in parallel.
- Where possible, provide sample scripts or commands that can be run natively on Linux (bash), and mention any required tools (e.g., curl, jq, azcopy) with installation instructions for Linux.
Create pull request
Flagged Code Snippets
Disable-AzHDInsightAzureMonitorAgent -ResourceGroupName $resourceGroup -ClusterName $cluster
# Associate DCR to HDInsight cluster
$hdinsightClusterResourceId = "/subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.HDInsight/clusters/{clusterName}"
$dcrAssociationName = "{yourDcrAssociation}"
New-AzDataCollectionRuleAssociation -AssociationName $dcrAssociationName -ResourceUri $hdinsightClusterResourceId -DataCollectionRuleId $dcr.Id
# The URL of the DCR template file, change {HDIClusterType} to your cluster type.
# The valid types are: hadoop, hbase, interactivehive, kafka, llap, spark
$dcrTemplatejsonUrl = "https://hdiconfigactions.blob.core.windows.net/azuremonitoriningagent/DCR/{HDIClusterType}_dcr_template.json"
$dcrJsonContent = Invoke-RestMethod -Uri $dcrTemplatejsonUrl
# Get details of your Log Analytics workspace, if your workspace is in another subscription, you need to change context to the subscription
$workspaceResourceGroupName = "{yourWorkspaceResourceGroup}"
$workspaceName = {yourWorkspaceName}
$workspace = Get-AzOperationalInsightsWorkspace -ResourceGroupName $workspaceResourceGroupName -Name $workspaceName
# Customize the DCR content
$dcrJsonContent.properties.destinations.logAnalytics[0].workspaceResourceId = $workspace.ResourceId
$dcrJsonContent.properties.destinations.logAnalytics[0].workspaceId = $workspace.CustomerId
$dcrJsonContent.location = $workspace.Location
# Create the DCR using the customized JSON (DCR needs to be in the same location as Log Analytics workspace).
# If your HDInsight cluster is in another subscription, you need to change context to your cluster’s subscription
$dcrName = " {yourDcrName} "
$resourceGroupName = " {YourDcrResourceGroup} "
$dcrStr = $dcrJsonContent | ConvertTo-Json -Depth 10
$dcr = New-AzDataCollectionRule -Name $dcrName -ResourceGroupName $resourceGroupName -JsonString $dcrStr
# Enter user information
$resourceGroup = "<your-resource-group>"
$cluster = "<your-cluster>"
$LAW = "<your-Log-Analytics-workspace>"
# End of user input
# obtain workspace id for defined Log Analytics workspace
$WorkspaceId = (Get-AzOperationalInsightsWorkspace -ResourceGroupName $resourceGroup -Name $LAW).CustomerId
# obtain primary key for defined Log Analytics workspace
$PrimaryKey = (Get-AzOperationalInsightsWorkspace -ResourceGroupName $resourceGroup -Name $LAW | Get-AzOperationalInsightsWorkspaceSharedKeys).PrimarySharedKey
# Enables monitoring and relevant logs will be sent to the specified workspace.
Enable-AzHDInsightAzureMonitorAgent -ResourceGroupName $resourceGroup -ClusterName $cluster -WorkspaceId $WorkspaceId -PrimaryKey $PrimaryKey
# Gets the status of monitoring installation on the cluster.
Get-AzHDInsightAzureMonitorAgent -ResourceGroupName $resourceGroup -ClusterName $cluster
# Associate DCR to HDInsight cluster
$hdinsightClusterResourceId = "{YourHDInsightClusterResourceId}"
$dcrAssociationName = "{yourDcrAssociation}"
$dcrId = $dcr | jq -r '.id'
az monitor data-collection rule association create --association-name $dcrAssociationName --resource $hdinsightClusterResourceId --data-collection-rule-id $dcrId
# The URL of the DCR template file, change {HDIClusterType} to your cluster type.
# The valid types are: hadoop, hbase, interactivehive, kafka, llap, spark
$dcrTemplatejsonUrl = "https://hdiconfigactions.blob.core.windows.net/azuremonitoriningagent/DCR/{HDIClusterType}_dcr_template.json?api-version=2020-08-01"
# Download dcr template to local
$dcrTemplateLocalFile = "dcrTemplateFileName.json"
azcopy copy $dcrTemplatejsonUrl $dcrTemplateLocalFile
# Set subscription
az account set --subscription "{yourSubscription}"
# Get details of your Log Analytics workspace
$workspaceResourceGroupName = "{yourWorkspaceResourceGroup}"
$workspaceName = "{yourWorkspaceName}"
$workspace = az monitor log-analytics workspace show --resource-group $workspaceResourceGroupName --workspace-name $workspaceName
# Customize the DCR content. Below script depends on jq, you need to install it if it’s not available in your environment.
$workspaceResourceId = $workspace | jq -r '.id'
$workspaceId = $workspace | jq -r '.customerId'
$location = $workspace | jq -r '.location'
# Read the JSON file
$templateJsonData=cat $dcrTemplateLocalFile
# Update the JSON fields using jq
$templateJsonData=echo $templateJsonData | jq --arg workspaceResourceId $workspaceResourceId '.properties.destinations.logAnalytics[0].workspaceResourceId = $workspaceResourceId'
$templateJsonData=echo $templateJsonData | jq --arg workspaceId $workspaceId '.properties.destinations.logAnalytics[0].workspaceId = $workspaceId'
$templateJsonData=echo $templateJsonData | jq --arg location $location '.location = $location'
# Save the updated JSON back to the file
echo $templateJsonData > $dcrTemplateLocalFile
# Print the updated JSON
cat $dcrTemplateLocalFile
# Create the DCR using the customized JSON (DCR needs to be in the same location as Log Analytics workspace)
# If your HDInsight cluster is in another subscription, you need to set subscription to your cluster’s subscription
$dcrName = "{yourDcrName}"
$resourceGroupName = "{YourDcrResourceGroup}" # Suggest to put DCR in the same resource group as your HDInsight cluster
$dcr = az monitor data-collection rule create --name $dcrName --location $location --resource-group $resourceGroupName --rule-file $dcrTemplateLocalFile