How to scale Azure VMSS linux VMs based on custom metric e.g. Memory Utilization?

Abhi 0 Reputation points
2024-06-19T09:32:25.9566667+00:00

How to scale Azure VMSS Linux VMs based on custom metric e.g. Memory Utilization?

I created a VMSS(manual scale) based on Ubuntu(22.04) Linux VMs. Then I created a Log analytics workspace and configured data collection rules in Azure Monitor by mentioning the source as the VMs inside VMSS and destination as Log analytics workspace. But it seems Perf logs are not getting captured.

When I logged into the VMSS VM instances it seems Azure monitor agents are not installed(though in case of standalone VM it gets automatically installed when we enable DCR).

My objective is to dynamically scale the VMSS based on memory usage of the VMs in VMSS, captured in Azure Monitor Logs.

Could not find any step by step guide in Microsoft document or internet.

Thanks in advance

Azure Virtual Machine Scale Sets
Azure Virtual Machine Scale Sets
Azure compute resources that are used to create and manage groups of heterogeneous load-balanced virtual machines.
360 questions
{count} votes

1 answer

Sort by: Most helpful
  1. kobulloc-MSFT 25,561 Reputation points Microsoft Employee
    2024-06-25T06:04:20.86+00:00

    Hello, @Abhi !

    How do I scale my Virtual Machine Scale Set based on custom metrics (like memory)?

    After you create your Virtual Machine Scale Set (VMSS), you can go to Monitoring > Metrics to view metrics (including available memory) and you can go to Availability + scale > Scaling to set new custom autoscale rules.

    https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-autoscale-portal#create-a-rule-to-automatically-scale-out

    1. Go to your VMSS
    2. Go to Availability + scale > Scaling
    3. Click on Custom autoscale
    4. Under Scale mode, select Scale based on a metric
    5. Click Add a rule
    6. Configure the rule using Current resource (for built in metrics, like available memory), Azure Monitor workspaces, or any of the other resources you would like to use.
    7. Set the Operator, Metric threshold to trigger scale action, Duration, Operation, and instance count to your desired values.
    8. Click Add
    9. Save your configuration.

    Custom autoscale for a VMSS using current resource/Available Memory:

    User's image

    Custom autoscale for a VMSS using Azure Monitor workspaces:

    User's image

    Additional Reading:


    I hope this has been helpful! Your feedback is important so please take a moment to accept answers.

    If you still have questions, please let us know what is needed in the comments so the question can be answered. Thank you for helping to improve Microsoft Q&A!

    User's image

    0 comments No comments