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
}