Wire VictoriaMetrics into Grafana and Tune Dashboards for MetricsQL
Choose between the Prometheus-type and native VictoriaMetrics Grafana datasource, then tune panels for MetricsQL, WITH templates, and $__rate_interval so large dashboards stop over-fetching.
- Target user
- Observability and SRE teams migrating Grafana dashboards from Prometheus to VictoriaMetrics or optimizing slow, wide panels.
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT, Cursor
The prompt
You are a Grafana + VictoriaMetrics integration engineer who knows the difference between the Prometheus-type datasource pointed at vmselect and the native VictoriaMetrics datasource plugin, and who has tuned wide dashboards to stop overloading `vmselect`. I will provide: - How VictoriaMetrics is deployed (single-node vmsingle vs cluster vmselect/vminsert/vmstorage) and the URL Grafana points at - The datasource type in use today (Prometheus-type vs VictoriaMetrics plugin) and Grafana version - The problem panels: their MetricsQL/PromQL, time ranges, `Min step`/`Max data points`, and symptoms (slow load, `too many points`, `504`, spiky rates) - The template variables and repeated panels/rows involved - Optionally: a query trace from `&trace=1` or the vmui query analyzer Your job: 1. **Recommend the datasource choice** — decide Prometheus-type vs native VictoriaMetrics plugin for their situation, weighing MetricsQL feature access, autocompletion, `Explore` behavior, and portability. State explicitly what they lose if they later need to point the same dashboards at Prometheus/Thanos. 2. **Fix the step / resolution model** — audit `$__rate_interval` vs `$__interval` vs hard-coded steps and `Max data points`; explain how each maps to the `step` vmselect receives, and correct panels that under-sample counters or request more points than pixels. Show the corrected panel options. 3. **Rewrite the heavy queries in MetricsQL** — where MetricsQL simplifies or de-costs the query (e.g. `WITH` templates to factor shared subexpressions, `rollup_rate`, `keep_metric_names`, `label_match`, subquery sugar), provide the rewrite with inline comments, and note which rewrites are plugin-only. 4. **Cut over-fetch on wide panels** — identify panels that pull huge cardinality for a few visible lines and reduce them via `topk`/`limit` series, recording rules for pre-aggregated series, or `by`-clause tightening; explain the vmselect memory impact of each. 5. **Tune variables and repeats** — flag template queries that scan `label_values` over expensive time ranges or that cause N repeated heavy panels, and propose cheaper variable queries or `__interval`-aware repeats. 6. **Give a validation pass** — a checklist to confirm the tuned panels return the same numbers as before (compare a fixed time range old vs new), plus the vmselect/vmui signals to watch (`vm_request_duration`, concurrent select limit, memory). Output as: (a) datasource recommendation with tradeoffs, (b) corrected panel step/resolution settings, (c) optimized MetricsQL with inline comments, (d) any recording rules to add, (e) a before/after equivalence checklist. Bias toward provably equivalent, portable rewrites over clever plugin-only tricks; whenever an optimization changes the sampled values or locks the dashboard to VictoriaMetrics, say so explicitly and give me the tradeoff.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Audit and Fix vmagent Relabeling to Kill Cardinality
Review vmagent relabel_configs and metric_relabel_configs (or -relabelConfig) to drop high-cardinality labels, tighten keep/drop target selection, and normalize labels without silently dropping the series you actually need.
-
Design VictoriaMetrics Stream Aggregation to Tame High-Cardinality Metrics
Design a vmagent or vmsingle stream aggregation config that pre-aggregates high-cardinality series at ingestion, collapsing labels while preserving counter and histogram semantics.
-
VictoriaMetrics MetricsQL Slow-Query Profiling Prompt
Profile and triage slow or expensive MetricsQL queries in production — using top_queries, active_queries, query traces, and TSDB status — to find which queries hurt vmselect and why, before rewriting them.
-
VictoriaMetrics MetricsQL Query Optimization Prompt
Audit and rewrite slow or expensive MetricsQL queries — fixing rollup misuse, subquery blowups, and unbounded label matchers — to cut vmselect latency and memory without changing results.
More Victoria Metrics prompts & error guides
Browse every Victoria Metrics prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.