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

标签 azure azure-log-analytics azure-data-explorer azure-application-gateway kql

我想查看过去 x 天的应用网关 500 错误日志。但对于这 x 天,我只想查看 UTC 时间 11:00 到 13:00 之间出现的日志。我怎样才能做到这一点?这是我到目前为止所拥有的,但它不起作用。

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)

显然第二个(Time generated)是错误的。有人可以建议如何做到这一点吗?

谢谢!

最佳答案

您可以使用hourofday():https://learn.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)

关于Azure Log Analytics - 如何查看最近 x 天但仅在特定时间之间的日志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65257311/

相关文章:

azure - 断开 Azure VM 与 loganalytics 工作区的连接

azure - 无法解析名为 'SecurityEvent' 的表或列表达式

azure-data-explorer - 当变量在范围内时,它仍然不引用任何已知的列、表、变量或函数

azure - Azure 表存储中未指定 PartitionKey

asp.net - Web 配置转换不适用于 Visual Studio Online、VS2013 和 Azure

使用 Azure Function 的 Azure 应用程序见解。调试日志未显示

azure-data-explorer - 库斯托 : Projecting all columns as string

azure - 如何使用 PowerShell(az 模块)部署到 Azure 应用服务?

sql - Azure SQL 数据库在本地运行时可以工作,但在发布到 Azure 时则无法工作

azure - 库斯托 : make-series stops with first day - doesnt work as expected