skip to Main Content

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

Answers


  1. Chosen as BEST ANSWER

    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)


  2. 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)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search