window.avg
다음에서 지원:
window.avg(numeric_values [, should_ignore_zero_values])
설명
입력 값(정수 또는 부동 소수점일 수 있음)의 평균을 반환합니다. 선택사항인 두 번째 인수를 true로 설정하면 0 값은 무시됩니다.
매개변수 데이터 유형
INT|FLOAT
반환 유형
FLOAT
코드 샘플
예 1
이 예시에서는 정수 평균을 보여줍니다.
// This rule sets the outcome $size_mode to the average
// file size in the 5 minute match window.
events:
$e.user.userid = $userid
match:
$userid over 5m
outcome:
$size_mode = window.avg($e.file.size) // yields 2.5 if the event file size values in the match window are 1, 2, 3 and 4
예 2
이 예시에서는 부동 소수점 평균을 보여줍니다.
events:
$e.user.userid = $userid
match:
$userid over 5m
outcome:
$size_mode = window.avg($e.file.size) // yields 1.75 if the event file size values in the match window are 1.1 and 2.4
예시 3
음수 입력 평균
events:
$e.user.userid = $userid
match:
$userid over 5m
outcome:
$size_mode = window.avg($e.file.size) // yields 0.6 if the event file size values in the match window are -1.1, 1.1, 0.0 and 2.4
예 4
0은 0을 반환
events:
$e.user.userid = $userid
match:
$userid over 5m
outcome:
$size_mode = window.avg($e.file.size) // yields 0 if the event file size values in the match window is 0
예시 5
0 값 무시
events:
$e.user.userid = $userid
match:
$userid over 5m
outcome:
$size_mode = window.avg($e.file.size, true) // yields 394 if the event file size values in the match window are 0, 0, 0 and 394