vmanomaly 모델 (Models)
이 섹션은 VictoriaMetrics 이상 탐지(vmanomaly)의 Models 컴포넌트를 다루고 서비스를 구성하는 방법을 안내해요.
- vmanomaly는 다양한 내장 모델을 포함해요.
- 커스텀 모델 가이드를 참고해 커스텀 모델을 통합할 수도 있어요.
- 모델에는 다양한 유형과 속성이 있어요. 자세한 내용은 모델 유형 섹션을 참고하세요.
모델은 RAM에 저장하는 대신 디스크에 덤프할 수 있어요(v1.13.0부터). 이 옵션은 추론 속도를 약간 줄이지만 RAM 사용량을 크게 줄이며, 특히 더 큰 구성에서 유용해요. 자세한 내용은 관련 FAQ 섹션을 참고하세요.
모델 구성 섹션은 별칭을 통해 여러 모델을 지원해요(v1.10.0부터). 이전의 평면 모델 섹션은 사용 중단(Deprecated)됐으며 향후 버전에서 제거될 거예요. 구성에 두 섹션이 모두 있으면 vmanomaly는 models:만 사용해요:
models:
model_univariate_1:
class: 'zscore_online'
z_threshold: 2.5
queries: ['query_alias2'] # referencing queries defined in `reader` section
model_multivariate_1:
class: 'temporal_envelope_multivariate'
seasonalities: ['hod_smooth', 'dow_smooth']
provide_series: ['anomaly_score']
# if there is no explicit `queries` arg, then the model will be run on ALL queries found in reader section
# ...
이전 스타일 구성(<1.10.0):
model:
class: "zscore" # or 'model.zscore.ZscoreModel' until v1.13.0
z_threshold: 3.0
# no explicit `queries` arg is provided
# ...
다음과 같이 암시적으로 변환돼요:
models:
default_model: # default model alias, backward compatibility
class: "model.zscore.ZscoreModel"
z_threshold: 3.0
# queries arg is created and propagated with all query aliases found in `queries` arg of `reader` section
queries: ['q1', 'q2', 'q3'] # i.e., if your `queries` in `reader` section has exactly q1, q2, q3 aliases
# ...
출처: 문서
본문
공통 인자 (Common args)
모든 모델이 지원하는 공통 인자는 v1.10.0에 도입됐어요.
모델 수준에서 data_range, detection_direction, min_dev_from_expected 또는 min_rel_dev_from_expected를 구성하는 것은 v1.30.2부터 사용 중단(Deprecated)됐어요. 이러한 안정적인 KPI 정책은 reader.queries. 아래에 속하며, 그 쿼리를 사용하는 모든 단변량 또는 다변량 모델에서 일관되게 유지돼요. 기존 모델 수준 값은 연결된 쿼리가 해당 필드를 정의하지 않을 때 모델 로컬 폴백으로 계속 호환되며, 명시적 쿼리 값이 우선해요.
Queries
queries 인자는 특정 모델을 피팅하고 실행하는 데 사용할 reader 쿼리를 선택해요(v1.10.0부터). 선택된 쿼리가 반환하는 모든 시리즈가 해당 모델에 전달돼요.
queries 인자는 모든 내장 및 커스텀 모델에서 지원돼요.
이 인자는 하위 호환돼요. 명시적 queries 인자가 없으면 구성에 정의된 모델이 reader 섹션에서 발견된 ALL 쿼리에서 실행돼요:
models:
model_alias_1:
# ...
# no explicit `queries` arg is provided
다음과 같이 암시적으로 변환돼요:
models:
model_alias_1:
# ...
# if not set, `queries` arg is created and propagated with all query aliases found in `queries` arg of `reader` section
queries: ['q1', 'q2', 'q3'] # i.e., if your `queries` in `reader` section has exactly q1, q2, q3 aliases
Schedulers
schedulers 인자는 특정 모델을 실행하는 스케줄러를 선택해요(v1.11.0부터).
schedulers 인자는 모든 내장 및 커스텀 모델에서 지원돼요.
이 인자는 하위 호환돼요. 명시적 schedulers 인자가 없으면 구성에 정의된 모델이 scheduler 섹션에서 발견된 ALL 스케줄러에 연결돼요:
models:
model_alias_1:
# ...
# no explicit `schedulers` arg is provided
다음과 같이 암시적으로 변환돼요:
models:
model_alias_1:
# ...
# if not set, `schedulers` arg is created and propagated with all scheduler aliases found in `schedulers` section
schedulers: ['s1', 's2', 's3'] # i.e., if your `schedulers` section has exactly s1, s2, s3 aliases
Provide series
provide_series 인자(v1.12.0부터)는 writer로 보내는 모델 출력을 제한해요. 예를 들어 모델은 기본적으로 ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper']를 생성할 수 있는 반면, 다음 구성은 각 입력 시리즈에 대해 anomaly_score만 써요:
models:
model_alias_1:
# ...
provide_series: ['anomaly_score'] # only `anomaly_score` metric will be available for writing back to the database
모델 구성에서 provide_series를 지정하지 않으면 모델은 기본 모델 의존 출력을 생성해요. 출력은 ['anomaly_score']보다 작을 수 없어요. timestamp 열이 생략되더라도 메트릭을 제대로 쓰는 데 필요하므로 provide_series 목록에 암시적으로 추가돼요.
Detection direction
detection_direction 인자(v1.13.0부터)는 도메인 지식이 기대값보다 위 또는 아래 값만 이상이라고 나타낼 때 오탐(false positive)을 줄일 수 있어요. 사용 가능한 값은 both, above_expected, below_expected예요. 입력 쿼리에 구성하세요. 모델 수준 배치는 v1.30.2부터 사용 중단(Deprecated)됐어요.
세 옵션의 차이는 다음과 같아요:
기본 하위 호환 both 값에서는 이상이 양방향(y > yhat 또는 y < yhat) 모두에서 추적돼요. 필요한 방향을 필터링할 도메인 전문성이 없을 때 유용해요.
above_expected로 설정하면 y > yhat일 때만 이상이 추적돼요.
예시 메트릭: 오류율, 응답 시간, 페이지 로드 시간, 실패한 트랜잭션 수 — 낮은 값이 더 좋은 메트릭이므로 일반적으로 더 높은 값이 추적돼요.
below_expected로 설정하면 y < yhat일 때만 이상이 추적돼요.
예시 메트릭: SLA(서비스 수준 계약) 준수율, 전환율, CSAT(고객 만족도 점수) — 높은 값이 더 좋은 메트릭이므로 일반적으로 더 낮은 값이 추적돼요.
정책이 각 쿼리에 속하므로 한 모델이 방향이 다른 여러 쿼리를 사용할 수 있어요:
reader:
# ...
queries:
query_values_the_lower_the_better:
expr: metricsql_expression1
detection_direction: 'above_expected' # query-level from v1.30.2; only y > yhat can be anomalous
query_values_the_higher_the_better:
expr: metricsql_expression2
detection_direction: 'below_expected' # query-level from v1.30.2; only y
query_values_both_direction_matters:
expr: metricsql_expression3
detection_direction: 'both' # query-level from v1.30.2; the default when omitted
models:
model_all_directions:
class: 'zscore_online'
z_threshold: 3.0
queries: [
'query_values_the_lower_the_better',
'query_values_the_higher_the_better',
'query_values_both_direction_matters',
]
# other components like writer, schedule, monitoring
Minimal deviation from expected
min_dev_from_expected 인자(v1.13.0부터)는 실제 값(y)과 기대값(yhat) 사이의 편차가 상대적으로 큰 시나리오에서 오탐을 줄이도록 설계됐어요. 이러한 편차는 모델이 높은 이상 점수를 생성하게 할 수 있어요. 그러나 비즈니스 관점에서 절대값이 이상으로 간주할 만큼 충분히 크지 않을 수 있어요. 이 매개변수는 |y - yhat| < min_dev_from_expected인 데이터 포인트의 이상 점수가 명시적으로 0으로 설정되도록 보장해요. 기본적으로 이 매개변수를 설정하지 않으면 하위 호환을 위해 0으로 설정돼요. 입력 쿼리에 구성하세요. 모델 수준 배치는 v1.30.2부터 사용 중단(Deprecated)됐어요.
v1.23.0부터 min_dev_from_expected 인자는 두 개의 float 값 목록이 될 수 있어 상한·하한 편차에 별도의 임계값을 허용해요. 이는 허용 편차가 방향마다 다를 때 유용해요(예: min_dev_from_expected: [0.01, 0.02]는 y가 yhat보다 작을 때 하한 0.01, y가 yhat보다 클 때 상한 0.02를 의미). 하나의 값만 제공하면 양방향으로 브로드캐스트돼요. 즉 같은 임계값이 상한·하한 편차 모두에 적용돼요(예: min_dev_from_expected: 0.01은 y가 yhat보다 작을 때 하한 0.01이고 y가 yhat보다 클 때 상한도 0.01).
min_dev_from_expected는 >= 0이어야 해요. 값이 클수록 이상 점수 != 0을 생성하려면 편차가 더 커야 해요. 이는 모니터링되는 메트릭의 맥락에서 의미가 없을 수 있는 작은 절대 편차를 걸러내는 데 도움이 돼요.
예시: 특정 모드의 CPU 사용률이 낮고 0.3%(0.003) 부근에서 진동하는 시나리오를 고려해요. 1.3%(0.013)로 갑자기 급증하면 상대적 기준으로 +333% 증가지만 절대적 기준으로는 +1% 포인트(0.01) 증가에 불과하며, 이는 무시할 만하고 알림이 필요하지 않을 수 있어요. min_dev_from_expected 인자를 0.01(1%)로 설정하면 <= 0.01 편차의 모든 이상 점수가 0으로 설정되도록 보장해요.
아래 시각화는 이 개념을 보여줘요. 좁은 파란색 모델 예측 경계는 더 넓은 초록색 비즈니스 보호 경계 안에 중첩돼 있어요. 예측 경계 밖에 있지만 여전히 [yhat - min_dev_from_expected, yhat + min_dev_from_expected] 안에 있는 실제 값은 anomaly_score = 0을 받고, 초록색 경계 밖의 값만 이상으로 남아요.
이 매개변수를 쿼리 결과에 기반해 사용하는 예시 구성:
# other components like writer, schedulers, monitoring ...
reader:
# ...
queries:
# the usage of min_dev should reduce false positives here
need_to_include_min_dev:
expr: small_abs_values_metricsql_expression
min_dev_from_expected: [5.0, 5.0] # query-level from v1.30.2
# min_dev is not really needed here
normal_behavior:
expr: no_need_to_exclude_small_deviations_metricsql_expression
models:
zscore:
class: 'zscore_online'
z_threshold: 3
queries: ['need_to_include_min_dev', 'normal_behavior']
Minimal relative deviation from expected
v1.29.1부터 min_rel_dev_from_expected 인자는 min_dev_from_expected(위 섹션 참고)와 비슷한 목적을 제공하지만 절대 편차가 아닌 상대 편차에 초점을 맞춰요. 이는 실제 값(y)과 기대값(yhat) 사이의 상대 편차는 크지만 비즈니스 관점에서 절대 편차가 이상으로 간주할 만큼 충분히 크지 않은 시나리오에서 오탐을 줄이도록 설계됐어요. 이 매개변수는 |y - yhat| / |yhat| < min_rel_dev_from_expected인 데이터 포인트의 이상 점수가 명시적으로 0으로 설정되도록 보장해요. 기본적으로 이 매개변수를 설정하지 않으면 하위 호환을 위해 0으로 설정돼요. 입력 쿼리에 구성하세요. 모델 수준 배치는 v1.30.2부터 사용 중단(Deprecated)됐어요.
매개변수는 두 개의 float 값 목록일 수 있어 상한·하한 상대 편차에 별도의 임계값을 허용해요. 하나의 값만 제공하면 양방향으로 브로드캐스트돼요.
min_dev_from_expected 인자와 min_rel_dev_from_expected가 모두 설정되면 모델이 두 필터를 결합해요. 데이터 포인트는 min_dev_from_expected에 정의된 절대 편차 임계값과 min_rel_dev_from_expected에 정의된 상대 편차 임계값을 모두 초과하는 경우에만 이상(즉 이상 점수 != 0)으로 간주돼요. 이는 이상 탐지를 더 세밀하게 제어할 수 있게 해주며, 절대·상대 양쪽 모두에서 의미 있는 편차만 이상으로 플래그되도록 보장해요.
아래 초록색 비즈니스 보호 경계는 |yhat|에 따라 확장되고, 모델 예측 경계는 그 안에 계속 보여요. 파란색 경계 밖이지만 비례하는 초록색 경계 안의 실제 값은 anomaly_score = 0을 받아요.
예시: 보통 사전에 알 수 없는 초당 요청 수(수십에서 수천)를 받는 웹사이트로의 트래픽을 모니터링하는 시나리오를 고려해요. min_dev_from_expected로 절대 편차 임계값을 설정하는 것은 오탐을 줄이는 데 효과적이지 않을 수 있어요. 트래픽의 작은 증가(예: 초당 10개에서 20개로)도 100% 상대 증가를 나타낼 수 있고 이는 해당 웹사이트에 의미가 있을 수 있기 때문이에요. 대신 min_rel_dev_from_expected를 더 작은 상대 값인 20, 40으로 설정하면 트래픽이 초당 10개에서 8개로 감소(20% 감소)하거나 10개에서 14개로 급증(40% 증가)해도 신뢰 구간을 초과하더라도 이상으로 간주되지 않도록 보장해요. 따라서 상대적으로 의미 있는 작은 절대 편차에 대한 오탐을 줄여줘요.
이 매개변수를 구성에서 사용하는 예시:
# other components like writer, schedulers, monitoring ...
reader:
# ...
queries:
# the usage of min_rel_dev should reduce false positives here
need_to_include_min_rel_dev:
expr: small_abs_values_metricsql_expression
min_rel_dev_from_expected: [10, 20] # query-level from v1.30.2
# min_rel_dev is not really needed here
normal_behavior:
expr: no_need_to_exclude_small_deviations_metricsql_expression
models:
zscore:
class: 'zscore_online'
z_threshold: 3
queries: ['need_to_include_min_rel_dev', 'normal_behavior']
Group by
groupby 인자는 다변량 모델과만 함께 작동해요.
groupby 인자(v1.13.0부터, list[string])는 다변량 모델 내에서 논리적 그룹화를 가능하게 해요. 지정하면 groupby 열에 존재하는 라벨 값의 각 고유 조합에 대해 별도의 다변량 모델이 훈련돼요.
예를 들어 서로 다른 엔티티 간 간섭을 피하면서 머신 수준에서 다변량 이상 탐지를 수행하려면 groupby: [host] 또는 groupby: [instance]를 설정할 수 있어요. 이는 각 개별 엔티티(예: 호스트별)에 대해 별도의 다변량 모델이 훈련되도록 보장해요. 아래는 각 호스트의 CPU, RAM, 네트워크 데이터를 사용해 다변량 이상을 추적하는 방법을 보여주는 단순화된 예시예요.
# other config sections ...
reader:
# other reader params ...
# assume there are M unique hosts identified by the `host` label
queries:
# return one timeseries for each CPU mode per host, total = N*M timeseries
cpu:
expr: sum(rate(node_cpu_seconds_total[5m])) by (host, mode)
data_range: [0, 'inf']
detection_direction: both
min_rel_dev_from_expected: [15, 15]
# return one timeseries per host, total = 1*M timeseries
ram:
expr: |
100 * (
1 - node_memory_MemAvailable_bytes
/ node_memory_MemTotal_bytes
)
data_range: [0, 100]
detection_direction: above_expected
min_rel_dev_from_expected: [0, 15]
# return one timeseries per host for both network receive and transmit data, total = 1*M timeseries
network:
expr: |
sum(rate(node_network_receive_bytes_total[5m])) by (host)
+ sum(rate(node_network_transmit_bytes_total[5m])) by (host)
data_range: [0, 'inf']
detection_direction: below_expected
min_rel_dev_from_expected: [20, 0]
models:
envelope: # alias for the model
class: temporal_envelope_multivariate
seasonalities: [hod_smooth, dow_smooth]
provide_series: [anomaly_score]
# the multivariate model can be trained on 2+ timeseries returned by 1+ queries
queries: [cpu, ram, network]
# train a distinct multivariate model for each unique value found in the `host` label
# a single multivariate model will be trained on (N + 1 + 1) timeseries, total = M models
groupby: [host]
v1.30.2부터 다변량 Temporal Envelope는 공동 이상 점수를 집계하기 전에 각 쿼리의 data_range, detection_direction, 최소 상대 편차를 해당 쿼리가 반환한 각 채널에 적용해요. 예시는 각 호스트 모델 내에서 양방향 CPU 편차, 15% 이상의 RAM 증가, 20% 이상의 네트워크 하락을 감지해요.
Scale
이전에는 ProphetModel과 OnlineQuantileModel에만 사용 가능했던 scale 매개변수(v1.20.0부터)는 이제 예측(yhat, yhat_lower, yhat_upper)을 생성하는 모든 모델에 적용돼요. 또한 이제 양면이며 [yhat, yhat_upper]와 [yhat_lower, yhat] 구간을 별도로 확장할 수 있는 두 개의 양수 float 값 목록으로 표현돼요. 새 여백은 다음과 같이 계산돼요:
- 상한 여백: |yhat_upper - yhat| * scale_upper
- 하한 여백: |yhat - yhat_lower| * scale_lower
하위 호환을 위해 이전 형식(scale: x)은 계속 지원되며 자동으로 scale: [x, x]로 변환돼요.
예를 들어 특정 모델에 scale: [1.2, 0.75]를 설정하면:
- 하한 신뢰 구간의 너비를 20% 늘림.
- 상한 신뢰 경계의 너비를 25% 줄임.
가장 일반적인 사용 사례는 이상 점수가 1.0보다 약간만 높아 해당 데이터 포인트를 여전히 이상으로 만드는 더 작은 오탐을 블랙리스트하기 위해 한쪽을 넓히고, 과도하게 느슨한 여백으로 인해 이상 점수가 1.0보다 약간 낮아 그런 데이터 포인트를 비이상으로 만드는 진짜 양성(true positives)을 놓치지 않도록 다른 쪽을 조이는 경우예요.
# other components like reader, writer, schedulers, monitoring ...
models:
zscore_no_scale:
class: 'zscore_online'
z_threshold: 3
# if not set, equals to [1.0, 1.0], meaning no scaling is applied
# scale: [1.0, 1.0]
zscore_scaled:
class: 'zscore_online'
z_threshold: 3
# vs `zscore_no_scale`, increase lower confidence interval width by 1.2x, decrease upper confidence width by 25% (1.0 - 0.25 = 0.75), thus, making the model more conservative in flagging anomalies when y yhat
scale: [1.2, 0.75]
Clip predictions
V머eader의 구성된 data_range 값으로 모델 예측(yhat, yhat_lower, yhat_upper 시리즈)을 자르는 후처리 단계를 사용할 수 있어요.
이 동작은 clip_predictions 불리언 인자(v1.20.0부터)로 제어돼요:
- 하위 호환을 위해 기본적으로 비활성화돼 있어요.
- models 섹션에서 해당 모델에 clip_predictions를 True로 설정해 예측과 추정치를 생성하는 모델(예: ProphetModel)에서 작동해요.
주요 사용 사례는 (data_range로 정의된) 데이터 동작에 대한 도메인 지식을 Grafana 대시보드 같은 시각화에 표시되는 것과 정렬하는 거예요. 이는 예측(yhat, yhat_lower, yhat_upper)이 실제 메트릭 값(y)과 일관되게 표시되고 합리적인 기대 범위 내에 유지되도록 보장해요.
이 매개변수는 y가 정의된 data_range 밖에 있을 때 데이터 포인트에 대해 > 1의 이상 점수 생성에 영향을 주지 않아요.
# other components like writer, schedulers, monitoring ...
reader:
# ...
queries:
q1_clipped:
expr: 'q1_metricsql'
data_range: [0, "inf"]
q2_no_clip:
expr: 'q2_metricsql'
# if no data range defined, it will be implicitly converted to ["-inf", "inf"]
models:
zscore_mixed:
class: 'zscore_online'
z_threshold: 3
clip_predictions: True
queries: [
# `yhat`, `yhat_lower`, `yhat_upper` will be within [0, inf]
# for all `zscore_mixed` instances that are fit on series returned by `q1_clipped` query
# anomaly scores > 1 will still be produced for `y` outside of data_range
'q1_clipped',
# there will be no (explicit) clip of `yhat`, `yhat_lower`, `yhat_upper`
# for all `zscore_mixed` instances that are fit on series returned by `q2_no_clip` query
# even when `clip_predictions` arg is set, because data_range was not set for `q2_no_clip`
'q2_no_clip',
]
zscore_no_clip:
class: 'zscore_online'
z_threshold: 3
# if not set, by default resolved to `clip_predictions: False`
queries: [
# `yhat`, `yhat_lower`, `yhat_upper` won't be clipped to [0, inf]
# even though `data_range` for `q1_clipped` is set
# however, anomaly scores > 1 will still be produced for y outside of data_range
'q1_clipped',
# there will be no (explicit) clip of yhat, yhat_lower, yhat_upper
# for all `zscore_mixed` instances that are fit on series returned by `q2_no_clip` query
# as `clip_predictions` arg is not set, regardless of data_range for `q2_no_clip`
'q2_no_clip',
]
Score outside data range
anomaly_score_outside_data_range 매개변수(v1.20.0부터)는 reader에서 정의된 경우 실제 값(y)이 정의된 data_range 밖에 있을 때 할당되는 기본 이상 점수(1.01)를 덮어쓸 수 있어요. 이는 알림 규칙 구성에 더 큰 유연성을 제공하고 다양한 유형의 이상 간 시각적 차별화를 가능하게 해요:
- 기본적으로 data_range 밖의 y 값은 기본 알림 규칙 역할을 하는 1.01의 이상 점수를 트리거해요.
- 그러나 일부 사용자는 모니터링 설정에서 알림을 안정적으로 트리거하기 위해 더 높은 이상 점수(예: > 1.2)가 필요할 수 있어요.
동작 방식:
- 설정하지 않으면 하위 호환을 위해 기본값(1.01)이 사용돼요.
- 서비스 수준(settings 섹션)에서 정의하면 모델 수준에서 덮어쓰지 않는 한 모든 모델에 적용돼요.
- 모델별로 설정하면 전역 설정보다 우선해요.
예시(덮어쓰기):
settings:
# other parameters ...
# all the models in `models` section will inherit this value unless overridden at the model level
anomaly_score_outside_data_range: 1.2
models:
model_score_override:
class: 'zscore_online'
# explicitly set, takes priority over `settings`'s value
anomaly_score_outside_data_range: 1.5
model_score_from_settings_level:
class: 'zscore_online'
# inherits from `settings`, will be `1.2`, same as setting
# anomaly_score_outside_data_range: 1.2
예시(기본값 vs 커스텀):
models:
model_default_score:
class: 'zscore_online'
# default anomaly score (1.01) is applied when y is outside data_range, same as setting
# anomaly_score_outside_data_range: 1.01
model_higher_out_of_data_range_score:
class: 'zscore_online'
# explicitly set, takes priority over `settings`'s value
anomaly_score_outside_data_range: 3.0
Decay
decay 인자는 ZScoreOnlineModel이나 OnlineQuantileModel 같은 온라인 모델과만 함께 작동해요.
decay 인자(v1.23.0부터)는 온라인 모델의 (지수) 감쇠 계수를 제어하는 데 사용되며, 모델이 새 데이터에 얼마나 빨리 적응하는지를 결정해요. (0.0, 1.0] 구간의 양수 float 값이며:
- 값 1.0은 감쇠가 없음을 의미(모델이 모든 데이터 포인트를 동등하게 취급, 최근 것에 더 많은 가중치를 주지 않음). 하위 호환을 위한 기본값이에요.
- 1.0 미만의 값은 모델이 최근 데이터에 더 많은 가중치를 준다는 것을 의미하며, 시간이 지나면서 오래된 데이터를 효과적으로 "잊어버려요".
대략적으로 최근 N개의 데이터 포인트에 대해 감쇠 d를 처리하는 모델은 이 데이터 포인트들이 [1 - d^N]%의 총 중요도로 기여한다는 뜻이에요. 예를 들어 감쇠:
- 0.99는 최근 100개 데이터 포인트가 [1 - 0.99^100] = 63.23% 총 중요도로 기여함을 의미
- 0.999는 최근 1000개 데이터 포인트가 [1 - 0.999^1000] = 63.23% 총 중요도로 기여함을 의미
예를 들어 모델이 5분마다(scheduler.infer_every) 5개의 1분 데이터 포인트에 대해 업데이트되고 마지막 1일의 데이터를 가장 영향력 있게 유지해야 할 필요가 있다면, decay: 0.996로 설정하면 모델이 마지막 (86400/60) = 1440개 데이터 포인트를 [1 - 0.996^1440] = 99.6% 총 중요도로 기여하도록 보장해요. 매일 모든 1440개 데이터 포인트를 fit_every: 1d로 재훈련하지 않아도 되며(이는 오프라인 모델의 한계), 온라인 모델의 이점이에요.
예시 구성:
# other components like writer, schedulers, monitoring ...
reader:
# ...
queries:
q1: metricsql_expression1
# ...
models:
online_zscore:
class: 'zscore_online'
z_threshold: 3.0
decay: 0.996 # decay factor for online model, default is 1.0
queries: ['q1']
모델 유형 (Model types)
모델은 두 가지 차원으로 분류되어 네 가지 조합이 가능해요:
입력 데이터 처리 방식:
- 단변량(Univariate) 모델 — 각 개별 시계열별로 피팅/사용되며 개별 출력을 생성
- 다변량(Multivariate) 모델 — 시계열 집합에 대해 동시에 피팅/사용되며 공유 출력을 생성
업데이트 전략:
- 오프라인(Offline) 모델 — scheduler의 fit_every 일정으로 정의된 정의된 fit_window 데이터에 대한 전체 재피팅이 필요한 모델
- 온라인(증분, Online) 모델(v1.15.0부터) — fit_window 데이터에 대한 전체 재피팅 없이도 각 infer_every 단계에서 단일 데이터 포인트에서도 매개변수의 증분 업데이트를 지원하는 모델. 이는 VictoriaMetrics나 다른 데이터 소스의 데이터 부담을 줄이는 권장 접근 방식이에요.
단변량 모델 (Univariate Models)
단변량 모델의 경우 선택된 queries가 반환하는 각 시계열에 대해 하나의 별도 모델 인스턴스가 피팅되고 사용돼요.
예를 들어 3개의 MetricsQL 쿼리에 연결된 단변량 모델은 각각 5개의 시계열을 반환하면 15개의 모델 인스턴스를 만들어요. 각 인스턴스는 자체 출력을 생성해요.
추론 중에 피팅된 어떤 모델에도 존재하지 않는 새 라벨셋을 가진 시리즈를 받으면, 다가오는 재피팅 단계에서 그러한 라벨셋에 특별히 훈련된 모델을 얻을 때까지 추론을 건너뜁니다.
의미: 단변량 모델은 쿼리가 크기, 추세 또는 계절성이 다른 개별 시계열의 변화하는 양을 반환할 때 기본 선택지예요. 단일 피팅 모델 안에서 서로 다른 동작을 가진 호환되지 않는 데이터를 섞지 않게 되기 때문이에요(문맥 분리).
예시: Temporal Envelope, Online MAD, Online Z-score, Online Seasonal Quantile.
다변량 모델 (Multivariate Models)
다변량 모델의 경우 선택된 queries가 반환하는 정렬된 모든 시계열에 걸쳐 하나의 공유 모델 인스턴스가 피팅되고 사용돼요.
예를 들어 일부 다변량 모델이 각각 5개의 시계열을 반환하는 3개의 MetricsQL 쿼리를 사용한다면 총 하나의 공유 모델이 생성돼요. 한 번 피팅하면 이 모델은 입력으로 정확히 같은 라벨셋을 가진 정확히 15개의 시계열을 기대해요. 이 모델은 하나의 공유 출력을 생성해요.
v1.30.2부터 다변량 Temporal Envelope와 Isolation Forest는 일치하는 입력 채널을 어떤 순서로든 받아들여요. 채널 집합은 여전히 피팅된 모델과 정확히 일치해야 해요. 누락·추가·중복 채널은 거부되며, 일치하는 집합은 추론이나 온라인 업데이트 전에 학습된 피팅 순서로 복원돼요.
v1.16.0부터 groupby 공통 인자에 지정된 라벨 값의 N개 고유 조합 각각에 대해 N개의 모델을 훈련할 수 있어요. 이는 문맥 분리(예: 호스트, 리전 또는 다른 관련 그룹화 라벨당 하나의 모델)를 가능하게 해 정확도를 개선하고 훈련을 더 빠르게 해요. 예시는 여기를 참고하세요.
추론 중에 다른 양의 시리즈나 피팅된 어떤 모델에도 존재하지 않는 새 라벨셋을 가진 일부 시리즈를 받으면, 다가오는 재피팅 단계에서 그러한 라벨셋에 특별히 훈련된 모델을 얻을 때까지 추론을 건너뜁니다.
의미: 다변량 모델은 쿼리가 고정된 양의 개별 시계열(예: 일부 집계)을 반환할 때 기본 선택지예요. 시리즈 간(그리고 쿼리 간) 문맥을 추가해 집단 이상(collective anomalies)이나 새로운 패턴(다중 입력 시나리오로 확장)을 잡는 데 유용해요. 예를 들어 서로 다른 모드(idle, user, system 등)의 CPU 사용률 이상 탐지에 설정하고 그 교차 의존성을 사용해 (피팅 데이터에서 보지 못한) 동작을 감지할 수 있어요.
권장: Temporal Envelope. 기존 Isolation Forest 구성은 다변량 형태로 마이그레이션할 수 있어요.
다음 구성은 같은 정렬된 입력 시리즈에 다변량 Temporal Envelope 모델을 적용해요:
models:
service_dependency_envelope:
class: temporal_envelope_multivariate
queries: [request_rate, error_rate, latency]
groupby: [cluster]
dependency_rank: 8
score_aggregation: l2
seasonalities: [hod_smooth, dow_smooth]
provide_series: [anomaly_score]
온라인 모델 (Online Models)
온라인 모델은 상태 저장(stateful) 서비스(v1.24.0부터)와 함께 사용하는 것이 가장 좋아요. 그러면 서비스가 재시작해도 모델 상태가 보존되고 집계된 모델 업데이트가 손실되지 않도록 보장해요. 예를 들어 모델이 이미 수 주 분량의 데이터로 훈련됐고 매분 새 데이터 포인트로 업데이트되고 있다면, 각 재시작 후 같은 데이터로 처음부터 다시 훈련할 필요 없이 복원된 상태를 새 데이터 포인트로 계속 업데이트할 수 있어요. 또한 보존 정책(retention policy)(v1.28.1부터)을 설정해 입력 데이터의 고유 라벨셋 변동률이 높은 경우 등 오래된 아티팩트를 주기적으로 정리하는 것이 좋아요.
온라인(증분) 모델(v1.15.0부터)은 더 작은 프레임 fit_window와 덜 빈번한 fit 호출을 정의해 VictoriaMetrics의 데이터 부담을 줄여줘요. 각 infer_every 호출 동안 단일 데이터 포인트에서도 모델 매개변수를 증분 업데이트해요.
모델이 온라인 모드를 지원하지 않으면 오프라인이라고 불러요(매개변수는 fit 호출 중에만 업데이트돼요).
오프라인과 온라인의 주요 차이:
Fit 단계:
- 두 유형 모두 fit_window 데이터 프레임에서 실행되는 fit 단계가 있어요.
- 오프라인 모델의 경우 fit_window가 모델 훈련에 충분한 데이터(예: 2개의 계절 기간)를 포함해야 해요.
- 온라인 모델의 경우 더 작은 청크(예: 1시간)에서 점진적으로 훈련을 시작할 수 있어요.
Infer 단계:
- 두 유형 모두 이전 infer 호출의 마지막으로 본 타임스탬프보다 새로운 데이터 포인트에 실행되는 infer 단계가 있어요.
- 오프라인 모델은 (fit 호출 중에) 사전 훈련된 정적 모델을 사용해 모델이 완전히 재훈련되는 다음 fit 호출까지 매 infer 호출을 수행해요.
- 온라인 모델은 (fit 호출 중에) 사전 훈련된 동적 모델을 사용하며, 각 infer 호출 중에 새 데이터 포인트로 점진적으로 업데이트돼요. 그러나 모델이 오래된 동작을 축적하지 않도록 각 fit 호출은 모델을 처음부터 재설정해요.
장점:
- 초기 fit과 이후 infer 호출 사이에 데이터 처리를 분산할 수 있는 능력. 예를 들어 모델은 10개의 1분 샘플로 시작한 다음 큰 fit 창을 반복적으로 가져오는 대신 각 새 10개 샘플 청크에서 업데이트할 수 있어요.
- 모델이 다음 fit 호출과 한 번의 큰 재훈련을 기다릴 필요 없이 새 데이터 패턴에 적응할 수 있음(각 infer 호출 중에 점진적으로 자기 업데이트).
- 유사한 오프라인 모델보다 훈련/업데이트 시간이 약간 더 빠름.
- 데이터 중심 설정의 추가 이점은 해당 FAQ 섹션을 참고하세요.
한계:
- 온라인 모델이 충분한 데이터를 볼 때까지(특히 데이터가 강한 계절성을 보일 때) 예측이 불안정할 수 있으며, 더 많은 오탐(anomaly_score > 1)을 생성하거나 실제 이상을 건너뛰는 오탐적 예측을 할 수 있어요.
각 (내장 또는 커스텀) 온라인 모델(예: OnlineZscoreModel)은 다음 공통 매개변수와 속성을 공유해요:
- n_samples_seen_ (int) — 모델이 훈련된 데이터 포인트 수를 나타내는 모델 속성. 첫 번째 fit 전 0에서 시작해 각 연속 infer 호출로 증가해요.
- min_n_samples_seen (int), 선택 — 모델이 비-중립 이상 점수를 내보내기 전에 필요한 최소 샘플 수. 그 전까지는 이상 점수가 0이에요. 예를 들어 288개 샘플은 5분 샘플링 간격으로 하루를 커버해요.
오프라인 모델 (Offline models)
온라인이 아닌 다른 모든 모델이에요. 오프라인 모델은 fit 호출 중에 완전히 재훈련되며 연속 infer 호출 중에는 업데이트되지 않아요.
내장 오프라인 모델 클래스는 온라인 대응 모델을 위해 향후 릴리스에서 사용 중단(Deprecated)될 예정이에요. 복잡한 시계열 데이터에는 증분 적응, 예측, 단·다변량 동작을 지원하는 Temporal Envelope를 선호하세요.
내장 모델 (Built-in Models)
개요 (Overview)
내장 모델은 2가지 인자 그룹을 지원해요:
- 모델별 인자 — 각 모델의 아래 접힌 "모델별 인자(Model-specific arguments)" 섹션을 참고하세요.
- 내부 모델(예: Facebook의 Prophet)에 대한 인자 — args 인자 안에 키-값 쌍으로 전달되며, 세밀한 제어를 위해 초기화 중에 모델에 직접 주어져요. 선택 사항.
list[dict] 같은 Python 데이터 타입에 익숙하지 않은 사용자를 위해: Python의 dictionary는 데이터 값을 키-값 쌍으로 저장하는 데이터 구조예요. 이 구조는 효율적인 데이터 검색과 관리를 가능하게 해요.
모델:
- AutoTuned — 사용자의 인지 부담을 줄이도록 설계. 알고리즘의 각 fit 단계에서 볼 수 있는 데이터에 대해 아래 내장 모델 중 하나를 최적의 하이퍼파라미터로 재조정할 수 있게 해줘요. 증가된 계산 시간과 최적화된 결과/더 간단한 유지보수 사이의 트레이드오프.
- Temporal Envelope — 추세, 변경점, 여러 캘린더 패턴, 휴일이 있는 복잡한 운영 데이터에 선호되는 온라인 모델이며 예측이 가능해요. 다변량 형태는 시리즈 간 관계도 학습해요.
- Online Z-score — 초기 테스트와 더 단순한 데이터(엄격한 계절성 없는 추세 제거된 데이터와 "정상" 데이터와 비슷한 크기의 이상)에 유용.
- MAD — Z-score와 유사하게 비교적 일관된 데이터의 이상치 식별에 효과적. 중앙값에서 갑작스럽고 뚜렷한 이탈을 감지하는 데 유용하며, 이상치의 크기에 덜 민감.
- Rolling Quantile — 진화하는 패턴이 있는 데이터에 가장 적합. 롤링 창에 걸쳐 변화에 적응.
- Online Seasonal Quantile — 강한(잠재적으로 여러) 계절성이 있는 추세 제거된 데이터에 가장 적합. ProphetModel의 (약간 덜 강력한) 온라인 대체물 역할을 할 수 있어요.
- Seasonal Trend Decomposition — Holt-Winters와 유사하게 뚜렷한 계절 및 추세 구성요소가 있는 데이터에 가장 적합.
- Prophet — 기존 배포를 위해 유지되는 오프라인 모델. Prophet 특유의 분해 출력을 보존해야 하는 경우가 아니면 예측과 계절 이상 탐지 구성을 Temporal Envelope로 마이그레이션하세요.
- Isolation forest (Multivariate) — 기존 단변량·다변량 배포를 위해 유지되는 오프라인 모델. 온라인 적응과 시간적 또는 시리즈 간 문맥을 위해 해당 Temporal Envelope 형태로 마이그레이션하세요.
- Holt-Winters — 기존 추세 및 단일 계절성 구성용으로 유지되는 오프라인 모델. 이 구성을 Temporal Envelope로 마이그레이션하세요.
- Custom model — 고유한 사용 사례를 더 잘 지원하기 위해 자신의 모델과 전문성을 활용.
AutoTuned
모델 하이퍼파라미터를 선택하려면 모델과 데이터 모두에 대한 상세한 지식이 필요할 수 있어요. AutoTunedModel 래퍼는 각 fit 중에 지원되는 매개변수를 검색해요. 최소한 tuned_model_class와 optimization_params.anomaly_percentage를 통한 이상 관측치의 예상 상한을 구성하세요.
1개보다 많은 시계열을 반환하는 쿼리에서 tuned_model_class에 autotune을 사용하면 각 고유 라벨셋에 대해 하나의 모델이 생성되며, 각각에 대해 아마 다른 하이퍼파라미터가 발견돼요. 이는 tuned_model_class를 직접 사용하는 것과 대비해 추가 문맥 분리에 유용해요. 직접 사용하면 쿼리가 반환하는 시계열 수와 같은 수의 모델이 생기지만 각각에 대해 같은 하이퍼파라미터가 적용돼요. 예:
models:
# this may result in 1 model per each unique labelset with different hyperparameters, such as z_threshold
autotuned_model:
class: 'auto'
tuned_class_name: 'zscore_online'
optimization_params:
anomaly_percentage: 0.01
queries: ['your_query']
는 your_query 결과에서 발견된 각 고유 라벨셋에 대해 하나의 모델을 생성하며 z_threshold 같은 서로 다른 하이퍼파라미터를 갖지만,
models:
# this will result in 1 model per each timeseries returned by the query,
# with the same hyperparameters, such as z_threshold
zscore_model:
class: 'zscore_online'
z_threshold: 3 # all models will have the same z_threshold, but different parameters, such as mean, std, etc.
queries: ['your_query']
는 your_query가 반환하는 각 시계열에 대해 하나의 모델을 생성하며, z_threshold 같은 같은 하이퍼파라미터를 갖지만 mean, std 등 다른 매개변수를 가져요.
모델별 인자:
- class (string): 모델 클래스 이름 "model.auto.AutoTunedModel"(또는 클래스 별칭 지원, v1.13.0부터,
auto) - tuned_class_name (string): 래핑할 내장 모델 클래스. 즉 zscore_online
- optimization_params (dict): 비지도 모델 튜닝을 위한 최적화 매개변수. 발견된 이상의 백분율과 시간 소요/정확도 간 트레이드오프를 제어해요. timeout과 n_trials가 높을수록 tuned_class_name에 대해 더 나은 모델 구성을 찾을 수 있지만 시간이 더 걸리고 그 반대도 마찬가지예요. n_jobs를 -1로 설정하면 사용 가능한 모든 CPU를 사용해요. fit 호출 중 훈련할 큰 데이터셋이 있을 때만 합리적이며, 그렇지 않으면 오버헤드가 가치가 없어요.
- anomaly_percentage (float): 훈련 데이터에서 볼 수 있는 예상 이상 백분율, [0, 0.5) 구간. 즉 0.01은 훈련 데이터에 약 1%의 이상이 존재할 것으로 예상됨을 의미. 필수 매개변수.
- optimized_business_params (list[string]): v1.15.0부터. 모델 수준 비즈니스 매개변수의 실험적 최적화는 v1.30.2부터 사용 중단(Deprecated)됐어요. 이 목록을 비워두고 대신 reader.queries.에서 안정적인 detection_direction, min_dev_from_expected, min_rel_dev_from_expected 정책을 구성하세요.
- seed (int): 기반 최적화의 재현성과 결정성을 위한 랜덤 시드.
- validation_scheme (string): v1.25.1부터. 하이퍼파라미터 튜닝에 사용할 검증 방식.
regular(시간 기반 기본값) 또는leaky(각 폴드가 데이터의 시간 기반 분할인 n_splits 폴드가 있는 일반 교차 검증). leaky 방식은 anomaly_percentage ~ 0%일 때 권장되며, 최적화 과정 중 모델이 모든 데이터 포인트를 적어도 한 번 "볼 수" 있어 그러한 경우 더 나은 결과로 이어질 수 있어요. 기본값 regular. - n_splits (int): 데이터에서 하이퍼파라미터 튜닝용 폴드를 몇 개 만들지. 높을수록 시간이 더 걸리지만 결과는 더 좋아질 수 있어요. 기본값 3.
- train_val_ratio (float): v1.25.1부터. 폴드를 구성할 때 훈련 대 검증 데이터 크기의 비율. 예를 들어 2로 설정하면 각 분할에서 데이터의 2/3가 훈련에, 1/3이 검증에 사용돼요. 기본값 3(데이터의 3/4 훈련, 1/4 검증). validation_scheme이 leaky로 설정되면 사용되지 않아요.
- n_trials (int): 하이퍼파라미터 검색 공간에서 샘플링할 시행 수. 높을수록 시간이 더 걸리지만 결과는 더 좋아질 수 있어요. 기본값 128.
- timeout (float): 각 모델의 하이퍼파라미터 튜닝에 총 몇 초를 소요할 수 있는지. 높을수록 시간이 더 걸리며 정의된 n_trials에서 더 많은 시행을 테스트할 수 있지만 결과는 더 좋아질 수 있어요.
- exact (boolean): v1.30.0부터. 검증 중에 온라인 모델을 인과적으로 평가: 현재 상태에서 예측한 다음 새로 관측된 데이터로 업데이트. 프로덕션이 정확한 온라인 추론을 사용할 때 true로 설정. 하위 호환을 위해 기본값 false.
- optimize_complexity (boolean): v1.30.0부터. 검증 품질이 효과적으로 동률일 때 더 작은 피팅 모델 상태를 선호. 기본값 true.
- frozen_params (dict): v1.30.0부터. 나머지 검색 공간이 튜닝되는 동안 고정된 상태를 유지해야 하는 모델별 매개변수. 중첩 사전은 재귀적으로 병합돼요. 구성된 휴일이나 다변량 groupby 같은 비최적화 문맥에 사용하세요. class는 고정할 수 없어요.
구성 예시:
# ...
models:
your_desired_alias_for_a_model:
class: 'auto' # or 'model.auto.AutoTunedModel' until v1.13.0
tuned_class_name: 'zscore_online'
optimization_params:
anomaly_percentage: 0.004 # required. i.e. we expect
seed: 42 # fix reproducibility & determinism
n_splits: 3 # how much folds are created for internal cross-validation
validation_scheme: 'regular' # either 'regular' (time-based default) or 'leaky' (cross-validation with n_splits folds)
train_val_ratio: 3 # how much training data to use in each fold vs validation, e.g. 3 means 3/4 of the data for fit and 1/4 for infer
n_trials: 128 # how many configurations to sample from search space during optimization
timeout: 10 # how many seconds to spend on optimization for each trained model during `fit` phase call
n_jobs: 1 # how many jobs in parallel to launch. Consider making it > 1 only if you have fit window containing > 10000 datapoints for each series
optimized_business_params: [] # business-specific params to include in optimization, if not set - defaults to empty list, meaning no business params will be optimized, which is a recommended option as business arguments are better set by stakeholders rather than algorithms
exact: true # causally validate online models the same way they run in production
optimize_complexity: true # prefer smaller fitted state when quality is tied
frozen_params:
history_strength: 2
# ...
공유 비동기 autotune 워크플로
v1.30.0부터 에이전트, UI, 외부 자동화는 프로덕션 구성에 auto 래퍼를 추가하지 않고 쿼리 결과의 경계 샘플에 걸쳐 하나의 공유 구성을 튜닝할 수 있어요:
GET /api/v1/timeseries/characteristics로 쿼리를 검사해 추세, 캘린더 계절성, 변경점, 갭, 간헐적 동작을 식별.POST /api/v1/autotune/tasks로 작업 시작. 실제 쿼리(또는 명명된 쿼리), 후보 모델 클래스, 프로덕션에서 사용한 것과 동일한 쿼리 step, 경계 제한을 제공.GET /api/v1/autotune/tasks/{task_id}를 status가 done이 될 때까지 폴링. 불필요한 작업은 같은 경로에서 DELETE로 취소.- result_data.data.modelConfig를 검증하고 배포. 이는 선택된 모델 클래스에 대한 구체적인 구성이에요.
위 워크플로가 자동화된 곳에서는 스킬을 사용하세요. 또한 AI Copilot은 쿼리 데이터 특성과 사용자의 이상 기대를 기반으로 UI에서 대화형 백테스트할 튜닝된 모델 구성을 생성할 수 있어요.
아래 예시는 POST /api/v1/autotune/tasks용 JSON 본문이에요. 예시 datasource_url을 vmanomaly에서 접근 가능한 주소로 바꾸고 start와 end(Unix 초)를 데이터에 맞게 조정하세요. 예시는 2026-08-10 00:00 UTC부터 2026-09-09 00:00 UTC까지를 선택해요. 실행 중인 버전의 요청 스키마는 서버의 대화형 API 참조를 참고하세요.
단변량 온라인 모델 예시:
{
"datasource_url": "http://victoriametrics:8428",
"start": 1786320000,
"end": 1788912000,
"query": "sum(rate(http_requests_total[5m])) by (service)",
"tuned_class_name": "temporal_envelope",
"anomaly_percentage": 0.01,
"step": "5m",
"limit": 100,
"use_profile_hints": true,
"optimization_params": {
"exact": true,
"n_splits": 3,
"n_trials": 64,
"timeout": 60,
"optimize_complexity": true
},
"frozen_params": {
"holidays": {
"countries": [
"US"
],
"group": true
}
}
}
그룹화가 있는 다변량 명명 쿼리 예시(v1.30.5부터): 요청율과 오류율을 공동으로 튜닝하고 서비스별 하나의 다변량 입력 그룹을 사용해요. 두 표현식 모두 연구에 포함된 모든 서비스에 대한 데이터를 반환해야 해요. 오류 시리즈가 없으면 자동으로 0으로 처리되지 않아요.
{
"datasource_url": "http://victoriametrics:8428",
"start": 1786320000,
"end": 1788912000,
"queries": {
"request_rate": {
"expr": "sum by (service) (rate(http_requests_total{service!=\"\"}[5m]))",
"data_range": [
0,
"inf"
]
},
"error_rate": {
"expr": "sum by (service) (rate(http_requests_total{service!=\"\",status=~\"5..\"}[5m]))",
"data_range": [
0,
"inf"
],
"detection_direction": "above_expected"
}
},
"tuned_class_name": "temporal_envelope_multivariate",
"anomaly_percentage": 0.01,
"step": "5m",
"limit": 100,
"optimization_params": {
"exact": true,
"n_splits": 3,
"n_trials": 64,
"timeout": 60,
"optimize_complexity": true
},
"frozen_params": {
"groupby": [
"service"
],
"score_aggregation": "l2"
}
}
각 후보 구성에 대해 서버는 정렬된 서비스 그룹에 대해 별도의 모델을 피팅하고 검증하며 한 연구에서 검증 점수를 집계해요. 결과는 모든 그룹에 대한 하나의 공유 모델 구성이에요. frozen_params.groupby는 그룹화를 고정으로 유지하고, 명명된 쿼리는 개별 비즈니스 정책을 유지해요. limit는 각 표현식에 별도로 적용되므로 의도된 그룹에 필요한 모든 채널을 유지하기에 충분히 크게 해야 해요.
요청된 이상 백분율은 모든 검증 폴드에서 반드시 달성해야 하는 목표가 아니라 알림 볼륨 제약으로 취급돼요. 모델별 검색 범위는 샘플링된 특성으로 좁힐 수 있으며, frozen_params는 운영자가 제공한 문맥을 보존해요. 온라인 모델의 경우 프로덕션 추론이 인과적일 때 exact: true가 보통 가장 대표적인 선택을 줘요.
Autotune 모드의 예상 한계가 있어요:
- 커스텀 모델에는 적용할 수 없어요.
- 자체에는 적용할 수 없어요(예: tuned_class_name: 'model.auto.AutoTunedModel').
Temporal Envelope
v1.30.0부터 Temporal Envelope는 복잡한 운영·비즈니스 메트릭에 선호되는 온라인 모델이에요. 강력한 추세, 캘린더 및 휴일 패턴, 지속적인 수준 이동, 불확실성, 선택적 미래 예측에서 진화하는 기대 범위를 학습해요. 모델은 추론 중에 적응하면서 단기 스파이크의 지속적 영향은 제한해요.
fit 창이 최근에 확립된 수준에서 끝나면(v1.30.1부터) 모델은 지원되는 캘린더 구조를 보존하면서 그 최근 체제에서 적응 상태를 초기화해요. 이는 수준 이동 후 첫 주기적 예측을 개선하고 추가 구성 없이 거짓 계절 진동을 줄여요.
TemporalEnvelopeModel은 단변량이며 온라인이에요. TemporalEnvelopeMultivariateModel은 다변량 모델로 정상적인 시리즈 간 관계도 학습해요.
다음에 사용하세요:
- 추세와 일별·주별·월별 또는 휴일 동작이 있는 인프라, 애플리케이션 또는 비즈니스 메트릭;
- 지속적인 이동을 만드는 배포, 트래픽 마이그레이션, 용량 변경 — forecast_at를 통한 단기 예측 포함;
- 각 채널이 자신의 시간적 패턴을 유지하면서 공동 동작이 하나의 이상 점수에 기여하는 정렬된 관련 메트릭.
강한 추세나 계절성이 없는 단순한 프로파일에는 Online MAD나 Online Z-score를 선호하세요. 기존 Prophet와 Isolation Forest 구성은 해당 단변량 또는 다변량 Temporal Envelope 형태로 마이그레이션할 수 있어요.
모델별 인자:
- class (string): temporal_envelope 또는 전체 클래스 이름 model.online.TemporalEnvelopeModel.
- quantiles (list[float], 기본 [0.25, 0.75]): 기본 하한·상한 잔차 경계로 사용되는 두 개의 정렬된 확률. 값은 [0, 1] 내여야 해요.
- iqr_threshold (float, 기본 2.0): 기본 데이터 기반 구간 너비 제어. 높은 값은 일반 잔차 엔벨로프를 넓히고 감지를 줄여요. 1~4 값이 실용적인 실험 범위예요.
- alpha (float, 기본 0.005): 추세 반응성(Trend Reactivity). 높은 값은 지속적인 수준·추세 변화를 더 빨리 따르고, 낮은 값은 더 안정적인 기대값을 생성해요. 0.0025~0.02 값이 실용적인 실험 범위예요.
- loss_reactivity (float, 기본 5.0): 새 편차가 모델에 얼마나 쉽게 영향을 주는지 제어. 높을수록 더 쉽게 적응하고, 낮을수록 스파이크의 영향을 줄여요. 1~5 값이 좋은 시작 범위예요.
- min_n_samples_seen (integer, 기본 16): 이상 점수를 신뢰하기 전에 각 모델 또는 그룹이 봐야 하는 관측치. 상태와 예측은 워밍업 중에도 계속 학습하지만 이상 점수는 0으로 유지돼요. 대략적인 워밍업 기간은 이 값에 쿼리 step을 곱한 값이에요.
- changepoint_window (integer, 기본 16): 편차를 지속적인 수준 이동으로 취급하기 전에 필요한 연속적인 동일 방향 잔차. 일반 이상 버스트보다 긴 값을 사용하세요. 대략적인 확인 시간은 이 값에 쿼리 step을 곱한 값이에요.
- seasonalities (list[string], 기본 ['hod_smooth', 'dow_smooth']): 모델링할 반복 캘린더 패턴. 캘린더 패턴이 관련 없다고 알려진 경우 빈 목록을 사용하세요. 지원되는 프리셋:
- hour of day: hod_smooth, hod_spiky, hod_plateau;
- day of week: dow_smooth, dow_spiky, dow_plateau;
- weekday versus weekend: weekpart_plateau;
- month of year: month_smooth, month_plateau.
- holidays (object, 기본 {}): 알려진 국가 휴일과 특별 이벤트. 지원되는 키는 countries(국가 코드 또는 이름), special_events(반복 MM-DD 또는 일회성 YYYY-MM-DD 날짜), group(구성된 이벤트가 하나의 학습된 응답을 공유하는지 여부)이에요. 휴일 응답 형태는 공개적으로 구성되는 것이 아니라 데이터에서 학습돼요.
- forecast_at (list[string], 기본 []): ['1h', '1d'] 같은 양의 미래 오프셋. 각 오프셋은 point를 추가하고, provide_series로 요청하면 하한·상한 예측 시리즈를 추가해요.
프리셋 접미사는 예상 프로파일 형태를 설명해요: smooth는 점진적인 반복 곡선, spiky는 좁은 위상 피크, plateau는 지속적인 캘린더 수준을 나타내요. 데이터가 지원하는 프로파일만 선택하세요. 캘린더와 휴일 피처는 구성된 쿼리 시간대의 민간 시간(civil time)을 사용하므로 일광 절약 시간 전환에 걸쳐 시간·일 프로파일이 정렬된 상태로 유지돼요.
Temporal Envelope는 queries, schedulers, provide_series, scale, clip_predictions를 포함한 공통 모델 인자도 지원해요. data_range, detection_direction, min_dev_from_expected, min_rel_dev_from_expected, 쿼리 시간대는 해당 reader 쿼리 아래에 구성하세요. 다변량 변형은 이러한 비즈니스 정책을 각 입력 채널에 독립적으로 적용하므로(v1.30.2부터) 한 모델이 온도가 기대 이상, 전력이 기대 이상, 시계가 기대 이하 같은 조합을 나타낼 수 있어요.
다변량 변형은 class: temporal_envelope_multivariate 또는 model.online.TemporalEnvelopeMultivariateModel을 사용하며 다음을 추가해요:
- dependency_rank (integer, 기본 8): 크로스 채널 의존성을 나타내는 데 사용되는 컴팩트 랭크. 0으로 설정하면 의존성 피처를 비활성화해요.
- score_aggregation (max, mean, 또는 l2; 기본 l2): 각 채널 경계 편차를 하나의 이상 점수로 결합. l2는 제곱 평균 제곱근 크기를 사용해요.
- groupby (list[string], 선택): 각 고유 라벨-값 조합에 대해 별도의 다변량 모델을 피팅하는 데 사용되는 메트릭 라벨 이름.
- max_channels (integer, 기본 1000): 하나의 모델 인스턴스의 입력 시계열에 대한 하드 안전 한도.
- recommended_max_channels (integer, 기본 100): 권고 한도. 더 큰 입력은 고차원 추정이 덜 안정적이고 더 비쌀 수 있으므로 경고와 함께 max_channels까지 허용돼요.
- random_state (integer, 기본 42): 재현 가능한 의존성 피처에 사용되는 시드.
다변량 모델은 출력 카디널리티를 경계로 유지하기 위해 기본적으로 공동 anomaly_score만 내보내요. 해당 진단이 필요하고 다운스트림 카디널리티가 허용 가능한 경우에만 provide_series를 통해 채널 수준 y, yhat, yhat_lower, yhat_upper 패밀리를 명시적으로 요청하세요.
구성 예시 — 캘린더와 휴일 동작이 있는 단변량 모니터링:
models:
operations_envelope:
class: temporal_envelope
queries: [request_rate, latency]
seasonalities: [hod_smooth, dow_smooth, weekpart_plateau]
alpha: 0.005
loss_reactivity: 5
iqr_threshold: 2
changepoint_window: 16
holidays:
countries: [US]
special_events: ['12-24']
group: true
forecast_at: [1h, 1d]
provide_series: [anomaly_score, yhat, yhat_lower, yhat_upper]
구성 예시 — 클러스터당 하나의 의존성 모델이 있는 다변량 모니터링:
models:
service_dependency_envelope:
class: temporal_envelope_multivariate
queries: [request_rate, error_rate, latency]
groupby: [cluster]
dependency_rank: 8
score_aggregation: l2
seasonalities: [hod_smooth, dow_smooth]
provide_series: [anomaly_score]
독립적인 시리즈별 감지에는 temporal_envelope를 사용하세요. 정렬된 시리즈 간 관계 자체가 의미 있을 때만 temporal_envelope_multivariate를 사용하세요. 각 채널은 여전히 자신의 추세와 캘린더 패턴을 학습해요.
Online MAD
OnlineMADModel은 단변량, 온라인 모델이에요.
MAD 모델은 표준 편차 기반 모델보다 데이터의 이상치에 덜 민감한 강건한 이상 탐지 방법이에요. 중앙값과의 절대 편차가 상당히 크면 포인트를 이상으로 간주해요. 이는 온라인 분위수 추정용 t-digests(v1.15.0부터)에 기반한 온라인 근사 버전이에요.
모델별 인자:
- class (string): 모델 클래스 이름 "model.online.OnlineMADModel"(또는 클래스 별칭 지원, v1.13.0부터,
mad_online) - threshold (float, 선택): 이상을 결정하기 위한 MAD의 임계값 승수. 기본값 2.5. 더 높은 값은 더 적은 포인트를 이상으로 식별해요.
- min_n_samples_seen (int, 선택): 이상 점수를 계산하기 전에 보아야 하는 최소 샘플 수(n_samples_seen_ 속성). 그렇지 않으면 모델 예측을 신뢰할 충분한 데이터가 없으므로 이상 점수가 0이에요. 기본값 16.
- history_strength (float, 선택): v1.30.0부터. fit이 학습한 초기 히스토리의 강도. 1보다 큰 값은 처음에 피팅된 분위수를 보존하지만 이후 업데이트의 레버리지를 줄여요. 기본값 1.
- compression (int, 선택): 기반 t-digest의 압축 매개변수. 더 높은 값은 더 높은 정확도를 의미하지만 더 높은 메모리 사용. 기본값 100.
구성 예시:
models:
your_desired_alias_for_a_model:
class: "mad_online" # or 'model.online.OnlineMADModel'
threshold: 2.5
min_n_samples_seen: 128 # i.e. calculate it as full seasonality / data freq
history_strength: 2 # retain fitted history as a stronger prior
compression: 100 # higher values mean higher accuracy but higher memory usage
provide_series: ['anomaly_score', 'yhat'] # common arg example
# Common arguments for built-in model, if not set, default to
# See https://docs.victoriametrics.com/anomaly-detection/components/models/#common-args
# provide_series: ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper']
# schedulers: [
# all scheduler aliases defined in `scheduler` section,
# ]
# queries: [
# all query aliases defined in `reader.queries` section,
# ]
# Configure detection_direction and minimum-deviation policies under reader.queries. (query-level from v1.30.2).
# scale: [1.0, 1.0] # if needed, prediction intervals' width can be increased (>1) or narrowed (<1)
# clip_predictions: False # if data_range for respective `queries` is set in reader, `yhat.*` columns will be clipped
# anomaly_score_outside_data_range: 1.01 # auto anomaly score (1.01) if `y` (real value) is outside of data_range, if set
모델의 결과 메트릭은 여기에서 설명돼요.
Online Seasonal Quantile
OnlineQuantileModel은 단변량, 온라인 모델이에요.
온라인(계절) 분위수는 온라인 분위수 추정용 t-digests(v1.15.0부터)에 기반한 근사 분포 집합을 활용해요.
강한(잠재적으로 여러) 계절성이 있는 추세 제거된 데이터에 가장 적합해요. ProphetModel의 (약간 덜 유연한) 대체물 역할을 할 수 있어요.
출력의 yhat_lower, yhat, yhat_upper를 각각 계산하기 위해 seasonal_interval에 포함된 min_subseason 하위 구간 각각에 대해 분위수 트리플렛을 사용해요. 예를 들어 '4d' + '2h' 계절성 패턴(여러 개)을 사용하면 24*4 / 2 = 48개의 연속 추정치(각 2시간)를 보유하고 업데이트해요.
모델별 인자:
- class (string): 모델 클래스 이름 "model.online.OnlineQuantileModel"(또는 클래스 별칭 지원, v1.13.0부터,
quantile_online) - quantiles (list[float], 선택): 추정할 분위수. yhat_lower, yhat, yhat_upper가 분위수 순서예요. 기본값 (0.01, 0.5, 0.99).
- iqr_threshold (float, 선택): v1.25.0부터. 예측 구간의 너비를 늘리기 위한 사분위수 범위(IQR) 승수. 하위 호환을 위해 기본값 0(조정 없음). > 0으로 설정하면 모델이 yhat_lower와 yhat_upper에 IQR * iqr_threshold를 추가해요(min_subseason 계절 버킷 존중). 분산이나 이상치가 큰 데이터에 유용하며, 이상 탐지의 오탐을 피하는 데 도움이 돼요. (0.25, 0.5, 0.75) 같은 강건한 분위수와 함께 사용하는 것이 가장 좋아요.
- seasonal_interval (string, 선택): 계절 조정 구간. 설정하지 않으면 모델은 단순한 온라인 분위수 모델과 같아져요. 기본적으로 설정되지 않음.
- min_subseason (str, 선택): 분위수를 추정할 최소 구간. 기본적으로 설정되지 않음. 최소 구간은 계절 구간의 배수여야 해요. 즉 seasonal_interval='2h'면 min_subseason='15m'은 유효하지만 '37m'은 아님.
- use_transform (bool, 선택): 내부 분위수 추정을 안정화하기 위해 데이터에 log1p(abs(x)) * sign(x) 변환을 내부적으로 적용할지 여부. 생성된 출력(yhat)의 스케일에는 영향을 주지 않아요. 기본값 False.
- global_smoothing (float, 선택): 전역 분위수의 평활화 매개변수. 즉 출력은 전역과 계절 분위수의 가중 평균이에요(seasonal_interval과 min_subseason 인자가 설정된 경우). [0, 1] 구간이어야 하며, 0은 평활화 없음, 1은 전역 분위수 값만 사용을 의미해요.
- scale (float, 선택): yhat와 [yhat_lower, yhat_upper] 사이의 여백을 조정하는 데 사용. 새 여백 = |yhat_* - yhat_lower| * scale. 기본값 1(스케일링 없음). 자세한 지침과 양면 옵션은 scale 공통 인자 섹션을 참고하세요.
- season_starts_from (str, 선택): 계절 조정의 시작 날짜로, 구간 계산을 시작하는 기준점. 기본값 '1970-01-01'.
- min_n_samples_seen (int, 선택): 이상 점수를 계산하기 전에 보아야 하는 최소 샘플 수(n_samples_seen_ 속성). 그렇지 않으면 모델 예측을 신뢰할 충분한 데이터가 없으므로 이상 점수가 0이에요. 기본값 16.
- history_strength (float, 선택): v1.30.0부터. fit이 학습한 초기 히스토리의 강도. 1보다 큰 값은 피팅된 분위수를 처음에 보존하지만 이후 업데이트의 레버리지를 줄여요. 기본값 1.
- compression (int, 선택): 기반 t-digests의 압축 매개변수. 더 높은 값은 더 높은 정확도를 의미하지만 더 높은 메모리 사용. 기본값 100.
구성 예시: 강한 일중(시간별) 및 주중(일별) 계절성이 있고 데이터 정밀도가 '5m'이며 데이터에 최대 5% 예상 이상치가 있는 데이터가 있다고 가정해요. 그러면 유사한 구성을 적용할 수 있어요:
models:
your_desired_alias_for_a_model:
class: "quantile_online" # or 'model.online.OnlineQuantileModel'
quantiles: [0.25, 0.5, 0.75] # lowered to exclude anomalous edges, can be compensated by `scale` param > 1 and `iqr_threshold` > 0
iqr_threshold: 2.5 # to increase prediction intervals' width to avoid false positives while still keeping the model robust
seasonal_interval: '7d' # longest seasonality (week, day) = week, starting from `season_starts_from`
min_subseason: '1h' # smallest seasonality (week, day, hour) = hour, will have its own quantile estimates
min_n_samples_seen: 288 # 1440 / 5 - at least 1 full day, ideal = 1440 / 5 * 7 - one full week (seasonal_interval)
history_strength: 2 # retain fitted history as a stronger prior
scale: 1.1 # to compensate lowered quantile boundaries with wider intervals
season_starts_from: '2024-01-01' # interval calculation starting point, especially for uncommon seasonalities like '36h' or '12d'
compression: 100 # higher values mean higher accuracy but higher memory usage
provide_series: ['anomaly_score', 'yhat'] # common arg example
# Common arguments for built-in model, if not set, default to
# See https://docs.victoriametrics.com/anomaly-detection/components/models/#common-args
# provide_series: ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper']
# schedulers: [
# all scheduler aliases defined in `scheduler` section,
# ]
# queries: [
# all query aliases defined in `reader.queries` section,
# ]
# Configure detection_direction and minimum-deviation policies under reader.queries. (query-level from v1.30.2).
# scale: [1.0, 1.0] # if needed, prediction intervals' width can be increased (>1) or narrowed (<1)
# clip_predictions: False # if data_range for respective `queries` is set in reader, `yhat.*` columns will be clipped
# anomaly_score_outside_data_range: 1.01 # auto anomaly score (1.01) if `y` (real value) is outside of data_range, if set
모델의 결과 메트릭은 여기에서 설명돼요.
Online Z-score
OnlineZscoreModel은 단변량, 온라인 모델이에요.
기존 Z-score 구현의 온라인 버전으로 정확히 같은 동작과 의미를 가져요(v1.15.0부터).
모델별 인자:
- class (string): 모델 클래스 이름 "model.online.OnlineZscoreModel"(또는 클래스 별칭 지원, v1.13.0부터,
zscore_online) - z_threshold (float, 선택): 경계와 이상 점수 계산을 위한 표준 점수. 기본값 2.5.
- min_n_samples_seen (int, 선택): 이상 점수를 계산하기 전에 보아야 하는 최소 샘플 수(n_samples_seen_ 속성). 그렇지 않으면 모델 예측을 신뢰할 충분한 데이터가 없으므로 이상 점수가 0이에요. 기본값 16.
- history_strength (float, 선택): v1.30.0부터. fit이 학습한 초기 히스토리의 강도. 1보다 큰 값은 처음에 피팅된 평균과 분산을 유지하지만 이후 업데이트의 레버리지를 줄여요. 기본값 1.
구성 예시:
models:
your_desired_alias_for_a_model:
class: "zscore_online" # or 'model.online.OnlineZscoreModel'
z_threshold: 3.5
min_n_samples_seen: 128 # i.e. calculate it as full seasonality / data freq
history_strength: 2 # retain fitted history as a stronger prior
provide_series: ['anomaly_score', 'yhat'] # common arg example
# Common arguments for built-in model, if not set, default to
# See https://docs.victoriametrics.com/anomaly-detection/components/models/#common-args
# provide_series: ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper']
# schedulers: [
# all scheduler aliases defined in `scheduler` section,
# ]
# queries: [
# all query aliases defined in `reader.queries` section,
# ]
# Configure detection_direction and minimum-deviation policies under reader.queries. (query-level from v1.30.2).
# scale: [1.0, 1.0] # if needed, prediction intervals' width can be increased (>1) or narrowed (<1)
# clip_predictions: False # if data_range for respective `queries` is set in reader, `yhat.*` columns will be clipped
# anomaly_score_outside_data_range: 1.01 # auto anomaly score (1.01) if `y` (real value) is outside of data_range, if set
모델의 결과 메트릭은 여기에서 설명돼요.
Rolling Quantile
RollingQuantileModel(v1.28.0부터)은 단변량, 온라인 모델이에요. v1.28.0부터 사용 중단(Deprecated)된 단변량, 롤링, 오프라인 모델이었어요.
이 모델은 짧은 진화 패턴(즉 특정 주기의 10-100개의 데이터 포인트)이 있는 데이터에 가장 적합하며, 롤링 창에 걸쳐 변화에 적응해요.
모델별 인자:
- class (string): 모델 클래스 이름 "model.rolling_quantile.RollingQuantileModel"(또는 클래스 별칭 지원, v1.13.0부터,
rolling_quantile) - quantile (float): 0.5에서 1.0까지의 분위수 값. 이 제약은 양면 신뢰 구간에서 암시돼요.
- window_steps (integer): 이동 창의 크기. ('sampling_period' 참고)
- iqr_threshold (float, 선택): v1.25.0부터. 예측 구간의 너비를 늘리기 위한 사분위수 범위(IQR) 승수. 하위 호환을 위해 기본값 0(조정 없음). > 0으로 설정하면 모델이 yhat_lower와 yhat_upper에 절반 IQR * iqr_threshold를 추가해요. 분산이나 이상치가 큰 데이터에 유용하며, 이상 탐지의 오탐을 피하는 데 도움이 돼요.
구성 예시:
models:
your_desired_alias_for_a_model:
class: "rolling_quantile"
quantile: 0.9
window_steps: 96
iqr_threshold: 1
# Common arguments for built-in model, if not set, default to
# See https://docs.victoriametrics.com/anomaly-detection/components/models/#common-args
# provide_series: ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper']
# schedulers: [
# all scheduler aliases defined in `scheduler` section,
# ]
# queries: [
# all query aliases defined in `reader.queries` section,
# ]
# Configure detection_direction and minimum-deviation policies under reader.queries. (query-level from v1.30.2).
# scale: [1.0, 1.0] # if needed, prediction intervals' width can be increased (>1) or narrowed (<1)
# clip_predictions: False # if data_range for respective `queries` is set in reader, `yhat.*` columns will be clipped
# anomaly_score_outside_data_range: 1.01 # auto anomaly score (1.01) if `y` (real value) is outside of data_range, if set
모델의 결과 메트릭은 여기에서 설명돼요.
Prophet
vmanomaly는 시계열 예측을 위해 Facebook Prophet 구현을 사용하며, 자세한 사용법은 Prophet 라이브러리 문서에 제공돼요. 모든 원본 Prophet 매개변수가 지원되며 args 인자를 통해 모델에 직접 전달할 수 있어요.
ProphetModel은 단변량, 오프라인 모델이에요.
Prophet은 향후 릴리스에서 사용 중단(Deprecated)될 예정이에요. 새 예측·이상 탐지 배포에는 Prophet 특유의 분해 출력이 필요하지 않는 한 온라인 Temporal Envelope 모델을 선호하세요.
v1.25.3부터 미래 타임스탬프에 대한 예측 생성이 지원돼요. 활성화하려면 forecast_at 인자를 상대 미래 오프셋 목록(예: ['1h', '1d'])으로 설정하세요. 그러면 모델이 이러한 미래 타임스탬프에 대한 예측을 생성하며, 이는 계획과 리소스 할당에 유용할 수 있어요. 출력 시리즈는 provide_series 인자의 영향을 받는데, 지점별 예측에는 최소 yhat(각 신뢰 구간에는 yhat_lower 또는/및 yhat_upper)을 포함해야 해요. 자세한 내용은 아래 예시를 참고하세요.
모델별 인자:
- class (string): 모델 클래스 이름 "model.prophet.ProphetModel"(또는 클래스 별칭 지원, v1.13.0부터,
prophet) - seasonalities (list[dict], 선택): Prophet에 포함할 추가 계절 구성요소. 자세한 내용은 Prophet의 add_seasonality() 문서를 참고하세요.
- scale (v1.18.0부터, float): yhat와 [yhat_lower, yhat_upper] 사이의 여백을 조정하는 데 사용. 새 여백 = |yhat_* - yhat_lower| * scale. 기본값 1(스케일링 없음). 자세한 지침과 양면 옵션은 scale 공통 인자 섹션을 참고하세요.
- tz_aware (v1.18.0부터, bool): 시간대 인식 타임스탬프 처리를 활성화. 기본값 False. tz_seasonalities와 tz_use_cyclical_encoding 매개변수와 함께 사용해야 해요.
- tz_seasonalities (v1.18.0부터, list[dict]): 시간대 인식 계절 구성요소를 지정. tz_aware=True 필요. 지원되는 옵션은 minuted(분), hod(시간), dow(요일), month(월)이에요. v1.18.2부터 각 계절성에 대해 fourier_order, prior_scale, mode 같은 추가 매개변수를 구성할 수 있어요. 자세한 내용은 아래 "시간대 비인식 구성 예시"를 참고하세요. v1.18.2부터 tz_seasonalities의 형식이 유연성을 높이도록 업데이트됐어요. 이전에는 문자열 목록(예: ['hod', 'minute'])을 받았어요. 이제 seasonalities 인자에 정의된 커스텀 계절성과 같은 구조(예: {"name": "hod", "fourier_order": 5, "mode": "additive"})를 따릅니다. 이 변경은 하위 호환이므로 이전 구성은 기본값을 사용해 새 형식으로 자동 변환돼요.
- tz_use_cyclical_encoding (v1.18.0부터, bool): True로 설정하면 시간대 인식 계절성에 순환 인코딩 기법을 적용해요. tz_aware=True와 tz_seasonalities와 함께 사용해야 해요.
- forecast_at (v1.25.3부터, list[str]): 예측을 생성할 미래 상대 오프셋을 지정(예: ['1h', '1d']). MetricsQL의 predict_linear과 유사하게 작동하지만 더 많은 유연성과 계절성 지원 제공. 생성된 시리즈는 다른 출력 시리즈와 같은 타임스탬프를 갖지만 미래 타임스탬프의 예측값을 가져요. 기본값 [](빈 목록, 미래 예측 없음). 설정하면 provide_series에 지점별 예측을 위한 최소 yhat(각 신뢰 구간용 yhat_lower 또는/및 yhat_upper)이 포함되어야 해요. 예를 들어 forecast_at가 ['1h', '1d']로 설정되면 모델은 다음 시간과 다음 날 모두에 대한 예측을 생성하고, 이 시리즈는 출력에서 각각 yhat_1h, yhat_lower_1h, yhat_upper_1h, yhat_1d, yhat_lower_1d, yhat_upper_1d로 접근할 수 있어요. 자세한 내용은 FAQ를 참고하세요. 쿼리가 반환하는 시계열이 많으면 forecast_at 매개변수가 활성 시계열을 크게 늘릴 수 있어요. forecast_at에 지정된 각 미래 타임스탬프에 대해 추가 시리즈를 생성하기 때문이에요(구간 예측 포함 시 선택적으로 1-3배). 예를 들어 쿼리가 1000개의 시계열을 반환하고 forecast_at을 [1h, 1d, 1w]로 설정하고 provide_series가 yhat_lower와 yhat_upper를 포함한다면 1000(시리즈) * 3(구간) * 3(예측, 지점+구간) = 9000개의 추가 시계열을 생성해요. 이 문제를 피하려면 소수의 메트릭 하위 집합(예: 호스트나 리전으로 그룹화)에서만 사용하는 것을 고려하세요. 또한 forecast_at 요소 수에 비례해 추론 호출 타이밍도 증가해요.
- compression (v1.28.1부터, dict, 선택): 모델 피팅 전 입력 데이터를 다운샘플링하기 위한 구성. 고주파 데이터에서 CPU/RAM/디스크 부하를 줄이고 모델 성능을 개선하는 데 유용. compression 블록은 다음 매개변수를 지원:
- window (str, 필수): 다운샘플링 시간 창(예: "5m", "1h").
- agg_method (str, 선택, 기본 "mean"): 각 창 내에 적용할 집계 함수. 지원 값: "mean", "median".
- adjust_boundaries (bool, 선택, 기본 true): 다운샘플링 후 신뢰 구간 경계를 조정할지 여부. true면 yhat_lower와 yhat_upper가 집계된 데이터와 원본 데이터의 변동성을 기반으로 조정돼요.
구성 예시 — 시간대 비인식:
models:
your_desired_alias_for_a_model:
class: 'prophet' # or 'model.prophet.ProphetModel' until v1.13.0
provide_series: ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper', 'trend']
# Common arguments for built-in model, if not set, default to
# See https://docs.victoriametrics.com/anomaly-detection/components/models/#common-args
# provide_series: ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper', 'trend']
# schedulers: [
# all scheduler aliases defined in `scheduler` section,
# ]
# queries: [
# all query aliases defined in `reader.queries` section,
# ]
# Configure detection_direction and minimum-deviation policies under reader.queries. (query-level from v1.30.2).
# scale: [1.0, 1.0] # if needed, prediction intervals' width can be increased (>1) or narrowed (<1)
# clip_predictions: False # if data_range for respective `queries` is set in reader, `yhat.*` columns will be clipped
# anomaly_score_outside_data_range: 1.01 # auto anomaly score (1.01) if `y` (real value) is outside of data_range, if set
seasonalities:
- name: 'hourly'
period: 0.04166666666
fourier_order: 30
prior_scale: 20
compression: # downsample input data to reduce CPU/RAM load
window: '30m' # downsample to 30-minute intervals
agg_method: 'mean' # use mean aggregation within each window
adjust_boundaries: true # adjust yhat_lower/yhat_upper after downsampling
# inner model args (key-value pairs) accepted by
# https://facebook.github.io/prophet/docs/quick_start#python-api
args:
interval_width: 0.98 # see https://facebook.github.io/prophet/docs/uncertainty_intervals
country_holidays: 'US'
구성 예시 — 시간대 인식:
models:
your_desired_alias_for_a_model:
class: 'prophet' # or 'model.prophet.ProphetModel' until v1.13.0
provide_series: ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper', 'trend']
# Common arguments for built-in model, if not set, default to
# See https://docs.victoriametrics.com/anomaly-detection/components/models/#common-args
# provide_series: ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper', 'trend']
# schedulers: [
# all scheduler aliases defined in `scheduler` section,
# ]
# queries: [
# all query aliases defined in `reader.queries` section,
# ]
# Configure detection_direction and minimum-deviation policies under reader.queries. (query-level from v1.30.2).
# scale: [1.0, 1.0] # if needed, prediction intervals' width can be increased (>1) or narrowed (<1)
# clip_predictions: False # if data_range for respective `queries` is set in reader, `yhat.*` columns will be clipped
# anomaly_score_outside_data_range: 1.01 # auto anomaly score (1.01) if `y` (real value) is outside of data_range, if set
tz_aware: True
tz_use_cyclical_encoding: True
tz_seasonalities: # intra-day + intra-week seasonality, no intra-year / sub-hour seasonality
- name: 'hod' # intra-day seasonality, hour of the day
fourier_order: 5 # keep it 3-8 based on intraday pattern complexity
prior_scale: 10
- name: 'dow' # intra-week seasonality, time of the week
fourier_order: 2 # keep it 2-4, as dependencies are learned separately for each weekday
compression: # downsample input data to reduce CPU/RAM load
window: '30m' # downsample to 30-minute intervals
agg_method: 'mean' # use mean aggregation within each window
adjust_boundaries: true # adjust yhat_lower/yhat_upper after downsampling
# inner model args (key-value pairs) accepted by
# https://facebook.github.io/prophet/docs/quick_start#python-api
args:
interval_width: 0.98 # see https://facebook.github.io/prophet/docs/uncertainty_intervals
country_holidays: 'US'
표준 vmanomaly 출력 외에도 Prophet 모델은 추가 메트릭을 제공할 수 있어요.
FB Prophet이 생성하는 추가 출력 메트릭: 선택한 seasonality 매개변수에 따라 FB Prophet은 다음과 같은 추가 메트릭을 반환할 수 있어요:
- trend, trend_lower, trend_upper
- additive_terms, additive_terms_lower, additive_terms_upper
- multiplicative_terms, multiplicative_terms_lower, multiplicative_terms_upper
- daily, daily_lower, daily_upper
- hourly, hourly_lower, hourly_upper
- holidays, holidays_lower, holidays_upper
- holidays 매개변수가 설정되면 각 휴일에 대한 여러 열
모델의 결과 메트릭은 여기에서 설명돼요.
Isolation forest (Multivariate)
IsolationForestModel은 단변량, 오프라인 모델이에요.
IsolationForestMultivariateModel은 다변량, 오프라인 모델이에요.
단변량 isolation_forest와 다변량 isolation_forest_multivariate 모두 향후 릴리스에서 사용 중단(Deprecated)될 예정이에요. 새 배포에는 해당 단변량 또는 다변량 온라인 Temporal Envelope 모델을 사용하세요.
이진 트리를 사용해 이상을 감지해요. 알고리즘은 선형 시간 복잡도와 낮은 메모리 요구 사항을 가지며, 대용량 데이터에서 잘 작동해요. 단변량과 다변량 데이터 모두에 사용할 수 있지만 다변량 경우에 더 효과적이에요.
중요: 차원의 저주(curse of dimensionality)를 인지하세요. 쿼리가 메트릭 수보다 적은 데이터 포인트의 많은 시계열을 반환할 것으로 기대되면 단일 다변량 모델을 사용하지 마세요. 그러한 경우 모델이 너무 희박한 데이터 하이퍼큐브에서 의미 있는 의존성을 학습하기 어려워요.
여기서는 scikit-learn 라이브러리의 Isolation Forest 구현을 사용해요. 이 라이브러리의 모든 매개변수를 모델에 전달할 수 있어요.
모델별 인자:
- class (string): 모델 클래스 이름 "model.isolation_forest.IsolationForestMultivariateModel"(또는 클래스 별칭 지원, v1.13.0부터,
isolation_forest_multivariate) - contamination (float 또는 string, 선택): 데이터셋의 오염 정도, 즉 데이터셋에서 이상치의 비율. 피팅 시 샘플 점수의 임계값을 정의하는 데 사용. 기본값 "auto". "auto"이거나 (0.0, 0.5] 범위여야 해요. v1.29.5부터 "0.01" 같은 숫자 문자열은 허용되고, nan, inf, -inf 같은 유효하지 않은 비유한 값은 구성 검증 중에 거부돼요.
- seasonal_features (list of string): 순환 인코딩을 통해 인코딩할 계절성 목록(예: dow(요일)). 1.12.0에 도입. 하위 호환을 위해 기본적으로 비어 있어요.
- 예: seasonal_features: ['dow', 'hod'].
- 지원되는 계절성: "minute" - 시간의 분(0-59), "hod" - 일의 시간(0-23), "dow" - 주의 일(1-7), "month" - 연의 월(1-12).
- args (dict, 선택): 내부 모델 인자(키-값 쌍). 모델 문서에서 허용 매개변수 참고. 기본값 빈(제공 안 함). 예: {"random_state": 42, "n_estimators": 100}
구성 예시:
models:
your_desired_alias_for_a_model:
# To use univariate model, substitute class argument with "model.isolation_forest.IsolationForestModel".
class: "isolation_forest_multivariate" # or 'model.isolation_forest.IsolationForestMultivariateModel' until v1.13.0
contamination: "0.01"
provide_series: ['anomaly_score']
seasonal_features: ['dow', 'hod']
args:
n_estimators: 100
# i.e. to assure reproducibility of produced results each time model is fit on the same input
random_state: 42
# Common arguments for built-in model, if not set, default to
# See https://docs.victoriametrics.com/anomaly-detection/components/models/#common-args
# provide_series: ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper']
# schedulers: [
# all scheduler aliases defined in `scheduler` section,
# ]
# queries: [
# all query aliases defined in `reader.queries` section,
# ]
# anomaly_score_outside_data_range: 1.01 # auto anomaly score (1.01) if `y` (real value) is outside of data_range, if set
모델의 결과 메트릭은 여기에서 설명돼요.
Holt-Winters
Holt-Winters는 향후 릴리스에서 사용 중단(Deprecated)될 예정이에요. 새 배포에는 온라인 Temporal Envelope 모델을 선호하세요.
여기서는 statsmodels 라이브러리의 Holt-Winters 지수 평활법 구현을 사용해요. 이 라이브러리의 모든 매개변수를 모델에 전달할 수 있어요.
모델별 인자:
- class (string): 모델 클래스 이름 "model.holtwinters.HoltWinters"(또는 클래스 별칭 지원, v1.13.0부터,
holtwinters) - frequency (string): sampling_period와 같게 설정해야 해요. 모델은 예상 데이터 포인트 빈도(예: '10m')를 알아야 해요. 생략하면 피팅 중에 피팅 데이터 타임스탬프 간 간격의 중앙값으로 빈도가 추측돼요. 추론 중에 들어오는 데이터가 같은 빈도가 아니면 보간(interpolate)돼요. 예: 데이터가 15초 해상도로 오고 resample_freq가 '1m'이면, 피팅 데이터는 '1m'으로 다운샘플링되고 내부 모델은 '1m' 간격으로 훈련돼요. 그래서 추론 중에는 '1m' 간격으로 예측 데이터가 생성되지만, 출력 데이터는 같은 타임스탬프를 가져야 하므로 예상 출력과 맞추기 위해 "15s"로 보간돼요. pandas.Timedelta가 받아들이는 형식(예: '5m').
- seasonality (string, 선택): pandas.Timedelta가 받아들이는 형식. seasonal_periods가 지정되지 않으면 seasonality / frequency로 계산돼요. 모델의 "seasonal_periods" 매개변수를 계산하는 데 사용(예: '1D' 또는 '1W').
- z_threshold (float, 선택): 이상 점수를 정의하기 위한 경계 계산 표준 점수. 기본값 2.5.
기본 모델 매개변수:
- seasonal 매개변수가 지정되지 않으면 기본값은 add.
- initialization_method 매개변수가 지정되지 않으면 기본값은 estimated.
- args (dict, 선택): 내부 모델 인자(키-값 쌍). 모델 문서에서 허용 매개변수 참고. 기본값 빈(제공 안 함). 예: {"seasonal": "add", "initialization_method": "estimated"}
구성 예시:
models:
your_desired_alias_for_a_model:
class: "holtwinters" # or 'model.holtwinters.HoltWinters' until v1.13.0
seasonality: '1d'
frequency: '1h'
# Inner model args (key-value pairs) accepted by statsmodels.tsa.holtwinters.ExponentialSmoothing
args:
seasonal: 'add'
initialization_method: 'estimated'
# Common arguments for built-in model, if not set, default to
# See https://docs.victoriametrics.com/anomaly-detection/components/models/#common-args
# provide_series: ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper']
# schedulers: [
# all scheduler aliases defined in `scheduler` section,
# ]
# queries: [
# all query aliases defined in `reader.queries` section,
# ]
# Configure detection_direction and minimum-deviation policies under reader.queries. (query-level from v1.30.2).
# scale: [1.0, 1.0] # if needed, prediction intervals' width can be increased (>1) or narrowed (<1)
# clip_predictions: False # if data_range for respective `queries` is set in reader, `yhat.*` columns will be clipped
# anomaly_score_outside_data_range: 1.01 # auto anomaly score (1.01) if `y` (real value) is outside of data_range, if set
모델의 결과 메트릭은 여기에서 설명돼요.
Seasonal Trend Decomposition
StdModel(v1.28.0부터)은 단변량, 온라인 모델이에요. v1.28.0부터 사용 중단(Deprecated)된 단변량, 롤링, 오프라인 모델이었어요.
여기서는 statsmodels 라이브러리의 Seasonal Decompose 구현을 사용해요. 이 라이브러리의 매개변수를 모델에 전달할 수 있어요. 일부 매개변수는 vmanomaly에서 특별히 미리 정의되어 사용자가 변경할 수 없어요(model='additive', two_sided=False).
모델별 인자:
- class (string): 모델 클래스 이름 "model.std.StdModel"(또는 클래스 별칭 지원, v1.13.0부터,
std) - period (integer): 한 계절의 데이터 포인트 수.
- z_threshold (float, 선택): 이상 점수를 정의하기 위한 경계 계산 표준 점수. 기본값 2.5.
구성 예시:
models:
your_desired_alias_for_a_model:
class: "std" # or 'model.std.StdModel' starting from v1.13.0
period: 2
# Common arguments for built-in model, if not set, default to
# See https://docs.victoriametrics.com/anomaly-detection/components/models/#common-args
# provide_series: ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper']
# schedulers: [
# all scheduler aliases defined in `scheduler` section,
# ]
# queries: [
# all query aliases defined in `reader.queries` section,
# ]
# Configure detection_direction and minimum-deviation policies under reader.queries. (query-level from v1.30.2).
# scale: [1.0, 1.0] # if needed, prediction intervals' width can be increased (>1) or narrowed (<1)
# clip_predictions: False # if data_range for respective `queries` is set in reader, `yhat.*` columns will be clipped
# anomaly_score_outside_data_range: 1.01 # auto anomaly score (1.01) if `y` (real value) is outside of data_range, if set
모델의 결과 메트릭은 여기에서 설명돼요.
Seasonal Trend Decomposition 모델이 생성하는 추가 출력 메트릭:
- resid — 데이터 시리즈의 잔차 성분.
- trend — 데이터 시리즈의 추세 성분.
- seasonal — 데이터 시리즈의 계절 성분.
vmanomaly 출력
vmanomaly는 모델 의존 출력 시리즈를 생성해요. 그 메트릭 이름은 writer 섹션에서 구성할 수 있어요.
vmanomaly가 생성하는 기본 메트릭:
- anomaly_score: 기본 메트릭이에요. 0.0에서 1.0까지의 값이 비이상 데이터를 나타내도록 설계됐어요.
- 1.0보다 큰 값은 일반적으로 이상으로 분류되지만, 이 임계값은 알림 구성에서 조정할 수 있어요.
- 임계값은 모델 간 1로 정규화되므로 알림 규칙은 1보다 큰 점수를 일관되게 이상으로 취급할 수 있어요.
- yhat: 예측된 기대값을 나타내요.
- yhat_lower: 예측된 하한 경계를 나타내요.
- yhat_upper: 예측된 상한 경계를 나타내요.
- y: 쿼리 결과에서 얻은 원본 값이에요.
infer 호출이 NaN 또는 무한 입력 값을 받으면 해당 anomaly_score는 NaN이에요.
vmanomaly 모니터링 메트릭
모델 동작은 구성된 monitoring.pull.health_path 엔드포인트의 자체 모니터링 메트릭으로 노출돼요.
커스텀 모델 가이드 (Custom Model Guide)
내장 모델 외에도 vmanomaly는 커스텀 Python 모델을 로드할 수 있어요.
이 가이드는 다음 방법을 보여줘요:
- Model 인터페이스 구현;
- 커스텀 모델 구성;
- 모듈을 vmanomaly 컨테이너에 마운트하고 실행.
모델을 포함하는 파일은 Python 3.14 이상으로 작성되어야 해요. 커스텀 모델은 vmanomaly Python 환경 내부에서 실행되므로, 해당 종속성을 대상 이미지와 호환되게 유지하고 재시작 후 직렬화된 모델 상태를 복원할 때 모듈을 사용할 수 있게 유지하세요.
1. 커스텀 모델
Model에서 파생된 CustomModel 클래스로 custom_model.py를 만드세요. 구체적인 모델은 다음을 구현해야 해요:
- init — 공통 모델 인자가 초기화되도록 super().init(**kwargs)를 호출해야 함;
- fit — 최소 timestamp와 y를 포함하는 DataFrame으로 모델을 조건화;
- infer — 첫 열이 timestamp이고 최소 anomaly_score를 포함하는 DataFrame을 반환;
- serialize — 디스크 저장에 적합한 bytes를 반환;
- deserialize — bytes나 파일 경로에서 같은 모델을 복원.
모델별 구성은 args 매핑을 통해 전달돼요. 아래 예시는 정상적인 구간을 학습해요. 표준 예측 열을 내보내고 기본 클래스의 이상 점수 계산을 사용하므로 detection_direction, data_range, 최소 편차 같은 쿼리 정책과 scale 같은 모델 설정이 계속 작동해요.
from pickle import dumps
from statistics import NormalDist
import numpy as np
import pandas as pd
from model.model import (
PICKLE_PROTOCOL,
Model,
deserialize_basic,
)
class CustomModel(Model):
"""Simple univariate, offline custom model."""
def __init__(self, percentage: float = 0.95, **kwargs):
model_args = kwargs.get("args") or {}
self.percentage = float(model_args.get("percentage", percentage))
if not 0 < self.percentage < 1:
raise ValueError("percentage must be between 0 and 1")
super().__init__(**kwargs)
self._mean = np.nan
self._std = np.nan
self._z_threshold = NormalDist().inv_cdf((1 + self.percentage) / 2)
def fit(self, df: pd.DataFrame) -> None:
values = df["y"].to_numpy(dtype=np.float64)
self._mean = float(np.nanmean(values))
self._std = float(np.nanstd(values))
if not np.isfinite(self._mean) or not np.isfinite(self._std):
raise ValueError("fit data must contain finite values")
self._std = max(self._std, np.finfo(np.float64).eps)
def infer(self, df: pd.DataFrame) -> pd.DataFrame:
margin = self._z_threshold * self._std
df_pred = df[["timestamp", "y"]].copy()
df_pred["yhat"] = self._mean
df_pred["yhat_lower"] = self._mean - margin
df_pred["yhat_upper"] = self._mean + margin
self._prepare_ci_columns(
df_pred,
scale=self.scale,
clip_predictions=self.clip_predictions,
data_range=self.data_range,
)
df_pred["anomaly_score"] = self.get_anomaly_score(
df_pred,
data_range=self.data_range,
detection_direction=self.detection_direction,
min_dev_from_expected=self.min_dev_from_expected,
min_rel_dev_from_expected=self.min_rel_dev_from_expected,
anomaly_score_outside_data_range=self.anomaly_score_outside_data_range,
)
if self.provide_series:
return df_pred[self._assemble_output_columns()]
return df_pred
def serialize(self) -> bytes:
return dumps(self, protocol=PICKLE_PROTOCOL)
@staticmethod
def deserialize(model: str | bytes) -> "CustomModel":
return deserialize_basic(model)
모델은 기본적으로 오프라인이며 일대일 입력-출력 서비스 토폴로지를 사용해요. 커스텀 온라인 모델은 OnlineModel에서 파생하고 인과적 업데이트 의미를 구현해야 해요. is_online = True만 설정하는 것으로는 충분하지 않아요.
v1.30.3부터 커스텀 모델은 ModelTopology를 사용해 서비스 수준 입력 정체성이 출력 정체성에 어떻게 매핑되는지 선언해야 해요. 토폴로지는 오케스트레이션, 영속성, 그룹화, 출력 라벨 복원을 제어해요. infer가 반환하는 열 수를 설명하지는 않아요.
- ModelTopology.ONE_TO_ONE이 기본: 서비스가 각 입력 시리즈에 대해 하나의 모델을 유지해요.
- ModelTopology.MANY_TO_ONE은 정렬된 입력 시리즈를 하나의 모델 정체성과 하나의 공동 anomaly_score로 병합해요. 모델은 채널별 y, yhat, yhat_lower, yhat_upper 또는 forecast_at 예측 열을 반환할 수도 있어요. 이러한 진단은 다대일 토폴로지를 변경하지 않아요.
- ModelTopology.MANY_TO_MANY는 변화하는 피어 시리즈 풀을 추적하고 각 엔티티에 대한 출력 정체성을 복원하는 온라인 모델을 위한 WideModel 확장 계약이에요.
커스텀 다대일 모델의 경우 MultivariateModel에서 파생하고 계약을 명시적으로 선언하세요:
from model.model import MultivariateModel
from model.topology import ModelTopology
class CustomMultivariateModel(MultivariateModel):
topology = ModelTopology.MANY_TO_ONE
# fit receives timestamp plus one value column per aligned input channel.
# infer returns a joint anomaly_score and may include per-channel diagnostics.
레거시 is_multivariate = True 클래스 플래그는 여전히 내부적으로 알고리즘을 설명할 수 있지만 더 이상 서비스 라우팅을 선택하지 않아요. 그 플래그만 설정하는 클래스는 일대일로 오케스트레이션돼요. 기존 호환 내장 다변량 덤프는 내장 클래스 정의를 통해 계속 복원돼요.
변화하는 피어 풀의 경우 WideModel에서 파생하세요. fit과 infer 메서드는 timestamp, entity_id, y를 가진 긴 DataFrame을 사용하고, 반환된 엔티티 수준 행은 entity_id를 유지해야 서비스가 원본 라벨을 복원할 수 있어요. WideModel은 토폴로지만 저장하는 데 사용되는 마커가 아니라 의미론적 확장 계약이에요.
2. 구성 파일
config.yaml을 만드세요. 모델 클래스를 custom(model.custom.CustomModel의 별칭)으로 설정하고 커스텀 생성자 매개변수를 args 아래에 두세요. 공통 모델 인자는 모델 수준에 유지돼요.
schedulers:
s1:
class: "periodic"
infer_every: "1m"
fit_every: "1h"
fit_window: "1d"
models:
custom_model:
class: "custom"
queries: [ingestion_rate, churn_rate]
schedulers: [s1]
args:
percentage: 0.95
reader:
datasource_url: "http://victoriametrics:8428/"
sampling_period: "1m"
queries:
ingestion_rate:
expr: "sum(rate(vm_rows_inserted_total)) by (type)"
churn_rate:
expr: "sum(rate(vm_new_timeseries_created_total[5m]))"
writer:
datasource_url: "http://victoriametrics:8428/"
metric_format:
__name__: "custom_$VAR"
for: "$QUERY_KEY"
run: "test-format"
monitoring:
# /metrics server.
pull:
port: 8080
push:
url: "http://victoriametrics:8428/"
extra_labels:
job: "vmanomaly-develop"
config: "custom.yaml"
나머지 필드는 컴포넌트 구성 참조를 참고하세요.
3. 커스텀 모델 실행
vmanomaly 이미지를 가져오세요:
docker pull victoriametrics/vmanomaly:v1.30.7
구성된 가져오기 경로 model.custom.CustomModel와 일치하는 /vmanomaly/src/model/custom.py에 모듈을 마운트하세요. 장기 실행 서비스를 시작하기 전에 --dryRun으로 전체 구성을 검증하세요.
docker run --rm \
-v "$PWD/license:/license:ro" \
-v "$PWD/custom_model.py:/vmanomaly/src/model/custom.py:ro" \
-v "$PWD/config.yaml:/config.yaml:ro" \
victoriametrics/vmanomaly:v1.30.7 \
/config.yaml \
--licenseFile=/license \
--dryRun
검증이 성공한 후 --dryRun을 제거하고 선택적으로 --watch를 추가하세요. 라이선싱과 실행 옵션은 Docker 설치 가이드를 참고하세요.
출력
writer는 각 입력 시리즈에 대해 하나의 custom_anomaly_score 시리즈를 내보내요. 입력 라벨을 유지하고 metric_format에 구성된 라벨을 추가해요:
{__name__="custom_anomaly_score", for="ingestion_rate", model_alias="custom_model", scheduler_alias="s1", run="test-format"},
{__name__="custom_anomaly_score", for="churn_rate", model_alias="custom_model", scheduler_alias="s1", run="test-format"}
사용 중단 (Deprecations)
사용 중단된 모델 유형과 모델. 여기 모든 사용 중단된 모델 유형과 각 버전 정보 및 마이그레이션 제안이 있는 특정 모델 목록이 있어요.
사용 중단된 유형
롤링(Rolling) 모델:
- v1.28.0부터 모든 롤링 모델은 각각의 문서 조정과 함께 온라인 대응 모델 favor로 사용 중단(Deprecated)됐어요. 이제 모든 모델 클래스는 비-롤링이에요.
Rolling Models
롤링 모델 클래스는 v1.28.0부터 온라인 모델 favor로 사용 중단(Deprecated)됐으며, 추가 이점과 함께 유사한 혜택을 제공해요. 각각의 롤링 모델은 온라인 모델로 리팩토링됐어요(예: RollingQuantile). 롤링 모델 별칭을 사용하는 기존 구성은 더 적은 제한(fit_every == infer_every 제약 없음)으로 계속 작동해요. 아래 설명은 오래된 배포와 하이퍼링크 일관성을 위해 유지돼요.
롤링 모델은 훈련된 후 피팅 단계에서 보지 못한 데이터에 대해 (자연스럽게) 추론을 하지 못하는 모델이에요.
롤링 모델 인스턴스는 infer 메서드 호출 중에 동시에 피팅되고 추론에 사용돼요.
결과적으로 이러한 모델 인스턴스는 연속 재피팅 호출 사이에 저장되지 않아(PeriodicScheduler의 fit_every 인자로 정의) RAM 소비가 낮아져요.
이러한 모델은 reader의 소스에 더 많은 부담을 줘요. 예를 들어 모델이 많은 양의 데이터(예: 1분 해상도로 14일)에 피팅되어야 하고 동시에 새 데이터 청크에서 빈번한 추론(예: 매분 1회)이 있다면, 각 추론 호출에서 나중에 사용하려면 (fit + infer) 창의 데이터를 먼저 피팅해야 하기 때문이에요.
롤링 모델은 PeriodicScheduler에서 fit_every를 설정하지 않거나 infer_every와 같게 명시적으로 설정해야 해요.
예시: RollingQuantile, v1.28.0 이전에는 온라인 모델이 됐어요.
Non-Rolling Models
이 섹션은 모든 모델 클래스가 v1.28.0부터 비-롤링이므로 deprecations로 이동됐어요. 롤링 모델 별칭을 사용한 구성은 더 적은 제한(fit_every == infer_every 제약 없음)으로 계속 작동해요. 아래 설명은 오래된 배포와 하이퍼링크 일관성을 위해 유지돼요.
롤링으로 분류되지 않는 모든 것이에요.
생성된 모델은 피팅 단계에서 보지 못한 데이터에 대해 명시적으로 추론할 수 있으므로 재피팅 절차를 요구하지 않아요.
이러한 모델은 reader의 소스에 더 적은 부담을 줘요. 예를 들어 많은 양의 데이터(예: 1분 해상도로 14일)에 피팅하지만 가끔(예: 하루 1회) 수행하고, 동시에 새 데이터 청크에서 빈번한 추론(예: 매분 1회)이 있다면요.
그러나 데이터가 시간이 지남에 따라 진화할 때 데이터에서 발견된 경향으로 모델을 최신 상태로 유지하는 것을 여전히 강력히 권장해요.
생성된 모델 인스턴스는 연속 재피팅 호출 사이에 메모리에 저장되어(PeriodicScheduler의 fit_every 인자로 정의) 더 높은 RAM 소비로 이어져요.
예시: Prophet.
사용 중단된 모델
Z-score
v1.28.4부터 사용 중단(Deprecated)됐어요. 데이터 효율성을 개선하고 사용자 혼란을 줄이기 위해 온라인 버전 favor로 제거됐어요. 이 모델을 사용한 구성(모델 클래스가 zscore 또는 model.zscore.ZscoreModel인 경우)은 내부적으로 온라인 버전으로 실제로 변경되면서 경고가 발생하며 계속 작동해요. fit_every 빈도를 줄여 데이터 조회에 대한 온라인 모델 이점을 얻기 위해 zscore_online 또는 model.online.OnlineZscoreModel 클래스로 명시적으로 교체할 것을 제안해요.
모델은 초기 테스트와 더 단순한 데이터(엄격한 계절성 없는 추세 제거된 데이터와 "정상" 데이터와 비슷한 크기의 이상)에 유용해요.
모델별 인자:
- class (string): 모델 클래스 이름 "model.zscore.ZscoreModel"(또는 클래스 별칭 지원, v1.13.0부터,
zscore) - z_threshold (float, 선택): 경계와 이상 점수 계산을 위한 표준 점수. 기본값 2.5.
구성 예시:
models:
your_desired_alias_for_a_model:
class: "zscore" # or 'model.zscore.ZscoreModel' until v1.13.0
z_threshold: 3.5
# Common arguments for built-in model, if not set, default to
# See https://docs.victoriametrics.com/anomaly-detection/components/models/#common-args
# provide_series: ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper']
# schedulers: [
# all scheduler aliases defined in `scheduler` section,
# ]
# queries: [
# all query aliases defined in `reader.queries` section,
# ]
# Configure detection_direction and minimum-deviation policies under reader.queries. (query-level from v1.30.2).
# scale: [1.0, 1.0] # if needed, prediction intervals' width can be increased (>1) or narrowed (<1)
# clip_predictions: False # if data_range for respective `queries` is set in reader, `yhat.*` columns will be clipped
# anomaly_score_outside_data_range: 1.01 # auto anomaly score (1.01) if `y` (real value) is outside of data_range, if set
모델의 결과 메트릭은 여기에서 설명돼요.
MAD (Median Absolute Deviation)
v1.28.4부터 사용 중단(Deprecated)됐어요. 데이터 효율성을 개선하고 사용자 혼란을 줄이기 위해 온라인 버전 favor로 제거됐어요. 이 모델을 사용한 구성(모델 클래스가 mad 또는 model.mad.MADModel인 경우)은 내부적으로 온라인 버전으로 실제로 변경되면서 경고가 발생하며 계속 작동해요. fit_every 빈도를 줄여 데이터 조회에 대한 온라인 모델 이점을 얻기 위해 mad_online 또는 model.online.OnlineMADModel 클래스로 명시적으로 교체할 것을 제안해요.
MAD 모델은 표준 편차 기반 모델보다 데이터의 이상치에 덜 민감한 강건한 이상 탐지 방법이에요. 중앙값과의 절대 편차가 상당히 크면 포인트를 이상으로 간주해요.
모델별 인자:
- class (string): 모델 클래스 이름 "model.mad.MADModel"(또는 클래스 별칭 지원, v1.13.0부터,
mad) - threshold (float, 선택): 이상을 결정하기 위한 MAD의 임계값 승수. 기본값 2.5. 더 높은 값은 더 적은 포인트를 이상으로 식별해요.
구성 예시:
models:
your_desired_alias_for_a_model:
class: "mad" # or 'model.mad.MADModel' until v1.13.0
threshold: 2.5
# Common arguments for built-in model, if not set, default to
# See https://docs.victoriametrics.com/anomaly-detection/components/models/#common-args
# provide_series: ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper']
# schedulers: [
# all scheduler aliases defined in `scheduler` section,
# ]
# queries: [
# all query aliases defined in `reader.queries` section,
# ]
# Configure detection_direction and minimum-deviation policies under reader.queries. (query-level from v1.30.2).
# scale: [1.0, 1.0] # if needed, prediction intervals' width can be increased (>1) or narrowed (<1)
# clip_predictions: False # if data_range for respective `queries` is set in reader, `yhat.*` columns will be clipped
# anomaly_score_outside_data_range: 1.01 # auto anomaly score (1.01) if `y` (real value) is outside of data_range, if set
모델의 결과 메트릭은 여기에서 설명돼요.