繁体   English   中英

Azure Application Insights Analytics API的页面结果

[英]Page results from Azure Application Insights Analytics API

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

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

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

我在一个结果集中最多得到10,000个结果。 是否可以使用类似于事件API的$ skip的方式? 例如“跳过75拍25”或获取第4页结果的内容。

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

容易

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

要达到这样的页面,你需要做一个复杂的查询,并使用summarizemakeList和发明一种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用户语音中已经存在支持查询语言中的分页运算符的请求。

这里的另一个假设是,您在工作时基础表中的数据没有更改 如果您的通话之间出现了新数据,例如

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

那么第3步实际上是将您刚在第1步中获得的50行重复归还给您。

现在有一种更正确的方法,使用自上次回答以来添加到查询语言中的新运算符。

这两个运算符是serializerow_number()

serialize可确保数据的形状和顺序与row_number() 一些现有的运算符喜欢order by已经创建序列化的数据。

还有prev()next()运算符,它们可以从序列化结果中的上一行或下一行获取值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM