首页 > 解决方案 > “where”运算符:无法解析名为“timeOffsetMin”的标量表达式

问题描述

我现在转向 Azure、KQL 和 Log Analytics。我正在尝试在我的品尝 Log Analytics 工作区上运行以下查询,但我遇到了这个错误,我无法绕过它。

错误:

'where' operator: failed to resolve scalar expression named 'timeOffsetMin'

询问:

let timeOffsetMin = 7d;
let timeOffsetMax = timeOffsetMin * 2;

AuditLogs | where TimeGenerated > ago(timeOffsetMin) and TimeGenerated < ago(timeOffsetMax);

谢谢您的帮助。

标签: azureazure-log-analyticskql

解决方案


在运行之前突出显示整个查询(在编辑器中)并重新格式化代码解决了我的问题。

询问:

let timeOffsetMin = 7d;
let timeOffsetMax = timeOffsetMin * 2;

AuditLogs
   | where TimeGenerated > ago(timeOffsetMin) and TimeGenerated < ago(timeOffsetMax);

推荐阅读