Repository navigation
test(logql): LogQL parity harness against Loki (M4, #923) - #1117
Open
Guess-Who-sec wants to merge 7 commits into
Open
Guess-Who-sec wants to merge 7 commits into
Guess-Who-sec wants to merge 7 commits into
Conversation
metrico#920) The integration workflow built, started and tested gigapipe with raw commands. It now runs make build, make integration-start and make test-integration, and test/integration/run.sh runs the same make test-integration, so CI and local runs are the same commands. integration-start waits up to 60s for /api/v1/status/buildinfo and prints gigapipe.log if gigapipe never answers.
run.sh changed to the repository root before running the tests, but the EXIT trap runs `docker compose -f docker-compose.yml` with a relative path, so teardown failed (hidden by `|| true`) and left the gigapipe and ClickHouse containers running after every run. Run the tests in a subshell so the trap still runs from test/integration.
…/4, metrico#920) Add test/integration/seed, a deterministic declaration of the data the integration tests write: services and pods, from which every signal is derived. Logs are generated with a fixed random seed, so the same fixture always produces the same push body; Run only sets the m2_run label that keeps one run's data apart from earlier runs. TestLogsRoundTrip pushes the fixture through /loki/api/v1/push and checks what the Loki read APIs return against it, one named case each: every line per stream, a line filter, the json parser with a label filter, count_over_time per pod, labels, label values and series. The query_range, instant query, label values and series responses are also compared with pinned copies under testdata/logs/, since that JSON is what Grafana reads. Run-specific values (the run label, timestamps) are normalized before the comparison. The pins are maintained by hand; there is no regeneration mode. gigapipe's labels endpoint ignores the query parameter Loki uses to narrow it to a selector, so that case cannot be limited to one run; the series case covers the label sets.
Run the PromQL compliance suite with a real Prometheus 3.15.1 as the reference and gigapipe built from this tree as the target. Gigapipe doesn't scrape, so its target scrapes the suite's replayer itself, remote-writes the samples and proxies the queries. `make parity-prom` prints how many queries agree; it is report-only for now. The suite lives in its own module under compatibility/prometheus, so gigapipe's go.mod and binary are unchanged.
baseline.json records the state of all 660 compliance queries (529 agree, 131 differ) and why each difference exists. `make parity-prom-check` fails when a query changes state: a query that agreed now differs, a query that differed now agrees, a baselined query didn't run, or a new query isn't in the baseline. `make parity-prom-baseline` rewrites the file and keeps its reasons. `make parity-prom` stays report-only. run.sh now saves `go test -json` output and hands it to the checker in compatibility/ratchet, which it builds before the suite runs. The checker is in gigapipe's main module (standard library only) so the LogQL and TraceQL parity harnesses can use it too; -test names the parity test whose results it reads, TestPromQLParity by default. Reasons for the 131 differences, facts only: - 113: the target sends no native histograms - 15: the reference Prometheus drops the 7 oldest replay snapshots - 3: gigapipe disables negative offsets (PQRC001)
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
compatibility/loki sends the in-house LogQL queries in queries.txt, written from the LogQL docs and grouped by docs section, to a real Loki 3.7.10 (pinned by image digest) and to gigapipe built from the tree, both fed the M2 seed's 17 log lines, and compares the normalized answers. `make parity-logql` reports, `make parity-logql-check` fails when a query changes state since baseline.json (shared compatibility/ratchet, -test TestLogQLParity), and `make parity-logql-baseline` rewrites it. The reference Loki has discover_log_levels off: with it Loki adds a detected_level label that gigapipe doesn't. service_name discovery stays on, since gigapipe adds the same label. Lines that share a timestamp within one stream are compared sorted by text: LogQL defines no order among them, and `keep` merges streams whose lines share timestamps. Today 44 of 67 queries agree. The 23 differences are recorded with what was measured: 8 unwrapped label kept (metrico#1082), 2 zero-valued group left out (metrico#1081), 8 HTTP 500 from gigapipe (parse errors or unsupported), and 5 behaviour differences (regex anchoring, logfmt on JSON lines, two label_format cases, sum_over_time grouping that Loki rejects).
Guess-Who-sec
force-pushed
the
test/m4-logql-parity
branch
from
November 20, 2026 15:00
e754dfc to
7c45021
Compare
This was referenced Nov 20, 2026
Contributor
|
Please don't hardcode versions in scripts or the README, I don't want to update them by hand. Put the Loki image in a compose file and have |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #923 (M4): the LogQL parity harness, with its first query list and baseline.
Depends on #1061 (M2 seed) and #1112 (shared checker, which needs #1069): this branch is built on them, so its first 6 commits are theirs (#1061: 3, #1069: 2, #1112: 1). Merge those first; I'll rebase this one onto
masterthen. Only the last commit is new here.As you decided: the query list is written in-house from the LogQL docs, like the planned TraceQL list. Nothing comes from Loki's code or its
logqlbenchqueries. Loki itself is used only as an unmodified Docker image to compare answers with.What it does
make parity-logqlstarts a real Loki 3.7.10 (pinned by image digest) and gigapipe built from the tree, pushes the same logs to both, sends every query incompatibility/loki/queries.txtto both, and compares the answers. Same shape as the PromQL harness:make parity-logql-checkfails when a query changes state sincebaseline.json(the shared checker from test(prom): PromQL parity baseline and ratchet (M3, #922) #1112,-test TestLogQLParity)make parity-logql-baselinerewrites the baseline and keeps its reasonsmake parity-logqlonly reportsData: the M2 seed fixture, 4 log streams (checkout p1, p2, p3 with 4, 7 and 1 lines; payments p1 with 5), 17 JSON lines with
level,msg,latency_ms,seq. The test waits until both servers return all 17 lines before asking anything.Queries: 67, each under the docs section it exercises (
## log_queries > Line filter expression): stream selectors, line filters, the five parsers, label filters,line_format,label_format,drop,keep, log range aggregations, offset, unwrapped range aggregations, vector aggregations,vector().go test ./compatibility/loki/checks the file's format without any server.Comparison: both answers are normalized the same way (run label value, timestamps as offsets, numbers compared as numbers, series sorted by labels except for
sort/sort_desc) and compared exactly. Lines that share a timestamp inside one stream are sorted by text, because LogQL defines no order among them (see Verification). Error answers are compared by HTTP status only. Full answers of every differing query are saved toout/answers/for triage.Location:
compatibility/loki/, in gigapipe's main module. Unlike the PromQL harness it needs no new dependencies, so there's no separatego.mod. The server test and the code that talks to the servers (server.go) have the build tagparity, so CI's normalgo test ./...andmake lintsee only the query parser, the normalizer and their unit tests.Reference Loki settings (a question for you)
loki.yamlturns off one Loki ingestion feature,discover_log_levels. With it, Loki adds adetected_levellabel to every line and splits each stream by level; gigapipe doesn't. Measured: with it on, 61 of 67 queries differ.discover_service_namestays at Loki's default: Loki then addsservice_namefromapp, and so does gigapipe. Measured: with it off, 58 differ. Is turning off level detection OK, or should gigapipe's answers be compared with it on?Result today: 44 agree, 23 differ
Every difference is recorded in
baseline.jsonwith what was measured; none isunclassified. Whether each one is a bug is your call. "not filed" means there is no issue yet.sum,avg,max,min,first,last,quantile,rateoverunwrap latency_ms): gigapipe keeps thelatency_mslabel; with it removed the answers are identical (checked, 17 series each)stddev/stdvar by (app): gigapipe leaves out payments, whose value is 0; the other group is equalsort,sort_desc: gigapipe HTTP 500, parse errorstddev_over_time,stdvar_over_timeon unwrap: gigapipe HTTP 500, "… is not supported for this query"| pattern: gigapipe HTTP 500, parse error| unpack: gigapipe HTTP 500, parse errorand): gigapipe HTTP 500, parse error… or vector(0): gigapipe HTTP 500, parse error{app=~"check"}: Loki matches the whole value (docs: fully anchored) and returns nothing; gigapipe matches part of it and returns checkout| logfmton JSON lines: gigapipe adds labels made from the line text; Loki adds nonelabel_format severity=level: Loki (docs: rename) dropslevel; gigapipe keeps itlabel_format kind="{{.level}}-{{.app}}": gigapipe returns the template text instead of filling it insum_over_time(… unwrap …) by (app): Loki rejects it (HTTP 400, "grouping not allowed for sum_over_time"); gigapipe answersShould I open issues for the 13 "not filed" differences? (One issue per row, 11 issues in all; the two
sortqueries and the two stddev/stdvar_over_time queries would share one each.) Or would you rather some of them stay recorded only in the baseline, for example if gigapipe is not meant to supportpatternorunpack?Verification
make parity-logql-check3 runs, allmatches the baseline (67 queries); regenerating the baseline keeps every reason| json | keep app, levelfirst differed in 1 of 3 full runs, and in 7 of 8 runs against one stack. Cause, checked on the saved answers:keepmerges the three checkout pods into one stream, their lines share timestamps, and the two servers return lines with the same timestamp in different orders (same lines, same timestamp sequence). LogQL defines no order there, so the harness now sorts such ties; after that, 10 of 10 agree.!=behave like|=inplanner_line_filter.gofails the check naming exactly the two!=queries; reverted-race): the query file, malformed query lists, and normalization of streams, matrices, vectors, scalars, number formats, result order, and timestamp ties (ties sorted, different timestamps still compared)gofmt,go vetwith and without-tags parity(no new findings compared with the base),CGO_ENABLED=0 go build, rootgo test ./...(39 packages)staticcheckboth without the tag (as CI'smake lintruns) and with-tags parity: 0 issues eachcleanupis never called, a false positive sincetrap cleanup EXITcalls it, and the PromQL harness'srun.shgets the same notePotential risks
make parity-logql-checkruns it, like the PromQL harness, so a regression is caught only when someone runs it. Adding it to CI would need Docker in the pipeline, about a minute per run. I'd leave that for later, unless you want it now.discover_log_levelsbeing off (see the question above). If gigapipe should match Loki with its defaults, 61 of 67 queries differ today, not 23.Fixed settings (a question for you)
Like the PromQL harness, the settings are written into the code rather than configurable:
run.sh: the Loki image, the Loki port, the container and stack names, and the wait and test timeoutslimit=1000, the query window (one minute before the data to three minutes after, instant queries at +2 minutes), the 30-second step, and the setup and HTTP timeoutssort/sort_descare recognised by the query text starting withsortToday this is fine: the data is 17 lines ending at +60 seconds. But two of these settings would fail with a misleading message if the data grows past 1000 lines or past +3 minutes. The setup wait counts lines with the same limit and window, so it times out with "returns N of the M lines written". That reads like an ingestion bug and doesn't say which setting to change.
Should I make both harnesses (PromQL and LogQL) more configurable in a follow-up PR? That would mean:
LOKI_IMAGE=… make parity-logql-baselineto try an upgradeI left it out of this PR to keep the two harnesses alike and this PR focused.