avg

avg 函式會傳回數值欄中的平均值。計算時會忽略 NULL 值。這項函式通常會與 match 搭配使用,計算資料中特定群組的平均值。

語法 參數資料類型 傳回類型
avg(numericExpression) NUMBER NUMBER

程式碼範例

  • 找出 target.ip 不為空白的所有事件。針對所有符合 principal.ip 的事件,將 metadata.event_timestamp.seconds 的平均值儲存在名為 avg_seconds 的變數中。

    target.ip != ""
    match:
      principal.ip
    outcome:
      $avg_seconds = avg(metadata.event_timestamp.seconds)