VictoriaMetrics/docs/anomaly-detection/components
Daria Karavaieva 9ae49b405c
docs/vmanomaly: format & fix docs (#8122)
### Describe Your Changes

- fix formatting in Presets
- change integration guide config according to new format + optimisation
of prophet
- minor fixes

### Checklist

The following checks are **mandatory**:

- [x] My change adheres [VictoriaMetrics contributing
guidelines](https://docs.victoriametrics.com/contributing/).
2025-01-22 18:59:51 +01:00
..
_index.md added _index.md for hugo, which point to README.md (#6686) 2024-07-23 17:30:49 +03:00
autotune.webp docs/vmanomaly: v1.12 updates & fixes (#6046) 2024-04-01 16:41:55 +03:00
model-lifecycle-multivariate.webp docs/vmanomaly: v1.12 updates & fixes (#6046) 2024-04-01 16:41:55 +03:00
model-lifecycle-univariate.webp docs/vmanomaly: v1.12 updates & fixes (#6046) 2024-04-01 16:41:55 +03:00
model-type-non-rolling.webp docs/vmanomaly: v1.12 updates & fixes (#6046) 2024-04-01 16:41:55 +03:00
model-type-rolling.webp docs/vmanomaly: v1.12 updates & fixes (#6046) 2024-04-01 16:41:55 +03:00
models.md docs/vmanomaly: format & fix docs (#8122) 2025-01-22 18:59:51 +01:00
monitoring.md docs/vmanomaly: prod ready config example (#8107) 2025-01-22 13:49:52 +01:00
reader.md docs/vmanomaly: release v1.19.1 (#8108) 2025-01-21 20:42:47 +02:00
README.md docs/vmanomaly: popup deprecated_from and available_from for all docs (#7905) 2024-12-20 15:24:16 +01:00
scheduler.md docs/vmanomaly: prod ready config example (#8107) 2025-01-22 13:49:52 +01:00
schema_detection_direction=above_expected.webp docs/vmanomaly - release 1.13.0 preparation (#6436) 2024-06-11 13:15:05 +03:00
schema_detection_direction=below_expected.webp docs/vmanomaly - release 1.13.0 preparation (#6436) 2024-06-11 13:15:05 +03:00
schema_detection_direction=both.webp docs/vmanomaly - release 1.13.0 preparation (#6436) 2024-06-11 13:15:05 +03:00
schema_min_dev_from_expected=0.webp docs/vmanomaly - release 1.13.0 preparation (#6436) 2024-06-11 13:15:05 +03:00
schema_min_dev_from_expected=1.0.webp docs/vmanomaly - release 1.13.0 preparation (#6436) 2024-06-11 13:15:05 +03:00
schema_min_dev_from_expected=5.0.webp docs/vmanomaly - release 1.13.0 preparation (#6436) 2024-06-11 13:15:05 +03:00
vmanomaly-components.webp - fix 404 links after renaming (#5653) 2024-01-21 21:24:29 +02:00
writer.md docs/vmanomaly: fix column width (#8059) 2025-01-17 15:04:28 +01:00

This chapter describes different components, that correspond to respective sections of a config to launch VictoriaMetrics Anomaly Detection (or simply vmanomaly service:

Note

: Once the service starts, automated config validation is performed{{% available_from "v1.7.2" anomaly %}}. Please see container logs for errors that need to be fixed to create fully valid config, visiting sections above for examples and documentation.

Note

: Components' class{{% available_from "v1.13.0" anomaly %}} can be referenced by a short alias instead of a full class path - i.e. model.zscore.ZscoreModel becomes zscore, reader.vm.VmReader becomes vm, scheduler.periodic.PeriodicScheduler becomes periodic, etc. Please see according sections for the details.

Note: preset modes are available{{% available_from "v1.13.0" anomaly %}} for vmanomaly. Please find the guide here.

Below, you will find an example illustrating how the components of vmanomaly interact with each other and with a single-node VictoriaMetrics setup.

Note

: Reader and Writer also support multitenancy, so you can read/write from/to different locations - see tenant_id param description.

vmanomaly-components

Here's a minimalistic full config example, demonstrating many-to-many configuration (actual for latest version):

# how and when to run the models is defined by schedulers
# https://docs.victoriametrics.com/anomaly-detection/components/scheduler/
schedulers:
  periodic_1d:  # alias
    class: 'periodic' # scheduler class
    infer_every: "30s"
    fit_every: "10m"
    fit_window: "24h"
  periodic_1w:
    class: 'periodic'
    infer_every: "15m"
    fit_every: "1h"
    fit_window: "7d"

# what model types and with what hyperparams to run on your data
# https://docs.victoriametrics.com/anomaly-detection/components/models/
models:
  zscore:  # we can set up alias for model
    class: 'zscore'  # model class
    z_threshold: 3.5
    provide_series: ['anomaly_score']  # what series to produce
    queries: ['host_network_receive_errors']  # what queries to run particular model on
    schedulers: ['periodic_1d']  # will be attached to 1-day schedule, fit every 10m and infer every 30s
    min_dev_from_expected: 0.0  # turned off. if |y - yhat| < min_dev_from_expected, anomaly score will be 0
    detection_direction: 'above_expected' # detect anomalies only when y > yhat, "peaks"
  prophet: # we can set up alias for model
    class: 'prophet'
    provide_series: ['anomaly_score', 'yhat', 'yhat_lower', 'yhat_upper']
    queries: ['cpu_seconds_total']
    schedulers: ['periodic_1w']  # will be attached to 1-week schedule, fit every 1h and infer every 15m
    min_dev_from_expected: 0.01  # if |y - yhat| < 0.01, anomaly score will be 0
    detection_direction: 'above_expected'
    args:  # model-specific arguments
      interval_width: 0.98

# where to read data from
# https://docs.victoriametrics.com/anomaly-detection/components/reader/#vm-reader
reader:
  datasource_url: "https://play.victoriametrics.com/"
  tenant_id: "0:0"
  class: 'vm'
  sampling_period: "30s"  # what data resolution to fetch from VictoriaMetrics' /query_range endpoint
  latency_offset: '1ms'
  query_from_last_seen_timestamp: False
  queries:  # aliases to MetricsQL expressions
    cpu_seconds_total:
      expr: 'avg(rate(node_cpu_seconds_total[5m])) by (mode)' 
      # step: '30s'  # if not set, will be equal to sampling_period
      data_range: [0, 'inf']  # expected value range, anomaly_score > 1 if y (real value) is outside
    host_network_receive_errors:
      expr: 'rate(node_network_receive_errs_total[3m]) / rate(node_network_receive_packets_total[3m])'
      step: '15m'  # here we override per-query `sampling_period` to request way less data from VM TSDB
      data_range: [0, 'inf']

# where to write data to
# https://docs.victoriametrics.com/anomaly-detection/components/writer/
writer:
  datasource_url: "http://victoriametrics:8428/"

# enable self-monitoring in pull and/or push mode
# https://docs.victoriametrics.com/anomaly-detection/components/monitoring/
monitoring:
  pull: # Enable /metrics endpoint.
    addr: "0.0.0.0"
    port: 8490