2024-07-24 08:00:31 +00:00
This chapter describes different components, that correspond to respective sections of a config to launch VictoriaMetrics Anomaly Detection (or simply [`vmanomaly` ](../Overview.md )) service:
2024-01-08 09:31:36 +00:00
2024-07-24 08:00:31 +00:00
- [Model(s) section ](./models.md ) - Required
- [Reader section ](./reader.md ) - Required
- [Scheduler(s) section ](./scheduler.md ) - Required
- [Writer section ](./writer.md ) - Required
- [Monitoring section ](./monitoring.md ) - Optional
2024-01-08 09:31:36 +00:00
2024-07-24 08:00:31 +00:00
> **Note**: starting from [v1.7.0](../CHANGELOG.md#v172), once the service starts, automated config validation is performed. Please see container logs for errors that need to be fixed to create fully valid config, visiting sections above for examples and documentation.
2024-01-08 09:31:36 +00:00
2024-07-24 08:00:31 +00:00
> **Note**: starting from [v1.13.0](../CHANGELOG.md#v1130), components' class 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.
2024-06-14 07:39:55 +00:00
2024-07-24 08:00:31 +00:00
> **Note:** Starting from [v1.13.0](../CHANGELOG.md#v1130) `preset` modes are available for `vmanomaly`. Please find the guide [here](../Presets.md).
2024-06-11 10:15:05 +00:00
2024-01-21 17:33:59 +00:00
Below, you will find an example illustrating how the components of `vmanomaly` interact with each other and with a single-node VictoriaMetrics setup.
2024-07-24 08:00:31 +00:00
> **Note**: [Reader](./reader.md#vm-reader) and [Writer](./writer.md#vm-writer) also support [multitenancy](../../Cluster-VictoriaMetrics.md#multitenancy), so you can read/write from/to different locations - see `tenant_id` param description.
2024-01-21 17:33:59 +00:00
2024-07-24 18:09:03 +00:00
![vmanomaly-components ](vmanomaly-components.webp )
2024-06-11 10:15:05 +00:00
2024-07-24 08:00:31 +00:00
Here's a minimalistic full config example, demonstrating many-to-many configuration (actual for [latest version ](../CHANGELOG.md )):
2024-06-11 10:15:05 +00:00
```yaml
2024-07-24 17:58:16 +00:00
# how and when to run the models is defined by schedulers
# https://docs.victoriametrics.com/anomaly-detection/components/scheduler/
2024-06-11 10:15:05 +00:00
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
2024-07-24 17:58:16 +00:00
# https://docs.victoriametrics.com/anomaly-detection/components/models/
2024-06-11 10:15:05 +00:00
models:
2024-08-10 14:43:05 +00:00
zscore: # we can set up alias for model
2024-06-11 10:15:05 +00:00
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
2024-08-10 14:43:05 +00:00
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
2024-06-11 10:15:05 +00:00
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
2024-08-10 14:43:05 +00:00
min_dev_from_expected: 0.01 # if |y - yhat| < 0.01 , anomaly score will be 0
detection_direction: 'above_expected'
2024-06-11 10:15:05 +00:00
args: # model-specific arguments
interval_width: 0.98
# where to read data from
2024-08-10 14:43:05 +00:00
# https://docs.victoriametrics.com/anomaly-detection/components/reader/#vm-reader
2024-06-11 10:15:05 +00:00
reader:
2024-08-10 14:43:05 +00:00
datasource_url: "https://play.victoriametrics.com/"
2024-06-11 10:15:05 +00:00
tenant_id: "0:0"
class: 'vm'
2024-08-10 14:43:05 +00:00
sampling_period: "30s" # what data resolution to fetch from VictoriaMetrics' /query_range endpoint
latency_offset: '1ms'
query_from_last_seen_timestamp: False
2024-06-11 10:15:05 +00:00
queries: # aliases to MetricsQL expressions
2024-08-10 14:43:05 +00:00
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']
2024-06-11 10:15:05 +00:00
# where to write data to
2024-07-24 17:58:16 +00:00
# https://docs.victoriametrics.com/anomaly-detection/components/writer/
2024-06-11 10:15:05 +00:00
writer:
datasource_url: "http://victoriametrics:8428/"
# enable self-monitoring in pull and/or push mode
2024-07-24 17:58:16 +00:00
# https://docs.victoriametrics.com/anomaly-detection/components/monitoring/
2024-06-11 10:15:05 +00:00
monitoring:
pull: # Enable /metrics endpoint.
addr: "0.0.0.0"
port: 8490
2024-07-23 14:30:49 +00:00
```