0
votes

I'm doing a query in Kusto on Azure to bring the memory fragmentation value of Redis, this value is obtained by dividing the RSS memory by the memory used, the problem is that I am not able to do the calculation using these two different fields because it is necessary to filter the value of the "Average" field of the "usedmemoryRss" and "usedmemory" fields when I do the filter on the extend line the query returns no value, the code looks like this:

AzureMetrics
| extend m1 = Average | where MetricName == "usedmemoryRss" and 
| extend m2 = Average | where MetricName == "usedmemory"
| extend teste = m1 / m2

When I remove the "where" clauyse from the lines it divides the value of each record by itself and return 1. Is it possible to do that? Thank you in advance for your help.

2
it would help if you could provide a sample input data set (using the datatable operator) and the expected output for it. understanding the schema and sample values in your data will allow to understand the problem statement, as well as test suggested solutions - Yoni L.

2 Answers

1
votes

Thanks for the answer Justin you gave me an idea and i solved this way

let m1 = AzureMetrics | where MetricName == "usedmemoryRss" | where Average != 0 | project Average;
let m2 = AzureMetrics | where MetricName  == "usedmemory" | where Average != 0 | project Average; 
print memory_fragmentation=toscalar(m1) / toscalar(m2)
0
votes
let Average=datatable (MetricName:string, Value:long)
    ["usedmemoryRss", 10,
     "usedmemory", "5"];
let m1=Average
| where MetricName =="usedmemoryRss" | project Value;
let m2=Average
| where MetricName =="usedmemory" | project Value;
print teste=toscalar(m1) / toscalar (m2)