Forum Discussion

samer87's avatar
samer87
Copper Contributor
Jul 30, 2019

How to add a custom column which will get data from a row

Follwing query gives values from multiple performance counters but in a different rows. Is it possible to add performance counter's value in columns
 
Perf
| where ObjectName =="Memory" and CounterName=="% Committed Bytes In Use" or CounterName=="% used memory" or CounterName=="Available MBytes"
| summarize Avg_Memory_Usage=avg(CounterValue) by Computer, CounterName
 
required output
Computer, Available Memory, %committed memory
xyz, 3000, 20
  • samer87's avatar
    samer87
    Copper Contributor

    May we be we can create a temp table and join the two data sets to have perf counter values in columns instead of row. If someone could help give an example of that may also help

     

    samer87 

    • CliveWatson's avatar
      CliveWatson
      Icon for Microsoft rankMicrosoft

      samer87 

       

      You can store the results using the Let statement - note, all three lets must return data for this to work - thats why I have commented out two lines as I don't have "% used memory" data in the workspace 

       

      Go to Log Analytics and Run Query

       

      let commitedBytes = (Perf
      | where ObjectName =="Memory" and CounterName=="% Committed Bytes In Use"
      | summarize AvgCommitedBytes=avg(CounterValue) by Computer);
      let usedMemory = (Perf
      | where ObjectName =="Memory" and CounterName=="% used memory"
      | summarize AvgUsedMemory=avg(CounterValue) by Computer);
      let availableBytes = (Perf
      | where ObjectName =="Memory" and CounterName=="Available MBytes"
      | summarize AvgAvailBytes=avg(CounterValue) by Computer);
      commitedBytes 
      //| join kind=inner (usedMemory)     on Computer 
      | join kind=inner (availableBytes) on Computer 
      | project Computer,
                AvgCommitedBytes,
      //          AvgUsedMemory,
                AvgAvailBytes

       

       

       

       

       

       

Resources