来自 Azure Application Insights Analytics API 的页面结果

2024-06-19

是否可以对 Analytics API 的结果进行“分页”?

如果我使用以下查询(通过http POST)

{
 "query":"customEvents | project customDimensions.FilePath, timestamp 
         | where timestamp > now(-100d) | order by timestamp desc | limit 25"
}

我在一个结果集中最多返回 10,000 个结果。有什么方法可以使用类似于事件 API 的 $skip 的东西吗?例如“SKIP 75 TAKE 25”或其他获得第 4 页结果的内容。


[编辑:这个答案现在已经过时了,已经有一个row_number函数添加到查询语言中。如果有人遇到类似于此答案的奇怪查询,则此答案将用于历史目的]

Not easily.

如果可以使用 /events ODATA 查询路径而不是 /query 路径,则支持分页。但不是像您那样真正的自定义查询。

要获得诸如分页之类的功能,您需要进行复杂的查询,并使用summarize and makeList并发明了一个rowNum查询中的字段,然后使用mvexpand重新展开列表,然后按rowNum。它非常复杂且不直观,例如:

customEvents 
| project customDimensions.FilePath, timestamp 
| where timestamp > now(-100d) 
| order by timestamp desc 
// squishes things down to 1 row where each column is huge list of values
| summarize filePath=makelist(customDimensions.FilePath, 1000000)
    , timestamp=makelist(timestamp, 1000000)
    // make up a row number, not sure this part is correct
    , rowNum = range(1,count(strcat(filePath,timestamp)),1)
// expands the single rows into real rows
| mvexpand filePath,timestamp,rowNum limit 1000000
| where rowNum > 0 and rowNum <= 100 // you'd change these values to page

我相信 appinsights uservoice 已经请求支持查询语言中的分页运算符。

这里的另一个假设是数据没有改变当您工作时在底层表中。如果出现新数据在您的通话之间, like

  1. 给我 0-99 行
  2. 出现 50 个新行
  3. 给我第 100-199 行

那么第 3 步是actually返回您在步骤 1 中刚刚获得的 50 个重复行。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

来自 Azure Application Insights Analytics API 的页面结果 的相关文章

随机推荐