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
}