SOLVED

Query to use percentage of values

%3CLINGO-SUB%20id%3D%22lingo-sub-1222191%22%20slang%3D%22fr-FR%22%3EQuery%20to%20use%20percentage%20of%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1222191%22%20slang%3D%22fr-FR%22%3E%3CP%3EHello%20guys%2C%3CBR%20%2F%3E%3CBR%20%2F%3EI'm%20beginner%20in%20Azure%20and%20I%20started%20a%20project%20in%20Azure%20Log%20Analytics.%20%3CBR%20%2F%3EI%20feel%20different%20values%20in%20a%20Custom%20Log%20from%20a%20Logic%20App%20(HTTP%20Request).%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22aprhn_0-1583935345858.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F176358i31D26C82C153B8EF%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22aprhn_0-1583935345858.png%22%20alt%3D%22aprhn_0-1583935345858.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EI%20have%20two%20values%20%22cpu_used%22%20and%20%22cpu_limit%22%20(Number%20type)%20and%20I%20want%20to%20create%20a%20query%20like%3A%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CEM%3EDisplay%20when%20%22cpu_used%22%20is%20at%2080%25%20of%20%22cpu_limit.%22%3C%2FEM%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EI%20tried%20many%20possibilities%20but%20I%20don't%20understand%20how%20to%20make%20this.%3C%2FP%3E%3CP%3EI%20don't%20understand%20anyway%20how%20to%20works%20%3CEM%3Esummary%20percentile().%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22aprhn_1-1583935688835.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F176359i5EF1FB433CE6FEE1%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22aprhn_1-1583935688835.png%22%20alt%3D%22aprhn_1-1583935688835.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThe%20value%20doesn't%20change.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20you%20in%20advance%20for%20your%20advises%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELooks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1222191%22%20slang%3D%22fr-FR%22%3E%3CLINGO-LABEL%3EAzure%20Log%20Analytics%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ECustom%20Logs%20and%20Custom%20Fields%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EQuery%20Language%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1222421%22%20slang%3D%22en-US%22%3ERe%3A%20Query%20to%20use%20percentage%20of%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1222421%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F579319%22%20target%3D%22_blank%22%3E%40aprhn%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20should%20be%20able%20to%20do%20the%20math%20with%20KQL.%26nbsp%3B%20This%20is%20fake%20but%20should%20give%20you%20the%20idea%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fms.portal.azure.com%23%4072f988bf-86f1-41af-91ab-2d7cd011db47%2Fblade%2FMicrosoft_Azure_Monitoring_Logs%2FDemoLogsBlade%2FresourceId%2F%252FDemo%2Fsource%2FLogsBlade.AnalyticsShareLinkToQuery%2Fq%2FH4sIAAAAAAAAA42OvQrCQBCE%25252B4DvMASERALRB0hlZaMp1FbOuNFI7i7sXfAHH96sGtFCsJxhvplJU9BZ6aYmDIKcuBwEN5wOxITF9kiFnytNyDKEOduCnLMcQpkdMDPOK1PQO7BZWq%25252FqUAoatsJialvjiR%25252BRpFdrVbdPqZu20xDCtVorrq6E2a6mvGMz8aoy%25252BqSSr0YZHT7yWFaaQsQJsHLEov7mBeh5bC%25252B%25252FbjXEBRmv9tIcdX7UL8VIJRe9jscxRpiMx3dHMfinWgEAAA%25253D%25253D%2Ftimespan%2FP1D%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EGo%20to%20Log%20Analytics%20and%20run%20query%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3E%2F%2F%20example%20%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EPerf%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Ewhere%3C%2FSPAN%3E%3CSPAN%3E%20ObjectName%20%3D%3D%20%3C%2FSPAN%3E%3CSPAN%3E%22Processor%22%3C%2FSPAN%3E%20%3CSPAN%3Eand%3C%2FSPAN%3E%3CSPAN%3E%20InstanceName%20%3D%3D%20%3C%2FSPAN%3E%3CSPAN%3E%22_Total%22%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Eproject%3C%2FSPAN%3E%3CSPAN%3E%20CounterName%20%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E%20CounterValue%20%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E%20Computer%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Esummarize%3C%2FSPAN%3E%3CSPAN%3E%20IdlePct%20%3D%20sumif%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3ECounterValue%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E%20CounterName%20%3D%3D%20%3C%2FSPAN%3E%3CSPAN%3E%22%25%20Idle%20Time%22%3C%2FSPAN%3E%20%3CSPAN%3E)%2C%3C%2FSPAN%3E%3CSPAN%3E%20UserTime%20%3D%20sumif%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3ECounterValue%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E%20CounterName%20%3D%3D%20%3C%2FSPAN%3E%3CSPAN%3E%22%25%20User%20Time%22%3C%2FSPAN%3E%20%3CSPAN%3E)%3C%2FSPAN%3E%20%3CSPAN%3Eby%3C%2FSPAN%3E%3CSPAN%3E%20Computer%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Esummarize%3C%2FSPAN%3E%3CSPAN%3E%20percentage%20%3D%20%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3Esum%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3EUserTime%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3CSPAN%3E%20%2F%20sum%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3EIdlePct%3C%2FSPAN%3E%3CSPAN%3E))%3C%2FSPAN%3E%3CSPAN%3E%20*%20%3C%2FSPAN%3E%3CSPAN%3E100%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1237386%22%20slang%3D%22fr-FR%22%3ERe%3A%20Query%20to%20use%20percentage%20of%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1237386%22%20slang%3D%22fr-FR%22%3E%3CP%3EHello%20Clive%2C%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20you!%20I%20adapted%20your%20query%20and%20works%20fine%20%3A).%20%3CBR%20%2F%3E%3CBR%20%2F%3ELooks%2C%3CBR%20%2F%3E%3CBR%20%2F%3EAur%C3%A9lien%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello guys,

I'm beginner in Azure and I started a project in Azure Log Analytics.
I sent different values in a Custom Log from a Logic App (HTTP Request).

aprhn_0-1583935345858.png

 


I have two values "cpu_used" and "cpu_limit" (Number type) and I want to create a query like :


Display when "cpu_used" is at 80% of "cpu_limit".

I tried many possibilities but I don't understand how to make this.

I don't understand anyway how to works summary percentile().

aprhn_1-1583935688835.png

The value doesn't change.

 

Thanks you in advance for your advises

 

Regards,

2 Replies
Best Response confirmed by aprhn (Occasional Contributor)
Solution

@aprhn 

 

You should be able to do the math with KQL.  This is fake but should give you the idea 

 

Go to Log Analytics and run query

// example
Perf
| where ObjectName == "Processor" and InstanceName == "_Total"
| project CounterName , CounterValue , Computer
| summarize IdlePct = sumif(CounterValue, CounterName == "% Idle Time" ), UserTime = sumif(CounterValue, CounterName == "% User Time" ) by Computer
| summarize percentage = (sum(UserTime) / sum(IdlePct)) * 100
 
 

Hello Clive,

Thanks you ! I adapted your query and works fine :).

Regards,

Aurélien