RousselTMLEARNING

Observability

MetricsQL: PromQL with superpowers

The differences between MetricsQL and PromQL: implicit windows, extra functions (range, rollup, label), WITH templates, and cardinality analysis in vmui.

1. Compatibility #

Your PromQL queries work.

Useful differences #

MetricsQL accepts existing PromQL queries, with a few behavioral differences designed to be more intuitive:

PointPromQLMetricsQL
rate windowMandatory: rate(x[5m])Optional: rate(x) picks the window based on the graph step
increase extrapolationFractional results for integer countersNo extrapolation: integer values as expected
Metric name after a functionDroppedCan be kept with keep_metric_names
Missing valueSeries absentdefault 0 to fill in

2. Extra functions #

A selection.

Examples #

# Modèles WITH : factoriser une requête complexe
WITH (
  errs = sum(rate(http_requests_total{code=~"5.."})) by (service),
  total = sum(rate(http_requests_total)) by (service),
)
errs / total

# Top 5 des séries selon leur moyenne sur la période affichée
topk_avg(5, rate(node_network_receive_bytes_total))

# Plusieurs agrégats d'une fenêtre en une passe (min, max, avg)
rollup(node_load1[1h])

# Combler les trous et garder le nom
rate(http_requests_total) keep_metric_names default 0

# Manipulation de labels
label_set(up, "equipe", "plateforme")
label_map(up, "job", "node", "système", "api", "applicatif")

# Médiane de chaque série sur la plage affichée
range_median(node_load1)
Common mistake: If you use MetricsQL functions in dashboards, they will no longer work on a regular Prometheus. Stick to standard PromQL for dashboards shared across several stores.

3. Exploring with vmui #

Queries, query traces and cardinality.

vmui tools #

TabUsage
QueryQueries with graph, table, JSON and execution trace
Cardinality explorerMetrics, labels and values creating the most series
Top queriesMost frequent and slowest queries
Active queriesQueries in progress
Relabeling debugTest a relabeling rule
Good practice: The cardinality explorer is the first tool to open when memory grows: it shows the responsible metric or label in one click.

Related articles

VictoriaMetrics: why and how, from single node to cluster

What VictoriaMetrics brings compared with Prometheus alone, its components (single-node, vmagent, vmalert, vm…

Ingesting metrics into VictoriaMetrics: scraping, vmagent and remote write

All the ways to feed VictoriaMetrics: remote write from Prometheus, built-in scraping, vmagent and its disk b…

VictoriaMetrics cluster: vminsert, vmselect, vmstorage and multi-tenancy

The VictoriaMetrics cluster architecture: the roles of vminsert, vmselect and vmstorage, data distribution an…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!