window.last

支援的國家/地區:
window.last(values_to_sort_by, values_to_return)

說明

這項匯總函式會傳回字串值,該值衍生自相符時間範圍內相關性最高的整數值事件。舉例來說,您可以在比對視窗中,從時間戳記最低 (時間戳記最高) 的事件取得使用者 ID。

參數資料類型

INT、STRING

傳回類型

STRING

程式碼範例

在比對時間範圍內,從相關性最高的事件衍生字串值。

rule test_windows_last {

// This rule sets the outcome $last_event to the highest correlated int value
// in the 5 minute match window.

  meta:

  events:
    $e.principal.user.userid = $userid

  match:
    $userid over 5m

  outcome:
    $last_event = window.last($e.metadata.event_timestamp.seconds, 
    $e.metadata.vendor_name)
    // yields v3 if the events in the match window are 1, 2 and 3 and 
    // corresponding values v1, v2, and v3.

  condition:
    $e
}