Stream analytics scale logging

%3CLINGO-SUB%20id%3D%22lingo-sub-2263917%22%20slang%3D%22en-US%22%3EStream%20analytics%20scale%20logging%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2263917%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20requirement%20to%20auto%20scale%20a%20Stream%20Analytics%20Job%20based%20on%20CPU%20utilization.%20I%20tried%20using%20the%20out%20of%20the%20box%20utilization%20alerts%2C%20but%20this%20caused%20problems%20when%20the%20scale%20operation%20failed%3B%20it%20would%20never%20fire%20the%20scale%20operation%20again.%20I%20changed%20to%20a%20custom%20kusto%20query%20based%20on%20AzureMetrics.%20This%20works%20well%2C%20and%20also%20triggers%20the%20alerts%20every%20time%20it%20evaluates%20the%20query.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20problem%20is%20it%20triggers%20the%20alerts%20every%20time%20it%20evaluates%20the%20query%2C%20so%20also%20keeps%20firing%20scale%20down%20alerts%20when%20the%20Stream%20Analytics%20job%20is%20already%20scaled%20at%201.%20I%20am%20now%20looking%20into%20including%20the%20Stream%20Analytics%20scale%20logging%20in%20the%20query%2C%20to%20prevent%20the%20alert%20from%20firing%20when%20the%20Stream%20Analytics%20is%20already%20scaled%20at%201%20and%20wants%20to%20scale%20down%2C%20or%20120%20and%20wants%20to%20scale%20up.%20There%20is%20logging%20I%20can%20use%20for%20this%2C%20under%20the%20JobScaling%20operation%2C%20but%20for%20some%20reason%20it%20never%20logs%20scale%20operations%20below%206%2C%20even%20though%20it%20frequently%20scaled%20down%20below%206.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22WiJaN_1-1617973858478.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F271506i1D20406B763E2598%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22WiJaN_1-1617973858478.png%22%20alt%3D%22WiJaN_1-1617973858478.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EBelow%20is%20my%20current%20query%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markdown%22%3E%3CCODE%3EAzureDiagnostics%0A%7C%20where%20OperationName%20%3D%3D%20'JobScaling'%20and%20TimeGenerated%20%26gt%3B%20startofday(datetime(%222021-03-09%22))%20and%20TimeGenerated%20%26lt%3B%20endofday(datetime(%222021-04-09%22))%0A%7C%20project%20TimeGenerated%2C%20OperationName%2C%20properties_s%0A%7C%20extend%20scaledTo%3D%20toint(split(parse_json(properties_s).Message%2C%20%22'%22)%5B1%5D)%0A%7C%20project-away%20OperationName%2C%20properties_s%0A%7C%20summarize%20min(scaledTo)%2C%20max(scaledTo)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EThe%20output%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22WiJaN_0-1617973705285.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F271505iFC06837244FCBE42%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22WiJaN_0-1617973705285.png%22%20alt%3D%22WiJaN_0-1617973705285.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThe%20current%20scale%20at%201%3B%20(it%20is%20frequently%20scaled%20at%201)%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22WiJaN_2-1617973937659.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F271508i3291043B1392D21A%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22WiJaN_2-1617973937659.png%22%20alt%3D%22WiJaN_2-1617973937659.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20this%20a%20bug%3F%20Is%20there%20any%20other%20way%20to%20achieve%20my%20goal%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi,

 

I have a requirement to auto scale a Stream Analytics Job based on CPU utilization. I tried using the out of the box utilization alerts, but this caused problems when the scale operation failed; it would never fire the scale operation again. I changed to a custom kusto query based on AzureMetrics. This works well, and also triggers the alerts every time it evaluates the query.

 

The problem is it triggers the alerts every time it evaluates the query, so also keeps firing scale down alerts when the Stream Analytics job is already scaled at 1. I am now looking into including the Stream Analytics scale logging in the query, to prevent the alert from firing when the Stream Analytics is already scaled at 1 and wants to scale down, or 120 and wants to scale up. There is logging I can use for this, under the JobScaling operation, but for some reason it never logs scale operations below 6, even though it frequently scaled down below 6.

WiJaN_1-1617973858478.png

Below is my current query:

AzureDiagnostics
| where OperationName == 'JobScaling' and TimeGenerated > startofday(datetime("2021-03-09")) and TimeGenerated < endofday(datetime("2021-04-09"))
| project TimeGenerated, OperationName, properties_s
| extend scaledTo= toint(split(parse_json(properties_s).Message, "'")[1])
| project-away OperationName, properties_s
| summarize min(scaledTo), max(scaledTo)

The output:

WiJaN_0-1617973705285.png

The current scale at 1; (it is frequently scaled at 1):

WiJaN_2-1617973937659.png

 

Is this a bug? Is there any other way to achieve my goal?

0 Replies