Kusto 查询包含运算符不适用于转义字符
Kusto Query Contains Operator Does Not Work With Escape Characters
我正在使用 Azure Monitor 日志从应用见解中查询页面视图。对 customDimensions 字段执行 Kusto 查询时,以下不会 return 任何结果:
pageViews
| where customDimensions contains "\"qa\""
自定义维度的值包含类似这样的内容 {"Environemnt": "qa"}。我错过了什么吗?我试过不使用转义字符,只使用“"qa"”,但它仍然不起作用。如果我只尝试 'qa' 结果 return。
好吧,任何有兴趣的人都可以改用正则表达式:
customDimensions matches regex '"qa"'
我通过两次转义解决了这个问题
我 运行 在尝试查询名称为 'total' 或名称不包含反斜杠的所有行时遇到了这个问题。
首先,我通过 Azure Data Explorer Web UI 编写了查询,发现以下返回了我想要的结果:
CodeCoverage | where name == "total" or name !contains "\"
当我检查 Chrome 的网络日志中的网络请求时,我看到请求的正文包含完全相同的字符串:CodeCoverage | where name == "total" or name !contains "\"
.
当我通过 REST API 将其复制到我的 JavaScript 和 运行 查询中时,请求返回了 400 状态代码(错误请求),并附有一条错误消息告诉我有语法错误。发生这种情况是因为查询缺少反斜杠:MyTable | where name == "total" or name !contains "\"
。转义转义了第二个 "
而第一个 "
没有匹配。语法无效。因此 400 状态代码。
两次反斜杠转义后查询成功,请求返回200:
MyTable | where name == "total" or name !contains "\\"
.
您可以尝试 Verbatim 字符串文字
像这样
用双引号 (") 括起来:@"This is a verbatim string literal
以反斜杠结尾
用单引号 (') 括起来:@'This is a verbatim string literal
以反斜杠结尾'
这里是post
我正在使用 Azure Monitor 日志从应用见解中查询页面视图。对 customDimensions 字段执行 Kusto 查询时,以下不会 return 任何结果:
pageViews
| where customDimensions contains "\"qa\""
自定义维度的值包含类似这样的内容 {"Environemnt": "qa"}。我错过了什么吗?我试过不使用转义字符,只使用“"qa"”,但它仍然不起作用。如果我只尝试 'qa' 结果 return。
好吧,任何有兴趣的人都可以改用正则表达式:
customDimensions matches regex '"qa"'
我通过两次转义解决了这个问题
我 运行 在尝试查询名称为 'total' 或名称不包含反斜杠的所有行时遇到了这个问题。
首先,我通过 Azure Data Explorer Web UI 编写了查询,发现以下返回了我想要的结果:
CodeCoverage | where name == "total" or name !contains "\"
当我检查 Chrome 的网络日志中的网络请求时,我看到请求的正文包含完全相同的字符串:CodeCoverage | where name == "total" or name !contains "\"
.
当我通过 REST API 将其复制到我的 JavaScript 和 运行 查询中时,请求返回了 400 状态代码(错误请求),并附有一条错误消息告诉我有语法错误。发生这种情况是因为查询缺少反斜杠:MyTable | where name == "total" or name !contains "\"
。转义转义了第二个 "
而第一个 "
没有匹配。语法无效。因此 400 状态代码。
两次反斜杠转义后查询成功,请求返回200:
MyTable | where name == "total" or name !contains "\\"
.
您可以尝试 Verbatim 字符串文字
像这样
用双引号 (") 括起来:@"This is a verbatim string literal 以反斜杠结尾
用单引号 (') 括起来:@'This is a verbatim string literal
以反斜杠结尾'
这里是post