Skip to content

Commit 4056cce

Browse files
authored
Merge pull request #285995 from sreekzz/patch-87
Added Approach 2 section
2 parents cc943c5 + 9dc341a commit 4056cce

File tree

3 files changed

+310
-8
lines changed

3 files changed

+310
-8
lines changed

articles/hdinsight/azure-monitor-agent.md

Lines changed: 308 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Azure Monitor Agent (AMA) migration guide for Azure HDInsight clusters
33
description: Learn how to migrate to Azure Monitor Agent (AMA) in Azure HDInsight clusters.
44
ms.service: azure-hdinsight
55
ms.topic: how-to
6-
ms.date: 08/29/2024
6+
ms.date: 09/03/2024
77
---
88

99
# Azure Monitor Agent (AMA) migration guide for Azure HDInsight clusters
@@ -75,7 +75,7 @@ The following sections describe how customers can use the new Azure Monitor Agen
7575
>
7676
> For more information about how to create a Log Analytics workspace, see [Create a Log Analytics workspace in the Azure portal](/azure/azure-monitor/logs/quick-create-workspace).
7777
78-
### Enable Azure monitor agent using Portal
78+
### Approach 1: Enable Azure monitor agent using Portal
7979

8080
Activate the new integration by going to your cluster's portal page and scrolling down the menu on the left until you reach the Monitoring section.
8181

@@ -92,6 +92,309 @@ Activate the new integration by going to your cluster's portal page and scrollin
9292

9393
1. Select Save once precondition steps are complete.
9494

95+
### Approach 2: Enable Azure monitor agent using Azure PowerShell
96+
97+
1. Enable system-assigned MSI
98+
99+
1. First get cluster information to check the MSI of cluster.
100+
101+
102+
`Get-AzHDInsightCluster -ResourceGroupName $resourceGroup –ClusterName $cluster`
103+
104+
105+
106+
1. If this cluster has no MSI, directly enable system assigned MSI
107+
108+
`Update-AzHDInsightCluster -ResourceGroupName $resourceGroup -ClusterName $cluster -IdentityType "SystemAssigned"`
109+
110+
111+
1. If this cluster only has user assigned MSI, add system assigned MSI to identity.
112+
113+
114+
`Update-AzHDInsightCluster -ResourceGroupName $resourceGroup -ClusterName $cluster -IdentityType "SystemAssigned,UserAssigned" -IdentityId "$userAssignedIdentityResourceId"`
115+
116+
117+
118+
1. If this cluster already system assigned MSI, no need to anything.
119+
120+
121+
1. Creation of DCR
122+
123+
For more information, see [Create and edit data collection rules (DCRs)](/azure/azure-monitor/essentials/data-collection-rule-create-edit?tabs=powershell#create-a-dcr).
124+
125+
```
126+
# The URL of the DCR template file, change {HDIClusterType} to your cluster type.
127+
128+
# The valid types are: hadoop, hbase, interactivehive, kafka, llap, spark
129+
130+
$dcrTemplatejsonUrl = "https://hdiconfigactions.blob.core.windows.net/azuremonitoriningagent/DCR/{HDIClusterType}_dcr_template.json"
131+
132+
$dcrJsonContent = Invoke-RestMethod -Uri $dcrTemplatejsonUrl
133+
134+
135+
136+
# Get details of your Log Analytics workspace, if your workspace is in another subscription, you need to change context to the subscription
137+
138+
$workspaceResourceGroupName = "{yourWorkspaceResourceGroup}"
139+
140+
$workspaceName = {yourWorkspaceName}
141+
142+
$workspace = Get-AzOperationalInsightsWorkspace -ResourceGroupName $workspaceResourceGroupName -Name $workspaceName
143+
144+
145+
146+
# Customize the DCR content
147+
148+
$dcrJsonContent.properties.destinations.logAnalytics[0].workspaceResourceId = $workspace.ResourceId
149+
150+
$dcrJsonContent.properties.destinations.logAnalytics[0].workspaceId = $workspace.CustomerId
151+
152+
$dcrJsonContent.location = $workspace.Location
153+
154+
155+
156+
# Create the DCR using the customized JSON (DCR needs to be in the same location as Log Analytics workspace).
157+
158+
# If your HDInsight cluster is in another subscription, you need to change context to your cluster’s subscription
159+
160+
$dcrName = " {yourDcrName} "
161+
162+
$resourceGroupName = " {YourDcrResourceGroup} "
163+
164+
$dcrStr = $dcrJsonContent | ConvertTo-Json -Depth 10
165+
166+
$dcr = New-AzDataCollectionRule -Name $dcrName -ResourceGroupName $resourceGroupName -JsonString $dcrStr
167+
```
168+
169+
170+
1. Association of DCR.
171+
172+
For more information, see [Set up the Azure Monitor agent on Windows client devices](/azure/azure-monitor/agents/azure-monitor-agent-windows-client#create-and-associate-a-monitored-object).
173+
174+
175+
```
176+
# Associate DCR to HDInsight cluster
177+
178+
$hdinsightClusterResourceId = "/subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.HDInsight/clusters/{clusterName}"
179+
180+
$dcrAssociationName = "dcrAssociationName {yourDcrAssociation} "
181+
182+
New-AzDataCollectionRuleAssociation -AssociationName $dcrAssociationName -ResourceUri $hdinsightClusterResourceId -DataCollectionRuleId $dcr.Id
183+
```
184+
185+
1. Enabling Azure Monitor Agent.
186+
187+
```
188+
# Enter user information
189+
190+
$resourceGroup = "<your-resource-group>"
191+
192+
$cluster = "<your-cluster>"
193+
194+
$LAW = "<your-Log-Analytics-workspace>"
195+
196+
# End of user input
197+
198+
199+
# obtain workspace id for defined Log Analytics workspace
200+
201+
$WorkspaceId = (Get-AzOperationalInsightsWorkspace -ResourceGroupName $resourceGroup -Name $LAW).CustomerId
202+
203+
204+
205+
# obtain primary key for defined Log Analytics workspace
206+
207+
$PrimaryKey = (Get-AzOperationalInsightsWorkspace -ResourceGroupName $resourceGroup -Name $LAW | Get-AzOperationalInsightsWorkspaceSharedKeys).PrimarySharedKey
208+
209+
210+
211+
# Enables monitoring and relevant logs will be sent to the specified workspace.
212+
213+
Enable-AzHDInsightAzureMonitorAgent -ResourceGroupName $resourceGroup -ClusterName $cluster -WorkspaceId $WorkspaceId -PrimaryKey $PrimaryKey
214+
215+
216+
217+
# Gets the status of monitoring installation on the cluster.
218+
219+
Get-AzHDInsightAzureMonitorAgent -ResourceGroupName $resourceGroup -ClusterName $cluster
220+
```
221+
222+
223+
1. (Optional) disabling Azure Monitor Agent.
224+
225+
```
226+
Disable-AzHDInsightAzureMonitorAgent -ResourceGroupName $resourceGroup -ClusterName $cluster
227+
```
228+
229+
230+
### Approach 3: Enable Azure monitor agent using Azure CLI
231+
232+
1. Enable system-assigned MSI.
233+
234+
1. First get cluster information to check the MSI of cluster.
235+
236+
237+
```
238+
az hdinsight show –-resource-group $resourceGroup –name $cluster
239+
240+
#get access token if needed
241+
242+
accessToken=$(az account get-access-token --query accessToken -o tsv)
243+
244+
url="https://management.azure.com/subscriptions/${subscriptionId}/resourcegroups/${resourceGroupName}/providers/Microsoft.HDInsight/clusters/${clusterName}?api-version=2024-08-01-preview"
245+
```
246+
247+
1. If this cluster has no MSI, directly enable system assigned MSI via rest API.
248+
249+
```
250+
body="{\"identity\": {\"type\": \"SystemAssigned\"}}"
251+
252+
az rest --method patch --url "$url" --body "$body" --headers "Authorization=Bearer $accessToken"
253+
```
254+
1. If this cluster only has user assigned MSI, add system assigned MSI to identity.
255+
```
256+
body="{\"identity\": {\"type\": \"SystemAssigned,UserAssigned\", \"userAssignedIdentities\": {$userAssignedIdentityResourceId:{}}}}"
257+
258+
az rest --method patch --url "$url" --body "$body" --headers "Authorization=Bearer $accessToken"
259+
```
260+
261+
262+
1. If this cluster already system assigned MSI, no need to anything.
263+
264+
265+
1. Creation of DCR.
266+
267+
For more information, see [Create and edit data collection rules (DCRs)](/azure/azure-monitor/essentials/data-collection-rule-create-edit?tabs=CLI#create-a-dcr)
268+
269+
```
270+
# The URL of the DCR template file, change {HDIClusterType} to your cluster type.
271+
272+
# The valid types are: hadoop, hbase, interactivehive, kafka, llap, spark
273+
274+
$dcrTemplatejsonUrl = "https://hdiconfigactions.blob.core.windows.net/azuremonitoriningagent/DCR/{HDIClusterType}_dcr_template.json?api-version=2020-08-01"
275+
276+
277+
278+
# Download dcr template to local
279+
280+
$dcrTemplateLocalFile = "dcrTemplateFileName.json"
281+
282+
azcopy copy $dcrTemplatejsonUrl $dcrTemplateLocalFile
283+
284+
285+
286+
# Set subscription
287+
288+
az account set --subscription "{yourSubscription}"
289+
290+
291+
292+
# Get details of your Log Analytics workspace
293+
294+
$workspaceResourceGroupName = "{yourWorkspaceResourceGroup}"
295+
296+
$workspaceName = "{yourWorkspaceName}"
297+
298+
$workspace = az monitor log-analytics workspace show --resource-group $workspaceResourceGroupName --workspace-name $workspaceName
299+
300+
301+
302+
# Customize the DCR content. Below script depends on jq, you need to install it if it’s not available in your environment.
303+
304+
$workspaceResourceId = $workspace | jq -r '.id'
305+
306+
$workspaceId = $workspace | jq -r '.customerId'
307+
308+
$location = $workspace | jq -r '.location'
309+
310+
311+
312+
# Read the JSON file
313+
314+
$templateJsonData=cat $dcrTemplateLocalFile
315+
316+
317+
318+
# Update the JSON fields using jq
319+
320+
$templateJsonData=echo $templateJsonData | jq --arg workspaceResourceId $workspaceResourceId '.properties.destinations.logAnalytics[0].workspaceResourceId = $workspaceResourceId'
321+
322+
$templateJsonData=echo $templateJsonData | jq --arg workspaceId $workspaceId '.properties.destinations.logAnalytics[0].workspaceId = $workspaceId'
323+
324+
$templateJsonData=echo $templateJsonData | jq --arg location $location '.location = $location'
325+
326+
327+
328+
# Save the updated JSON back to the file
329+
330+
echo $templateJsonData > $dcrTemplateLocalFile
331+
332+
333+
334+
# Print the updated JSON
335+
336+
cat $dcrTemplateLocalFile
337+
338+
339+
340+
# Create the DCR using the customized JSON (DCR needs to be in the same location as Log Analytics workspace)
341+
342+
# If your HDInsight cluster is in another subscription, you need to set subscription to your cluster’s subscription
343+
344+
$dcrName = "{yourDcrName}"
345+
346+
$resourceGroupName = "{YourDcrResourceGroup}" # Suggest to put DCR in the same resource group as your HDInsight cluster
347+
348+
$dcr = az monitor data-collection rule create --name $dcrName --location $location --resource-group $resourceGroupName --rule-file $dcrTemplateLocalFile
349+
```
350+
351+
352+
1. Association of DCR
353+
354+
```
355+
# Associate DCR to HDInsight cluster
356+
357+
$hdinsightClusterResourceId = "{YourHDInsightClusterResourceId}"
358+
359+
$dcrAssociationName = "{yourDcrAssociation}"
360+
361+
$dcrId = $dcr | jq -r '.id'
362+
363+
az monitor data-collection rule association create --association-name $dcrAssociationName --resource $hdinsightClusterResourceId --data-collection-rule-id $dcrId
364+
```
365+
366+
367+
1. Enabling Azure Monitor Agent
368+
369+
```
370+
# set variables
371+
372+
export resourceGroup=RESOURCEGROUPNAME
373+
374+
export cluster=CLUSTERNAME
375+
376+
export LAW=LOGANALYTICSWORKSPACENAME
377+
378+
379+
380+
# Enable the Azure Monitor Agent logs integration on an HDInsight cluster.
381+
382+
az hdinsight azure-monitor-agent enable --name $cluster --resource-group $resourceGroup --workspace $LAW
383+
384+
385+
386+
# Get the status of Azure Monitor Agent logs integration on an HDInsight cluster.
387+
388+
az hdinsight azure-monitor-agent show --name $cluster --resource-group $resourceGroup
389+
```
390+
391+
392+
1. (Optional) disabling Azure Monitor Agent.
393+
394+
```
395+
az hdinsight azure-monitor-agent disable --name $cluster --resource-group $resourceGroup
396+
```
397+
95398
### Enable Azure Monitor Agent logging for Spark cluster
96399
97400
Azure HDInsight Spark clusters control AMA integration using a Spark configuration `spark.hdi.ama.enabled`, by default the value is set to false. This configuration controls whether the Spark specific logs will come up in the Log Analytics workspace. If you want to enable AMA in your Spark clusters and retrieve the Spark event logs in their LA workspaces, you need to perform an additional step to enable AMA for spark specific logs.
@@ -112,7 +415,7 @@ The following steps describe how customers can enable the new Azure Monitor Agen
112415
113416
There are two ways you can access the new tables.
114417
115-
#### Approach 1:
418+
#### Approach 1
116419
117420
1. The first way to access the new tables is through the Log Analytics workspace.
118421
@@ -127,7 +430,7 @@ There are two ways you can access the new tables.
127430
> [!NOTE]
128431
>This process describes how the logs were accessed in the old integration. This requires the user to have access to the workspace.
129432
130-
#### Approach 2:
433+
#### Approach 2
131434
132435
The second way to access the new tables is through Cluster portal access.
133436
@@ -187,7 +490,7 @@ We provide a [mapping table](./log-analytics-migration.md#appendix-table-mappi
187490
188491
### Update dashboards for HDInsight clusters
189492
190-
If you build multiple dashboards to monitor your HDInsight clusters, you need to adjust the query behind the table once you enable the new Azure Monitor integration. The table name or the field name might change in the new integration, but all the information you have in old integration is included.
493+
If you build multiple dashboards to monitor your HDInsight clusters, you need to adjust the query behind the table once you enable the new Azure Monitor integration. The table name or the field name might change in the new integration, but all the information you have in old integration is included.
191494
192495
Refer to the [mapping table](log-analytics-migration.md#appendix-table-mapping) between the old table/schema to the new table/schema to update the query behind the dashboards
193496

articles/hdinsight/hdinsight-hadoop-oms-log-analytics-tutorial.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to use Azure Monitor logs to monitor jobs running in an H
44
ms.service: azure-hdinsight
55
ms.topic: how-to
66
ms.custom: devx-track-azurepowershell, references_regions, devx-track-azurecli
7-
ms.date: 05/10/2024
7+
ms.date: 09/03/2024
88
---
99

1010
# Use Azure Monitor logs to monitor HDInsight clusters
@@ -20,8 +20,7 @@ If you don't have an Azure subscription, [create a free account](https://azure.m
2020
#### [New Azure monitor experience](#tab/new)
2121

2222
> [!Important]
23-
> New Azure Monitor experience is available in all the regions as a preview feature.
24-
>
23+
> Azure Monitor experience (preview) in HDInsight is retiring by February 1, 2025. For more information, see [Retirement: Azure Monitor experience (preview) in HDInsight is retiring by February 1, 2025](https://azure.microsoft.com/updates/v2/HDInsight-Azure-Monitor-experience-retirement).
2524
2625
## Prerequisites
2726

3.81 KB
Loading

0 commit comments

Comments
 (0)