Hi @Anirban Sarkar ,
if this is your requirement:
Like if a user is using a vm using rdp, how long is he/she using it until he shuts down the vm.
Neither monitoring the network traffic nor monitoring the CPU workload helps to get the required details "which user is using the VM and how long".
- The CPU workload doesn't provide any detail of the user or user's computer. If the user is just idling in the RDP session it's hard to detect by monitoring the CPU.
- Monitoring the network traffic might give details about the IP of the user's computer. But even than it's not a reliable method to get the user details (start/end RDP session).
I would suggest to get the login/logoff information from the Security Event Log of the VM.
The EventID 4624 shows the successful logged on of a user, including the user name and the date/time details.
EventID 4647 shows the user initiated the logoff, including the user name and the date/time details
If you get both events it's possible to do the math how long a user was connected to the VM.
With Azure Log Analytics it's possible to collect the Event Log information: https://learn.microsoft.com/en-us/azure/azure-monitor/agents/data-sources-windows-events
The data can be queried in the Azure Log Analytics Workspace using Kusto:
https://techcommunity.microsoft.com/t5/azure-observability/oms-query-for-ad-login-and-log-offs/m-p/162689
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten