KQL query to check the date and time in virtual machine

Dharshinika-FT 21 Reputation points
2022-05-30T07:17:40.793+00:00

Hello Team,

I'm unable a write a kql query to see what is the time on virtual machine.
Could you please help me on this.

Thanks for your support

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,968 questions
Azure ISV (Independent Software Vendors) and Startups
Azure ISV (Independent Software Vendors) and Startups
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.ISV (Independent Software Vendors) and Startups: A Microsoft program that helps customers adopt Microsoft Cloud solutions and drive user adoption.
91 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ShaikMaheer-MSFT 38,321 Reputation points Microsoft Employee
    2022-05-31T06:11:31.64+00:00

    Hi @Dharshinika-FT ,

    Thank you for posting query in Microsoft Q&A Platform and helping me with clarifications on your query.

    Azure monitor workbooks basically help us to query log data of various resources in Azure and visualise data for reporting and analysis. KQL query helps us to query this data from log analytics behind the scenes.

    In KQL we have a function called now() to get current date and time in UTC. We should use that to get current date and time in UTC and then apply offset based on local time of VM.

    For example lets say if our VM local datetime is IST then below KQL query helps to get Current datetime of VM.
    Since the difference between UTC and IST is 5hours and 30 mins, here I am using offset to now() as 5.5h(That means 5hours and 30 mins)
    206850-image.png

    query used in above screenshot:

    datatable (VMname:string)[  
     'testVM'  
    ]  
    | extend UTCtime = now()  
    | extend ISTtime = now(+5.5h)  
    

    Hope this helps. Please let us know if any further queries.

    ---------------

    Please consider hitting Accept Answer. Accepted answers help community as well.