Skip to content

Commit f05d465

Browse files
Merge pull request #2638 from MicrosoftDocs/main
Auto Publish – main to live - 2025-11-19 06:00 UTC
2 parents fe0c6fb + eb58023 commit f05d465

File tree

1 file changed

+239
-0
lines changed

1 file changed

+239
-0
lines changed

articles/virtual-machine-scale-sets/virtual-machine-scale-sets-rolling-upgrade-custom-metrics.md

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,245 @@ if (Test-Path $scriptPath) {
365365

366366
For more response configuration examples, see [application health samples](https://github.com/Azure-Samples/application-health-samples)
367367

368+
### Verify and query custom metrics data
369+
370+
After configuring the application health extension to return custom metrics, you can verify that the custom metrics are being reported correctly and query the data from your Virtual Machine Scale Set instances.
371+
372+
> [!NOTE]
373+
> The method for querying custom metrics differs between Uniform and Flexible orchestration modes. Uniform mode uses `az vmss get-instance-view`, while Flexible mode requires querying individual VMs using `az vm get-instance-view`.
374+
375+
#### For Uniform Orchestration Mode
376+
377+
##### [CLI](#tab/azure-cli)
378+
379+
```azurecli-interactive
380+
az vmss get-instance-view \
381+
--resource-group <resource-group-name> \
382+
--name <vmss-name> \
383+
--instance-id <instance-id>
384+
```
385+
386+
**Sample output (snippet):**
387+
388+
```json
389+
{
390+
"extensions": [
391+
{
392+
"name": "ApplicationHealthExtension",
393+
"substatuses": [
394+
{
395+
"code": "ComponentStatus/CustomMetrics/succeeded",
396+
"message": "{\"rollingUpgrade\": {\"PhaseOrderingNumber\": 2, \"SkipUpgrade\": false}}"
397+
}
398+
]
399+
}
400+
]
401+
}
402+
```
403+
404+
The custom metrics are in the `message` field of the `ComponentStatus/CustomMetrics/succeeded` substatus.
405+
406+
##### [PowerShell](#tab/azure-powershell)
407+
408+
```azurepowershell-interactive
409+
Get-AzVmssVM `
410+
-ResourceGroupName <resource-group-name> `
411+
-VMScaleSetName <vmss-name> `
412+
-InstanceId <instance-id> `
413+
-InstanceView
414+
```
415+
416+
**Sample output (snippet):**
417+
418+
```json
419+
{
420+
"extensions": [
421+
{
422+
"name": "ApplicationHealthExtension",
423+
"substatuses": [
424+
{
425+
"code": "ComponentStatus/CustomMetrics/succeeded",
426+
"message": "{\"rollingUpgrade\": {\"PhaseOrderingNumber\": 2, \"SkipUpgrade\": false}}"
427+
}
428+
]
429+
}
430+
]
431+
}
432+
```
433+
434+
The custom metrics are in the `message` field of the `ComponentStatus/CustomMetrics/succeeded` substatus.
435+
436+
##### [REST](#tab/rest-api)
437+
438+
```http
439+
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/virtualMachines/{instanceId}/instanceView?api-version=2023-09-01
440+
```
441+
442+
**Sample response (snippet):**
443+
444+
```json
445+
{
446+
"extensions": [
447+
{
448+
"name": "ApplicationHealthExtension",
449+
"type": "Microsoft.ManagedServices.ApplicationHealthLinux",
450+
"typeHandlerVersion": "2.0",
451+
"substatuses": [
452+
{
453+
"code": "ComponentStatus/CustomMetrics/succeeded",
454+
"level": "Info",
455+
"displayStatus": "Provisioning succeeded",
456+
"message": "{\"rollingUpgrade\": {\"PhaseOrderingNumber\": 2, \"SkipUpgrade\": false}}"
457+
}
458+
]
459+
}
460+
]
461+
}
462+
```
463+
464+
The custom metrics are in the `message` field of the `ComponentStatus/CustomMetrics/succeeded` substatus.
465+
466+
---
467+
468+
#### For Flexible Orchestration Mode
469+
470+
In Flexible orchestration mode, instances are individual VMs. Use the `az vm get-instance-view` command and specify the VM name.
471+
472+
**Get custom metrics for a specific VM:**
473+
474+
##### [CLI](#tab/azure-cli)
475+
476+
```azurecli-interactive
477+
az vm get-instance-view \
478+
--resource-group <resource-group-name> \
479+
--name <vm-name>
480+
```
481+
482+
**Sample output (snippet):**
483+
484+
```json
485+
{
486+
"extensions": [
487+
{
488+
"name": "ApplicationHealthExtension",
489+
"substatuses": [
490+
{
491+
"code": "ComponentStatus/CustomMetrics/succeeded",
492+
"message": "{\"rollingUpgrade\": {\"PhaseOrderingNumber\": 1, \"SkipUpgrade\": false}}"
493+
}
494+
]
495+
}
496+
]
497+
}
498+
```
499+
500+
The custom metrics are in the `message` field of the `ComponentStatus/CustomMetrics/succeeded` substatus.
501+
502+
##### [PowerShell](#tab/azure-powershell)
503+
504+
```azurepowershell-interactive
505+
Get-AzVM `
506+
-ResourceGroupName <resource-group-name> `
507+
-Name <vm-name> `
508+
-Status
509+
```
510+
511+
**Sample output (snippet):**
512+
513+
```json
514+
{
515+
"extensions": [
516+
{
517+
"name": "ApplicationHealthExtension",
518+
"substatuses": [
519+
{
520+
"code": "ComponentStatus/CustomMetrics/succeeded",
521+
"message": "{\"rollingUpgrade\": {\"PhaseOrderingNumber\": 1, \"SkipUpgrade\": false}}"
522+
}
523+
]
524+
}
525+
]
526+
}
527+
```
528+
529+
The custom metrics are in the `message` field of the `ComponentStatus/CustomMetrics/succeeded` substatus.
530+
531+
##### [REST](#tab/rest-api)
532+
533+
```http
534+
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView?api-version=2023-09-01
535+
```
536+
537+
**Sample response (snippet):**
538+
539+
```json
540+
{
541+
"extensions": [
542+
{
543+
"name": "ApplicationHealthExtension",
544+
"type": "Microsoft.ManagedServices.ApplicationHealthLinux",
545+
"typeHandlerVersion": "2.0",
546+
"substatuses": [
547+
{
548+
"code": "ComponentStatus/CustomMetrics/succeeded",
549+
"level": "Info",
550+
"displayStatus": "Provisioning succeeded",
551+
"message": "{\"rollingUpgrade\": {\"PhaseOrderingNumber\": 1, \"SkipUpgrade\": false}}"
552+
}
553+
]
554+
}
555+
]
556+
}
557+
```
558+
559+
The custom metrics are in the `message` field of the `ComponentStatus/CustomMetrics/succeeded` substatus.
560+
561+
---
562+
563+
#### Troubleshooting custom metrics
564+
565+
If custom metrics are not being reported correctly, verify the following:
566+
567+
1. **Check Application Health Extension status:**
568+
569+
```bash
570+
az vmss get-instance-view \
571+
--resource-group <resource-group-name> \
572+
--name <vmss-name> \
573+
--instance-id <instance-id> \
574+
--query "extensions[?name=='ApplicationHealthExtension'].statuses"
575+
```
576+
577+
2. **Verify the health endpoint is responding:**
578+
579+
```bash
580+
# Get the public IP of an instance
581+
PUBLIC_IP=$(az vmss list-instance-public-ips \
582+
--resource-group <resource-group-name> \
583+
--name <vmss-name> \
584+
--query "[0].ipAddress" \
585+
--output tsv)
586+
587+
# Test the health endpoint
588+
curl -v http://$PUBLIC_IP:<port>/<request-path>
589+
```
590+
591+
3. **Check that the response format is correct:**
592+
593+
The application health endpoint must return a JSON response in this exact format:
594+
595+
```json
596+
{
597+
"ApplicationHealthState": "Healthy",
598+
"customMetrics": "{\"rollingUpgrade\": {\"PhaseOrderingNumber\": 0, \"SkipUpgrade\": false}}"
599+
}
600+
```
601+
602+
> [!IMPORTANT]
603+
>
604+
> - The `customMetrics` value must be a **JSON string** (double-serialized), not a JSON object
605+
> - The `ApplicationHealthState` must be set to "Healthy" for the instance to be included in the rolling upgrade
606+
> - The custom metrics are only read at the start of a rolling upgrade; changes during an upgrade won't affect the current upgrade
368607
369608
## Next steps
370609
Learn how to [perform manual upgrades](virtual-machine-scale-sets-perform-manual-upgrades.md) on Virtual Machine Scale Sets.

0 commit comments

Comments
 (0)