我可以提交天蓝色日志查询来获取当前日期时间吗? [英] can I submit an azure log query to get current datetime?

查看:134
本文介绍了我可以提交天蓝色日志查询来获取当前日期时间吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在ssms中执行以下查询来获取sql server db的当前日期时间:



选择GETDATE()



我是否可以使用任何类型的可比较查询来获取Azure自定义日志中使用的当前日期时间? 我尝试通过天蓝色日志查询提交等效内容但语法似乎无效:



MyLog_CL

| now()

I can execute the following query in ssms to get the current datetime for a sql server db:

select GETDATE()

Is there any type of comparable query that I can use to get the current datetime being used within an Azure custom log?  I tried to submit something equivalent through an azure log query but the syntax does not appear to be valid:

MyLog_CL
| now()

推荐答案

嗨dotnetteramg123,也许我错过了一些东西,但我不明白要求使用当前的日期时间在Azure自定义日志中。如果要求获取由于自定义日志文件中的任何更改而在Log Analytics
工作空间存储库中捕获的最新日志输入时间,那么您可以使用如下所示的查询



Hi dotnetteramg123, Perhaps I am missing something but I don't understand the requirement of getting the current datetime being used within an Azure custom log. If the requirement is to get the most recent log entry time that is captured in Log Analytics workspace repository due to any change in your custom log file, then you may use query something like shown below

MyLog_CL | sort by TimeGenerated desc | limit 1 | project TimeGenerated 





$
事实上,如果我们只想获得由于您的自定义日志文件中的任何更改,在Log Analytics工作区存储库中捕获的最新日志条目,然后您可以使用如下所示的查询






Infact, if we want to get only the most recent log entry that is captured in Log Analytics workspace repository due to any changes in your custom log file, then you may use query something like shown below

MyLog_CL | sort by TimeGenerated desc | limit 1 



半美元b b b b b b b b b b b b b b b b b b b b b b b b b b b b b无论MyLog_CL自定义日志的输出如何,它只会给你当前时间。然而,因为我们在管道输出MyLog_CL自定义日志之后尝试获取当前时间,所以我们得到当前时间的
输出,说'n'行,其中'n'等于MyLog_CL的行数自定义日志输出。






But if we have the query something like shown below then it would just give you the current time irrespective of MyLog_CL custom log's output. However as we are trying to get the current time after we pipe to the output of MyLog_CL custom log so we get the output of current time with say 'n' rows where 'n' is equal to number of rows of MyLog_CL custom log output.

MyLog_CL | project now()





$
如果您的要求仍然需要我们管道输出MyLog_CL自定义日志之后的当前时间,如果您希望它只显示当前时间一次,那么下面会查询一次。






If your requirement is still to get the current time after we pipe to the output of MyLog_CL custom log and if you want it to display the current time only once then below one would be query for that.

MyLog_CL | project now() | limit 1





但是我觉得上面解释的最后2个查询和他们的用例实际上并不是在实时场景中使用。



可能对您有用的参考文献如下:

now() - > https://docs.microsoft.com/en-us/azure/kusto/query/scalar-data-types/datetime



But I feel the above explained last 2 queries and their use cases are not really of any use in realtime scenarios.

References that might be of use for you are listed below:
now() -> https://docs.microsoft.com/en-us/azure/kusto/query/scalar-data-types/datetime

SQL到Kusto备忘单 - > https://docs.microsoft.com/en-us/azure/kusto/query/sqlcheatsheet

SQL to Kusto cheat sheet -> https://docs.microsoft.com/en-us/azure/kusto/query/sqlcheatsheet

sort - > https://docs.microsoft.com/en-us/azure/kusto/query/sortoperator

sort -> https://docs.microsoft.com/en-us/azure/kusto/query/sortoperator

limit - > https://docs.microsoft.com/en-us/azure/kusto/query/limitoperator

limit -> https://docs.microsoft.com/en-us/azure/kusto/query/limitoperator

项目 - > https://docs.microsoft.com/en-us/azure/kusto/query/projectoperator

project -> https://docs.microsoft.com/en-us/azure/kusto/query/projectoperator



希望这会有所帮助!!


Hope this helps!!

注意:如果您认为您的问题已被解答,请点击"标记为答案",如果只是帮助,请点击"投票为有用"。
这对阅读此论坛帖子的其他社区成员有益。


这篇关于我可以提交天蓝色日志查询来获取当前日期时间吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆