VictoriaMetrics Data Model
Metric names, labels, MetricsQL and the ingestion protocols VictoriaMetrics accepts.
VictoriaMetrics uses the Prometheus data model: a metric name plus a set of label key-value pairs identifies a series, and each series holds timestamped float values.
http_requests_total{job="api", instance="10.0.1.5:8080", method="GET", status="200"}Ingestion
It accepts several protocols, which makes it a drop-in replacement in most stacks:
- Prometheus remote write — the usual path.
- Prometheus scraping, performed by VictoriaMetrics itself (
vmagentor-promscrape.config). - InfluxDB line protocol, Graphite, OpenTSDB, CSV and JSON import.
# prometheus.yml
remote_write:
- url: http://victoriametrics:8428/api/v1/write
queue_config:
max_samples_per_send: 10000
capacity: 20000vmagent sits in front for scraping, relabeling, buffering during backend outages and fan-out to
several destinations. Its on-disk buffer is what prevents data loss during a backend restart.
MetricsQL
MetricsQL is a superset of PromQL: existing queries work, with additional functions and some behavioural differences that reduce common PromQL surprises.
# Rate over a window, aggregated by status.
sum(rate(http_requests_total{job="api"}[5m])) by (status)
# 99th percentile latency from a histogram.
histogram_quantile(0.99, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))
# MetricsQL additions.
rollup_rate(http_requests_total[5m])Stream aggregation
Aggregating at ingestion is the primary defence against
cardinality growth. VictoriaMetrics can do it in vmagent or at
the storage layer, before the raw series are stored:
# stream aggregation config
- match: 'http_requests_total'
interval: 1m
outputs: [total]
without: [instance] # drop per-instance detail, keep the service-level seriesThis turns thousands of per-instance series into a handful of per-service ones, permanently.
Relabeling
metric_relabel_configs:
# Drop a high-cardinality label entirely.
- regex: 'request_id|trace_id'
action: labeldrop
# Drop metrics you never query.
- source_labels: [__name__]
regex: 'go_gc_.*'
action: dropStorage characteristics
VictoriaMetrics stores data in per-month partitions with columnar compression, and merges parts in the background — an LSM-like design. Two practical consequences:
- Retention is a partition drop, so it is cheap.
- Free disk space is needed for merges, so plan capacity above the steady-state size.
Out-of-order and duplicate samples are handled: it accepts them and deduplicates on read according to the configured deduplication interval, which is what makes highly-available Prometheus pairs straightforward to consolidate.