Fixing search.maxUniqueTimeseries Exceeded Errors
Wide Grafana template-variable queries like {namespace=~".*"} hit the default -search.maxUniqueTimeseries=300000 guardrail and return HTTP 422 errors.
Measured TSDB & Cardinality Telemetry
VictoriaMetrics intentionally caps how many unique time series a single MetricsQL query can touch (-search.maxUniqueTimeseries, default 300,000) to protect small 2-4 GB nodes from accidental full-DB regex scans. When legitimate 1.5M-15M series fleets run global rollups, this limit must scale proportionally with node RAM.
| Subsystem / Signal | Measured Footprint | Operational Impact |
|---|---|---|
| Default Guardrail Limit | 300,000 series/query | Triggers 422 on global cluster dashboards |
| 2-4 GB VPS Safe Cap | 750,000 - 1,500,000 | Pairs safely with -memory.allowedPercent=60 |
| 8-16 GB VPS Safe Cap | 3,000,000 - 8,000,000 | Supports fleet-wide multi-cluster heatmaps |
Step-by-Step Diagnostic & Config Remediation
- Verify exact 422 error message: Check Grafana query inspector for "the number of matching unique timeseries exceeds 300000".
- Tighten Grafana variable filters: Filter by cluster or environment label before wildcarding pod metrics.
- Scale -search.maxUniqueTimeseries: Raise the flag to ~1.4x active series on adequately sized 4-16 GB RAM nodes.
# Adjust in victoriametrics.service or docker-compose.yml: -search.maxUniqueTimeseries=1500000 -search.maxSamplesPerSeries=30000000 -search.maxConcurrentRequests=16
Diagnostic FAQ
Why not set -search.maxUniqueTimeseries to 100 million?
An unindexed wildcard query touching millions of series concurrently will exhaust RAM and stall ingestion; always bound it near 1.2x-1.5x your real active series.
Can I enforce recording rules instead of raising the query cap?
Yes. Using vmalert recording rules pre-aggregates heavy global metrics so Grafana reads dozens of series instead of millions.