Azure log analytics, memory result not showing - azure

I wanted to get the performance report of my azure VMs using log analytics. I found a blog here
which shows what I wanted.
The problem is when I run the code in my log analytics, it gives all the details except FreeMemoryGB and TotalMemoryGB as shown in the screenshot in the blog. It just shows blank space.
Thanks

Thank you Arun and KrishnaG-MSFT. Posting your suggestions as an answer to help other community members.
"% Used Memory" is a counter available for Linux boxes only. For Windows "% Committed Bytes In Use" is the closest which can give the current memory in use for any windows VM.
Perf
| where TimeGenerated > ago(30m)
| where CounterName == "% Committed Bytes In Use"
| project TimeGenerated, CounterName, CounterValue, Computer
| summarize UsedMemory = avg(CounterValue) by CounterName, bin(TimeGenerated, 1m), Computer
| where UsedMemory > 20
| render timechart
If your Azure VM is Windows OS then query to find disk total free space is:
Perf
| where ( ObjectName == "LogicalDisk" )
| where ( CounterName == "% Free Space" )
| where ( InstanceName == "_Total" )
| summarize AggregatedValue= avg(CounterValue) by Computer, bin(TimeGenerated, 30s)
You can refer to Read Windows VM RAM Memory Log Analytics Query and Is there any API to query an Azure VM for free disk/memory space?

Related

Alerts with Azure Monitor Agent Metrics

I am using the Azure Monitor Agent (AMA) to monitor a virtual machine.
I need to make an alert if the free disk is less than 10%.
For this purpose i'm using the guest metric "disk/free_percent", with mean as type of data aggregation.
On the graph, the values on the ordinate are the percentage of free disk? Because using df command on the virtual machine i have quite different values than the ones shown on the dashboard.
I have to make an alert if free disk is below 10%. What query i have to make using "disk/free_percent" to accomplish that task?
I've tryed to use operator "lesset than", unit as "number" and thrshold value as 10.
Disk Space will be computed in GB/MB units in general.
Instead of monitoring on a percentage basis, create an alert to check if the free disk space is less than 10gb.
As discussed here in Microsoft Q&A, I tried in my environment with a few modifications accordingly and I got the expected output for disk space.
Query:
let setgbvalue = 10;
Perf
| where ObjectName == "LogicalDisk" and CounterName == "Free Megabytes"
| where InstanceName !contains "C:"
| where InstanceName !contains "_Total"
| extend FreeSpaceGB = CounterValue/1024
| summarize FreeSpace = max(FreeSpaceGB) by InstanceName
| where FreeSpace < setgbvalue
Output:
If requirement is only with percentage, then you can use computing operations like countervalue/1024 multiplied by 100.

Azure Log Analytics - Performance Counters - same process name but different PID for CPU/Mem Chart

Im trying to figure out how to get a process from the Perf Table. The issue is that the process on the server has the same process name. I like to have cpu and memory usage for each unique process. this involves getting the process ID [PID] but i cant find it in azure log analytic workspace.
I'm pulling the custom performance counter to log analytic workstation:
\process(*)\*
Example:
get all svchost.exe to render in graph.
via unique PID
Perf
| where ObjectName == "Process"
| where InstanceName startswith "svchost"
| where CounterName == "% Processor Time"
| where Computer == "ServerNameHere"
| summarize CPUperMin = avg(CounterValue) by bin(TimeGenerated,1m)
| render timechart
//| distinct InstanceName
any ideas on how to find the PID? or KQL script to do this.

Is it possible to query under utilized VM's through Azure CLI?

I'm trying to find examples of queries that do similar things in logs portal of a VM. I want to query a VM to see if its been under % CPU usage and Memory usage for over 24 hours (ideally 30 days or so as well) This will determine if our VM's can potentially be scaled down.
I've looked at "az vm monitor metrics" but it doesn't appear to show the same information as the logs portal, or at least the docs are not very clear on how to get what I'm after if it's possible.
Is it possible to query under utilized VM's through Azure CLI
Yes, we can get the CPU and memory utilization of VM in one single chart by using KQL query
Below is the code
Perf
| where ObjectName == "Processor" and CounterName == "% Processor Time" and InstanceName == "_Total"
| where Computer in ((Heartbeat | where OSType == "Linux" or OSType == "Windows" | distinct Computer))
| summarize MIN_CPU = min(CounterValue), AVG_CPU = avg(CounterValue), MAX_CPU = max(CounterValue) by Computer
| join
(
Perf
| where ObjectName == "Memory"
| where CounterName == "% Used Memory" or CounterName == "% Committed Bytes In Use"
| summarize MIN_MEM = min(CounterValue), AVG_MEM = avg(CounterValue), MAX_MEM = max(CounterValue) by Computer
) on Computer
| project Computer, MIN_CPU, AVG_CPU, MAX_CPU, MIN_MEM, AVG_MEM, MAX_MEM
And here is the CLI command for executing query
az monitor log-analytics query -w workspace-customId --analytics-query "AzureActivity | summarize count() by bin(timestamp, 1h)" -t P3DT12H
For complete information you can go through the related links
AZ monitor Log analytics query and KQL Log analytics query

Read Windows VM RAM Memory Log Analytics Query

I've been working on Log Analytics Workspace query, there i'd like to know about the memory(RAM) being use by windows VM Specially, in linux vm we can get it from % Used Memory counter though not able yo get Windows VM. Query for Linux Used memory is shown below:
// Memory usage
Perf
| where TimeGenerated > ago(30m)
| where CounterName == "% Used Memory"
| project TimeGenerated, CounterName, CounterValue, Computer
| summarize UsedMemory = avg(CounterValue) by CounterName, bin(TimeGenerated, 1m), Computer
| where UsedMemory > 20
| render timechart
this would work pretty much the same for windows vms, but you need to configure which counters do you gather, before this query can work.
https://learn.microsoft.com/en-us/azure/azure-monitor/platform/data-sources-performance-counters#configuring-performance-counters
#Sachin : You are right. "% Used Memory" is a counter available for Linux boxes only. For Windows "% Committed Bytes In Use" is the closest which can give you the current memory in use for any windows VM. The query can be the same what you have written but with the different counter name
Perf
| where TimeGenerated > ago(30m)
| where CounterName == "% Committed Bytes In Use"
| project TimeGenerated, CounterName, CounterValue, Computer
| summarize UsedMemory = avg(CounterValue) by CounterName, bin(TimeGenerated, 1m), Computer
| where UsedMemory > 20
| render timechart

Sizing Azure Kubernetes Services (AKS) Cluster

I am trying to size my AKS clusters. What I understood and followed is the number of micro services and their replication copies would be primary parameters. Also the resource usage by each micro services and prediction of that usage increase during coming years also needs to be considered. But all these information seems totally scattered to reach a number for AKS sizing. Sizing I meant by how many nodes to be assigned? what could be the configuration of nodes, how many pods to be considered, how many IP numbers to be reserved based on number of pods etc..
Is there any standard matrix here or practical way of calculation to
compute AKS cluster sizing, based on any ones'experience?
no, pretty sure there is none (and how it could be)? just take your pod cpu\memory usage and sum that up, you'll get an expectation of the resources needed to run your stuff, add k8s services on top of that.
also, like Peter mentions in his comment, you can always scale your cluster, so such planning seems a bit unreasonable.
Actually, you may be interested in the Sizing of your nodes, things like Memory, CPU, Networking, Disk are directly linked with the node you chose, example:
Not all memory and CPU in a Node can be used to run Pods. The resources are partitioned in 4:
Memory and CPU reserved to the operating system and system daemons such as SSH
Memory and CPU reserved to the Kubelet and Kubernetes agents such as the CRI
Memory reserved for the hard eviction threshold
Memory and CPU available to Pods
CPU and Memory available for PODs
________________________________________________
Memory | % Available | CPU | % Available
________________________________________________
1 | 0.00% | 1 | 84.00%
2 | 32.50% | 2 | 90.00%
4 | 53.75% | 4 | 94.00%
8 | 66.88% | 8 | 96.50%
16 | 78.44% | 16 | 97.75%
64 | 90.11% | 32 | 98.38%
128 | 92.05% | 64 | 98.69%
192 | 93.54%
256 | 94.65%
Other things are Disk and Networking, example:
Node Size | Maximum Disks| Maximum Disk IOPS | Maximum Throughput (MBps)
_______________________________________________________________________________
Standard_DS2_v2 | 8 | 6,400 | 96
Standard_B2ms | 4 | 1,920 | 22.5

Resources