Core deployment pattern
Use a Loki-compatible read proxy in front of VictoriaLogs
Loki-VL-proxy sits between Grafana or other Loki clients and VictoriaLogs. It keeps the read-side Loki API shape, translates metadata and query behavior where needed, and exposes route-aware telemetry so the middle layer stays operable.
What the proxy actually does
- Accepts Loki-compatible read and metadata requests.
- Translates query and metadata paths toward VictoriaLogs and optional rules backends.
- Shapes responses into the tuple and field contracts Grafana expects.
- Adds a 4-tier cache stack (Tier0, L1 memory, L2 bbolt disk, L3 peer) plus request coalescing and a sliding-window circuit breaker (30s window, 5 failure threshold) to protect the backend.
- Prefilters long-range queries and eliminates ~81.6% of empty-window backend calls.
What it intentionally does not do
- It does not become a generic log ingestion system.
- It does not ask Grafana to switch to a custom datasource plugin.
- It does not hide its own latency or cache behavior from operators.
- It does not open write ownership for Loki push paths.
Measured against Loki v3.7.10
The latest weekly A/B run, 2026-11-16 at commit 5b5c7965fc: the same data and hardware for both, 39 query-shape sets over 1h to 24h. A row is one query shape over one time range; faster or slower means beyond 25% and 50 ms, and a first request Loki's results cache answered is not judged. The same figures are generated into the README.
| Loki profile | Request | Rows compared | 🟢 Below Loki | 🟡 Close to Loki | 🟠 1–2× Loki | 🔴 Above 2× Loki |
|---|---|---|---|---|---|---|
loki-defaults | first | 568 | 365 (64.3%) | 183 (32.2%) | 14 (2.5%) | 6 (1.1%) |
loki-defaults | repeat | 765 | 187 (24.4%) | 568 (74.2%) | 4 (0.5%) | 6 (0.8%) |
aligned | first | 447 | 312 (69.8%) | 120 (26.8%) | 13 (2.9%) | 2 (0.4%) |
aligned | repeat | 529 | 22 (4.2%) | 500 (94.5%) | 2 (0.4%) | 5 (0.9%) |
| Workload (loki-defaults) | Pairs | 🟢 / 🟡 / 🔴 | First request p50 · p90 · slowest: proxy | Loki | Repeat p50: proxy | Loki |
|---|---|---|---|---|---|---|
| Metadata and label browser | 7 | 2 / 2 / 3 | 0.28 · 1.62 · 1.62 s | 0.10 · 0.38 · 0.38 s | 🟢 0.03 s | 0.10 s |
| Drilldown and Explore pages | 118 | 85 / 25 / 8 | 0.12 · 1.06 · 6.73 s | 0.35 · 4.96 · 9.85 s | 🟡 0.03 s | 0.05 s |
| Log queries | 79 | 39 / 39 / 1 | 0.02 · 0.08 · 0.24 s | 0.08 · 0.42 · 1.58 s | 🟢 0.01 s | 0.08 s |
| Metric queries | 366 | 239 / 117 / 10 | 0.10 · 1.04 · 6.52 s | 0.27 · 4.65 · 44.02 s | 🟡 0.02 s | 0.02 s |
First request by the time range a user picks, p50 · p90 · slowest pair:
| Workload | Range | Pairs | 🟢 / 🟡 / 🔴 | Proxy | Loki |
|---|---|---|---|---|---|
| Drilldown and Explore pages | 1h | 40 | 26 / 12 / 2 | 0.04 · 0.11 · 0.43 s | 0.24 · 0.33 · 0.64 s |
| Drilldown and Explore pages | 6h | 36 | 27 / 8 / 1 | 0.16 · 0.76 · 1.09 s | 0.93 · 1.41 · 2.82 s |
| Drilldown and Explore pages | 24h | 40 | 31 / 4 / 5 | 0.50 · 2.46 · 6.73 s | 4.16 · 5.53 · 9.85 s |
| Log queries | 1h | 31 | 4 / 26 / 1 | 0.05 · 0.08 · 0.09 s | 0.07 · 0.11 · 0.15 s |
| Log queries | 3h | 8 | 8 / 0 / 0 | 0.01 · 0.01 · 0.01 s | 0.08 · 0.14 · 0.14 s |
| Log queries | 6h | 20 | 13 / 7 / 0 | 0.01 · 0.04 · 0.08 s | 0.08 · 0.41 · 0.50 s |
| Log queries | 24h | 20 | 14 / 6 / 0 | 0.01 · 0.06 · 0.24 s | 0.11 · 1.50 · 1.58 s |
| Metric queries | 1h | 130 | 69 / 57 / 4 | 0.03 · 0.12 · 0.36 s | 0.13 · 0.30 · 3.98 s |
| Metric queries | 6h | 101 | 78 / 20 / 3 | 0.17 · 0.62 · 1.78 s | 0.66 · 1.60 · 14.84 s |
| Metric queries | 24h | 99 | 83 / 13 / 3 | 0.63 · 2.49 · 6.52 s | 3.35 · 6.55 · 31.26 s |
The heaviest queries for Loki, the ones a user waits for:
| Query shape | Range | Workload | Proxy | Loki | Proxy vs Loki |
|---|---|---|---|---|---|
F1 sum by over a ratio of two per-stream metrics, 20s step | 24h-20s | Metric queries | 4.14 s | 44.02 s | 🟢 10.6× faster |
B2 sum by over a ratio of two per-stream metrics | 24h | Metric queries | 3.81 s | 31.26 s | 🟢 8.2× faster |
F3 avg by service of rate, 20s step | 24h-20s | Metric queries | 1.82 s | 16.32 s | 🟢 9.0× faster |
B2 sum by over a ratio of two per-stream metrics | 6h | Metric queries | 1.05 s | 14.84 s | 🟢 14.1× faster |
F2 count by service of count_over_time, 20s step | 24h-20s | Metric queries | 0.01 s ‡ | 12.39 s | 🟢 1376.4× faster |
F4 sum of max by service,app, 20s step | 24h-20s | Metric queries | 4.43 s | 12.37 s | 🟢 2.8× faster |
DB1 label breakdown pod | 24h | Drilldown and Explore pages | 1.33 s | 9.85 s | 🟢 7.4× faster |
SF9 volume, logfmt label_format rename | 24h | Metric queries | 3.58 s | 8.38 s | 🟢 2.3× faster |
E3 logfmt latency_ms rate, production | 24h | Metric queries | 1.86 s | 8.27 s | 🟢 4.4× faster |
logfmt volume | 24h | Metric queries | 1.46 s | 8.07 s | 🟢 5.5× faster |
‡ The proxy answered a first request over 6h or more in under 50 ms: probably from its own cache, warmed by an earlier set of the weekly run that sent the same query. The run records Loki's cache counters but not the proxy's, so this row is not a cold proxy.
Where the proxy loses most:
| Query shape | Range | Workload | Proxy | Loki | Proxy vs Loki |
|---|---|---|---|---|---|
DP1 patterns of a plain-text service | 1h | Metadata and label browser | 0.33 s | 0.02 s | 🔴 14.5× slower |
DP2 patterns of an environment | 1h | Metadata and label browser | 1.62 s | 0.27 s | 🔴 6.0× slower |
LF29 logs, drop detected_level | 1h | Log queries | 0.08 s | 0.01 s | 🔴 5.5× slower |
LS8 json count by level_extracted, collision | 1h | Metric queries | 0.14 s | 0.04 s | 🔴 3.4× slower |
LS8 json count by level_extracted, collision | 6h | Metric queries | 0.56 s | 0.17 s | 🔴 3.3× slower |
Readiness by client: the Loki endpoints each client calls, their evidence, and the open differences it shows.
| Client | Loki endpoints it calls | Routed | Compared with Loki in tests | Proven | Open differences it shows |
|---|---|---|---|---|---|
| Grafana Explore | 10 | 10 | 10 | 8 | 64 |
| Logs Drilldown | 11 | 11 | 11 | 9 | 17 |
| Grafana Loki datasource | 6 | 6 | 6 | 4 | 1 |
| Loki API clients | 27 | 25 | 19 | 12 | 21 |
- Answers: 719 of 785 pairs return the same result as Loki, 51 differ and 15 could not be compared.
- Loki read API: 25 of 27 endpoints routed, 19 with tests that compare the proxy against Loki, 12 proven.
- Known differences from Loki: 174 ranked, 149 open; 82 of the open ones are visible in Grafana (64 Explore, 17 Logs Drilldown, 1 Grafana datasource). Each is listed in the ranked differences.
- Every shape and range, the open gaps and the regression gate: performance evidence.
Why this pattern works for Grafana
Grafana is already deeply opinionated around the Loki datasource and the Loki-style query path. Loki-VL-proxy keeps that client shape on the left while mapping requests to VictoriaLogs-aware internals on the right.
Labels and fields stay manageable
The proxy can expose underscore labels for Loki-safe query builder behavior while keeping dotted field semantics available through metadata modes and explicit mappings.
Patterns and Drilldown stay explicit
The Loki-compatible patterns endpoint is part of the supported read surface, with runtime gating and compatibility coverage for Grafana Logs Drilldown behavior.
Rules and alerts can stay visible
Read views for rules and alerts can be bridged through vmalert so Grafana does not lose those operational screens during the move. Alerting itself is not finished: vmalert runs the rules, and Loki-compatible rule evaluation is planned work.
Operators get their own control plane
The project ships route-aware metrics, structured logs, a packaged dashboard, and runbook-oriented docs instead of treating the proxy as a black box.
Where to go next
If this is the problem you are trying to solve, the next useful docs are the deployment guide, translation behavior, and observability model.