LogQL ↔ PromQL · Observability
Translate between LogQL and PromQL.
A free LogQL to PromQL converter that works online, entirely in your browser. Paste a query, pick a direction, and get a clean rewrite of the parts that map plus honest notes on the parts that do not.
LogQL ↔ PromQL Helper playground
Tip: press Esc to release focus.
Pick a direction, paste or load a query, then convert to see the translated query and notes on what does and does not map here.
The Gap
Same grammar, different worlds.
LogQL was deliberately modeled on PromQL: the matcher syntax, the range-vector functions, and the aggregation operators look almost identical. So engineers running both Loki and Prometheus constantly want to carry a query from one to the other — and reach for find-and-replace, which quietly breaks on the parts that don’t line up.
The catch is that PromQL only ever sees pre-aggregated samples, while LogQL can also filter and reshape raw log lines. Line filters, parsers and line_format have no PromQL equivalent at all. This Loki query converter does the boring metric mapping for you and, just as importantly, tells you exactly which pieces it could not translate — so you fix them on purpose instead of by surprise.
New to the differences? Jump to what maps and what doesn’t or try the live playground above.
The Pipeline
How it works.
Five deterministic steps run end-to-end on every press of Convert — all inside your browser tab, every time.
-
Parse the query.
Your source query is parsed into its structural parts — selectors, range functions, aggregations and comparisons — in whichever language you chose.
-
Map the metric shape.
Constructs that share grammar — matchers, rate/over_time, sum by (…), thresholds — are mapped one-to-one into the target language.
-
Isolate what can't map.
Log-only LogQL pieces — line filters, parsers, line_format — are separated out, since PromQL has no equivalent for them.
-
Emit the translation.
The rewritten query is rendered in the target language, ready to copy into Grafana, a rule file or an alert.
-
Report the notes.
Anything lossy or unmappable is surfaced as a plain-language note, so you know exactly what to verify by hand.
What Maps
What translates, and what doesn’t.
Metric queries share grammar and map cleanly. Log queries — the part that reads raw lines — are where the two languages part ways. Here is the honest split.
Maps cleanly
Label matchers, range-vector functions (rate, increase, count_over_time), aggregation operators with by / without grouping, and threshold comparisons all share near-identical syntax. The same shape in LogQL becomes the same shape in PromQL.
# LogQL metric query — error rate from a log stream
sum by (app) (
rate({app="checkout", env="prod"} |= "error" [5m])
) > 0.2 # PromQL — the same aggregation shape over a counter metric
sum by (app) (
rate(app_request_errors_total{app="checkout", env="prod"}[5m])
) > 0.2 Has no equivalent
PromQL only sees numeric samples, so the parts of LogQL that work on raw log text simply don’t exist on the other side. Line filters (|= "error"), parsers (| json, | logfmt), line_format and label_format are reported as notes, never silently dropped.
# These LogQL pieces have NO PromQL equivalent:
{app="checkout"} |= "error" # line filter — PromQL sees samples, not lines
| json | line_format "{{.msg}}" # parsers + line_format reshape log text
| label_format level=`{{.severity}}` # label_format rewrites labels at query time Preview Engine
A note on accuracy: the in-browser translator is a preview engine that maps the common metric-query shapes — label matchers, range-vector functions like rate / count_over_time, aggregations with by / without, and threshold comparisons. It does not run a full LogQL or PromQL parser, and it can’t invent a metric name for a log-derived series. Treat its output as a strong first draft to review — not a guaranteed drop-in for production rules.
FAQ
Questions, answered.
Tap a question to expand the answer.
What does the LogQL ↔ PromQL Helper do?
It translates common metric-query shapes between Grafana Loki's LogQL and Prometheus' PromQL, in both directions. Paste a query, pick a direction, and the helper rewrites the selectors, range functions, and aggregations into the other language — then flags anything that cannot map cleanly. It runs entirely in your browser, with no account and no upload.
Does my query ever leave my browser?
No. The helper is 100% client-side. Your queries are parsed and rewritten inside your browser tab — nothing is sent to a server, and there is no signup. You can safely paste internal label names, namespaces, and service identifiers.
Can every LogQL query become a PromQL query (and vice versa)?
No, and the helper is explicit about it. LogQL and PromQL share the same matcher and aggregation grammar for metric queries, so shapes like rate(), count_over_time(), sum by (…) and threshold comparisons translate well. But LogQL log queries — line filters such as |= "error", label_format, line_format, and pattern/regexp parsers — have no PromQL equivalent because PromQL only sees pre-aggregated samples. Those parts are reported as notes rather than silently dropped.
What carries over cleanly between the two?
Label matchers ({app="checkout", env=~"prod|stage"}), range-vector functions (rate, irate, increase, *_over_time), aggregation operators (sum, avg, max, min, count, topk) with by/without grouping, and binary/threshold comparisons all share near-identical syntax. The helper maps these directly and leaves your label names and durations untouched.
Why convert between LogQL and PromQL at all?
Teams often run both Loki and Prometheus and want a metric they have proven in one to exist in the other — for example, turning a log-derived error rate in Loki into a recording rule shape they can reason about against Prometheus metrics, or porting a PromQL alert threshold into a LogQL equivalent over a log stream. The helper gives you a fast first draft plus a clear list of what to double-check.
What is the difference between LogQL and PromQL?
PromQL queries pre-aggregated numeric metrics stored in Prometheus; LogQL queries log streams in Grafana Loki and can derive metrics from them at query time. Both share identical label-matcher syntax and the same aggregation operators (sum, avg, max), but LogQL adds a trailing pipeline of filters and parsers — separated by | — that has no PromQL counterpart. The difference is the data model: numeric samples versus raw log lines.
How do I convert a PromQL query to LogQL?
Keep the label matchers as-is — LogQL stream selectors use the same {label="value"} syntax. Then wrap the selector in a range aggregation such as rate(), count_over_time(), or sum_over_time() and add a range like [5m]. Because Loki has no pre-existing metric series, you will also need to point the selector at a real log stream and often add a parser stage (| json or | logfmt) to extract the labels you want to group by.
Which PromQL functions do not map cleanly to LogQL?
Functions that assume pre-existing instrumented series do not translate directly. histogram_quantile has no direct LogQL counterpart (you would need quantile_over_time with an unwrapped label instead). irate() is approximated by rate() in LogQL, since Loki has no equivalent instant-rate function. PromQL binary vector matching on metric pairs is also more limited in LogQL, which operates on log streams rather than numeric series.
Is LogQL based on PromQL?
Yes. LogQL was deliberately modeled on PromQL: stream selectors use identical {label="value"} syntax and LogQL metric queries reuse the same aggregation operators — sum, avg, max, topk, by/without. The key addition is the log pipeline for filtering and parsing raw log lines, so engineers already familiar with PromQL can read LogQL metric queries with minimal adjustment.
Is this affiliated with Grafana Labs or Prometheus?
No. This is an independent, community tool and is not affiliated with or endorsed by Grafana Labs or the Prometheus project. Loki and Grafana are trademarks of Raintank, Inc.; Prometheus is a trademark of The Linux Foundation. The vendor names are used only to describe the query languages the helper translates.
More free, private DevOps tools.
The LogQL ↔ PromQL Helper sits alongside the rest of the OpsCanopy observability cluster — explain a PromQL query or test your Loki alert rules with AlertLint, all browser-based and private by default.
More in Observability
29 free tools, every one offline-capable — opscanopy.com works with no signup and nothing uploaded.
Want the whole set? Browse the full tools directory, or read why everything here runs entirely client-side.
Not affiliated with or endorsed by Grafana Labs or the Prometheus project. Loki and Grafana are trademarks of Raintank, Inc.; Prometheus is a trademark of The Linux Foundation.