簡體   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