Azure Log Analytics - 如何查看最近 x 天但仅在特定时间之间的日志?

Azure Log Analytics - How to view logs from last x days but only between certain hours?

我想查看过去 x 天的应用程序网关 500 错误日志。但是对于那 x 天,我只想查看 11:00 和 13:00 UTC 之间的日志。我怎样才能做到这一点?这是我目前所拥有的,但它没有用。

AzureDiagnostics
| where TimeGenerated > ago(7d) and TimeGenerated between (datetime(11:00:00) .. datetime(13:00:00))
| where ResourceType == "APPLICATIONGATEWAYS" and httpStatus_d > 499
| where host_s == "my.website.com"
| summarize count() by clientIP_s, bin(TimeGenerated, 5m)

显然第二个赞(Timegenerated)是错误的。有人可以建议如何执行此操作吗?

谢谢!

您可以使用 hourofday()https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/hourofdayfunction

例如:

AzureDiagnostics
| where TimeGenerated > ago(7d)
| where hourofday(TimeGenerated) between (11 .. 12) // 11:00 AM -> 12:59 PM
| where host_s == "my.website.com"
| where ResourceType == "APPLICATIONGATEWAYS"
| where httpStatus_d > 499
| summarize count() by clientIP_s, bin(TimeGenerated, 5m)