Error in getting Percentage value using KQL

%3CLINGO-SUB%20id%3D%22lingo-sub-1381831%22%20slang%3D%22en-US%22%3EError%20in%20getting%20Percentage%20value%20using%20KQL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1381831%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20use%20below%20query%20to%20find%20memory%20utilisation%20percentage%2C%20when%20i%20am%20trying%20to%20use%20summarize%20operator%20with%20division%20operator%20to%20get%20percentage%20its%20giving%20me%20output%20as%20zero%20only.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20someone%20help%20please%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3EInsightsMetrics%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Ewhere%3C%2FSPAN%3E%3CSPAN%3ETimeGenerated%20%26gt%3B%20ago(%3C%2FSPAN%3E%3CSPAN%3E1%3C%2FSPAN%3E%3CSPAN%3Eh)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Ewhere%3C%2FSPAN%3E%3CSPAN%3E%20Namespace%20%3C%2FSPAN%3E%3CSPAN%3Econtains%3C%2FSPAN%3E%20%3CSPAN%3E%22Memory%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Ewhere%3C%2FSPAN%3E%3CSPAN%3E%20Name%20%3C%2FSPAN%3E%3CSPAN%3Econtains%3C%2FSPAN%3E%20%3CSPAN%3E%22AvailableMB%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Eextend%3C%2FSPAN%3E%3CSPAN%3E%20FreeMB%20%3D%20toint(%3C%2FSPAN%3E%3CSPAN%3E32000%3C%2FSPAN%3E%3CSPAN%3E-toint(Val))%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Eextend%3C%2FSPAN%3E%3CSPAN%3E%20totalMB%20%3D%20toint(Val)%20%2B%20toint(FreeMB)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Esummarize%3C%2FSPAN%3E%3CSPAN%3E%20percent%20%3D%20max((FreeMB%2FtotalMB)*%3C%2FSPAN%3E%3CSPAN%3E100%3C%2FSPAN%3E%3CSPAN%3E)%20%3C%2FSPAN%3E%3CSPAN%3Eby%3C%2FSPAN%3E%3CSPAN%3E%20bin(TimeGenerated%2C%20%3C%2FSPAN%3E%3CSPAN%3E5%3C%2FSPAN%3E%3CSPAN%3Em)%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1381831%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Log%20Analytics%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1383716%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20in%20getting%20Percentage%20value%20using%20KQL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1383716%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F664248%22%20target%3D%22_blank%22%3E%40Azure_Kush2001%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%20try%20this%20(I%20have%20also%20replaced%20contains%20with%20has%20-%20as%20per%20best%20practise%2C%20also%20you%20can%20remove%20the%20two%20extra%20columns%20I%20added%20if%20its%20working%20ok%3F)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-cpp%22%3E%3CCODE%3EInsightsMetrics%0A%7C%20where%20TimeGenerated%20%26gt%3B%20ago(1h)%0A%7C%20where%20Namespace%20has%20%22Memory%22%0A%7C%20where%20Name%20has%20%22AvailableMB%22%0A%7C%20extend%20FreeMB%20%3D%20toreal(32000-toint(Val))%0A%7C%20extend%20totalMB%20%3D%20toreal(Val)%20%2B%20toint(FreeMB)%0A%7C%20summarize%20percent%20%3D%20max(FreeMB%2FtotalMB)*100%2C%20max(FreeMB)%2C%20max(totalMB)%20by%20bin(TimeGenerated%2C%205m)%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Visitor

 

 

 

 

I am trying to use below query to find memory utilisation percentage, when i am trying to use summarize operator with division operator to get percentage its giving me output as zero only.

 

Can someone help please

 

InsightsMetrics
| where TimeGenerated > ago(1h)
| where Namespace contains "Memory"
| where Name contains "AvailableMB"
| extend FreeMB = toint(32000-toint(Val))
| extend totalMB = toint(Val) + toint(FreeMB)
| summarize percent = max((FreeMB/totalMB)*100) by bin(TimeGenerated, 5m)
1 Reply
Highlighted

@Azure_Kush2001 

 

Please try this (I have also replaced contains with has - as per best practise, also you can remove the two extra columns I added if its working ok?)

 

InsightsMetrics
| where TimeGenerated > ago(1h)
| where Namespace has "Memory"
| where Name has "AvailableMB"
| extend FreeMB = toreal(32000-toint(Val))
| extend totalMB = toreal(Val) + toint(FreeMB)
| summarize percent = max(FreeMB/totalMB)*100, max(FreeMB), max(totalMB) by bin(TimeGenerated, 5m)