Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪲 Bug Report - VMSS Predictive Autoscale ARG not joining correctly #563

Open
judyer28 opened this issue Dec 10, 2024 · 0 comments
Open
Labels
Bug 🐞 Something isn't working

Comments

@judyer28
Copy link
Contributor

Describe the bug

The ARG for Enable Predictive autoscale and configure at least for Forecast Only
does not change id's to all lower case before joining leading to autoscalesettings set to null after join.

If I run the first part of the query I get an id like this:
/subscriptions/xxxx/resourceGroups/aprl-sandbox-rg/providers/Microsoft.Compute/virtualMachineScaleSets/aprl-vmss1

If I then run the query inside the join I get an id like this:
/subscriptions/xxxx/resourcegroups/aprl-sandbox-rg/providers/Microsoft.Compute/virtualMachineScaleSets/aprl-vmss1

It is subtle but notice the 'G' in resourceGroups is capitalized in the first result but not the second. This causes the leftouter join to only take the left results and not do the join as expected and leaving autoscale settings to be null.

To Reproduce

Steps to reproduce the behaviour:

Create a VMSS with autoscale settings and predictive disabled

Expected behaviour

Should catch if autoscale is turned on but predictive is disabled.

Screenshots 📷

If applicable, add screenshots to help explain your problem. Please feel free to blur/cover any sensitive information.

Additional context

Suggest changing the query to the following:

// Find VMSS instances associated with autoscale settings when predictiveAutoscalePolicy_scaleMode is disabled
resources
| where type == "microsoft.compute/virtualmachinescalesets"
| where iff(isempty(tostring(tags['aks-managed-poolName'])), true, false)
| project name, id=tolower(id), tags
| join kind=leftouter (
resources
| where type == "microsoft.insights/autoscalesettings"
| where tostring(properties.targetResourceUri) contains "Microsoft.Compute/virtualMachineScaleSets"
| project id = tolower(tostring(properties.targetResourceUri)), autoscalesettings = properties
) on id
| where autoscalesettings.enabled == "true" and autoscalesettings.predictiveAutoscalePolicy.scaleMode == "Disabled"
| project recommendationId = "3f85a51c-e286-9f44-b4dc-51d00768696c", name, id, tags, param1 = "predictiveAutoscalePolicy_scaleMode: Disabled"
| order by id asc

@microsoft-github-policy-service microsoft-github-policy-service bot added the Bug 🐞 Something isn't working label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐞 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant