enable linux VM guest metrics in the Virtual Machine Scale Set [VMSS]

Uziel Silva 51 Reputation points
2020-06-17T19:50:27.653+00:00

Hello!

I need to perform automatic scaling of the VMSS VMs, based on RAM metrics of the linux VM

I followed the microsoft link procedure below, but there was an error when deploying the JSON template,

10237-azuredeployjson.txthttps://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-mvss-guest-based-autoscale-linux

"Exception of type
'Microsoft.WindowsAzure.Management.Monitoring.MonitoringServiceException' was thrown.
(Code.UnsupportedMetric)"

Attached is a template file used to deploy

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.
340 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Uziel Silva 51 Reputation points
    2020-07-09T12:29:06.46+00:00

    Below is the solution offered by Microsoft

    Once the VMSS is set. You can follow the below instruction on how to set up autoscale to scale VMSS on memory
     
    Install the IaaSDiagnostics extension at the VMSS level
     

    1. The first thing that we have to do is add the diagnostics extension to the VMSS. This is the easiest from Azure CLI, because we have a command to pull the default config of the extension schema:
      $ az vmss diagnostics get-default-config --is-windows-os > <where you want the file stored locally>\config.json //if you are installing on Linux, remove --is-windows-os
       
                      Example:
       
                     $ az vmss diagnostics get-default-config --is-windows-os > C:\diagnostic\config.json
                    There will be output in your CLI or PowerShell window. Copy the following output for later:
       
                    {
                     "storageAccountName": "STORAGE_ACCOUNT_NAME",
                     "storageAccountSasToken": "SAS_TOKEN_WITH_LEADING_QUESTION_MARK"
                     }
       
    2. Make sure that your config.json file ended up where you wanted it to go, and open it. There are two lines in here that we need to fill in with our information:
       
                      "StorageAccount": "DIAGNOSTIC_STORAGE_ACCOUNT", and
       
                      "resourceId": "VM_OR_VMSS_RESOURCE_ID"
       
    3. Save the config.json file,
    4. we need to create our protected settings file. In the same directory where our config.json file is
    5. create a new txt file and name it protected-settings.txt. Add the json block that we copied from CLI or PowerShell earlier:
      Fill in the information, and then save the file as protected-settings.json.
      {
        "storageAccountName": "STORAGE_ACCOUNT_NAME",
        "storageAccountSasToken": "SAS_TOKEN_WITH_LEADING_QUESTION_MARK"
      }
    6. We need to add extension. Open the powershell / CLI
      $ az vmss diagnostics set --resource-group <vmss RG> --vmss-name <vmss name> --settings <directory of config file>\config.json --protected-settings <directory of protected settings file>\protected-settings.json
      Example:
                     $ az vmss diagnostics set --resource-group memscale --vmss-name memscalevmss --settings C:\diagnostic\config.json --protected-settings C:\diagnostic\protected-settings.json
    7. make sure that you update your VMSS if its  set to manual:
       
      $ az vmss update-instances --resource-group <vmss RG> --name <vmss name> --instance-ids "*"
       
      Now, you can either check that the extension is on the VMSS in the Portal or through CLI. If you choose CLI, the command is:
       
      $ az vmss show --resource-group <vmss RG> --name <vmss name>
       
      Checking through the Portal is as easy as looking at the extensions in the VMSS blade.
    8. To confirm that the metrics are being collected, make sure that the VMSS is running and has been for a while, and check the diagnostic storage account --> table storage. You should see the following there (among others):
      o WADDiagnosticInfrastructureLogsTable
      o WADMetricsPT1MP10DV2S<date>
      o WADPerformanceCountersTable
       
       
       
      Creating the autoscale rules on the VMSS
      To create autoscale rules based on the IaaSDiagnostics extension that we added earlier, follow these steps:
       
      · On the VMSS blade, click Scaling
      · Change over to custom autoscale
      · Click + Add Rule
      · Change the Metric namespace to Guest (Classic)
      · Select Memory Usage in the Metric name field
      · Fill in your percentages
      · Depending on what you want your rules to do, fill in the rest of the fields
      · Don't forget to create another rule for scaling back in
      Save your new autoscale rules, and then update your current VMSS instances, if your upgrade policy is set to manual.
    1 person found this answer helpful.
    0 comments No comments

  2. Uziel Silva 51 Reputation points
    2020-06-23T01:26:44.873+00:00

    I was able to enable it, I'm already using RAM metrics to scale VMs automatically