• 461K Members
• 5,150 Online
• 559K Conversations
SOLVED

## Calculating performance counters memory and network usage as percentage

Occasional Contributor

# Calculating performance counters memory and network usage as percentage

Hi everyone,

Calculating memory and network usage as a percentage of the resource is a classic problem for Windows performance counters. The issue is that the available counters are absolute numbers, but you don't necessarily know the total for these resources on a given machine.

Has anyone come up with a clever way to do this through in OMS and log analytics?

For reference, here is a query I'm using to get the average for Bytes Total/sec:

Perf
| where ObjectName == "Network Interface" and CounterName == "Bytes Total/sec"
| where TimeGenerated > startofday(now()-22d) and TimeGenerated < endofday(now()-1d)
| summarize AggregatedValue = avg(CounterValue) by Computer, InstanceName , bin(TimeGenerated, 1hour)

3 Replies
Solution

# Re: Calculating performance counters memory and network usage as percentage

So this will get you really close on the memory, however it would be much easier if the log analytics just collected this type of hardware inventory data.

its not quite 100% for instance on my hyperv server its ~4gb off, but on another physical server it was less than .5 gb off. Perhaps it will get you started?

let Convert = Perf
| where CounterName == "% Committed Bytes In Use"
| extend Perc = 100 - CounterValue;

let Gigs = Perf
| where CounterName == "Available MBytes"
| extend available_GB = CounterValue / 1024;

Gigs | join (Convert) on Computer
| project Computer, available_GB, Perc, CounterName1, CounterValue1
| extend Total_GB = (available_GB * 100) / Perc

# Re: Calculating performance counters memory and network usage as percentage

I think Billy's reply is the best response. Tried to "prettify" it:

```let free_memory_percent = Perf
| where CounterName == "% Committed Bytes In Use"
| summarize arg_max(TimeGenerated, CounterValue) by Computer
| project TimeGenerated, Computer, free_memory_percent=100-CounterValue;

let free_memory_gigs = Perf
| where CounterName == "Available MBytes"
| summarize arg_max(TimeGenerated, CounterValue) by Computer
| project TimeGenerated, Computer, free_memory_GB=CounterValue/1024;

free_memory_gigs
| join kind= innerunique(free_memory_percent) on Computer
| where time_diff=abs((TimeGenerated-TimeGenerated1)/1m)<1
| project TimeGenerated, Computer, free_memory_percent, free_memory_GB, Total_GB=(free_memory_GB*100)/free_memory_percent```

A link to the example on the demo env here.

# Re: Calculating performance counters memory and network usage as percentage

Thanks Billy and Noa, this was very helpful.

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies