Commit graph

2699 commits

Author SHA1 Message Date
Junker der Provinz
091e3a9243
Merge pull request #19124 from junkerderprovinz/validate-stats-param
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests for 32-bit x86 (push) Waiting to run
CI / List active LTS releases (push) Waiting to run
CI / Go tests for Prometheus upgrades and downgrades (push) Blocked by required conditions
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Compliance testing (push) Waiting to run
CI / Build Prometheus for common architectures (push) Blocked by required conditions
CI / Build Prometheus for all architectures (push) Blocked by required conditions
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
govulncheck / Run govulncheck (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
api: deprecate unsupported values of the `stats` query parameter

Anything other than "true" and "all" earn the caller a warning of deprecation. To be enacted in Prom 4.0.
2026-07-15 08:31:04 +02:00
George Krajcsovits
30aa810b61
Merge pull request #19125 from junkerderprovinz/fix-teststats-windows
web/api: fix TestStats failing on Windows (timer granularity)
2026-07-14 11:08:01 +02:00
renovate[bot]
1d56153b8e
Upgrade consul/api to v1.33.7 (#19122)
Upgrade consul/api to v1.33.7, as well as serf to v0.10.4, to get rid of
vulnerable mapstructure dependency.

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2026-07-08 11:49:00 +02:00
junkerderprovinz
fd62cdb87d web/api: fix TestStats failing on Windows (timer granularity)
TestStats asserts EvalTotalTime > 0, but on Windows the monotonic clock
has millisecond-scale granularity, so evaluating the trivial test query
legitimately measures 0 and the stats_is_true / stats_is_all subtests
fail on every run. CI does not catch this because the Windows job
excludes the web packages; it bites anyone developing on Windows with
a plain `go test ./...`.

Relax the assertion to GreaterOrEqual, matching the SamplesRead
assertion right below it. The non-nil Timings check already proves the
timings were populated.

Signed-off-by: junkerderprovinz <jdp@braethoria.com>
2026-07-07 13:35:10 +02:00
Julien Pivotto
b4741eeb99
promql: promote first_over_time to stable
Remove the Experimental flag from first_over_time and move it into the
stable *_over_time function lists in the docs and UI function reference.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-07-03 16:44:27 +02:00
George Krajcsovits
bfc70fef19
Merge pull request #19068 from prometheus/krajo/merge-release-3.13-to-main
merge release 3.13 to main
2026-07-02 12:36:13 +02:00
renovate[bot]
02e067c61e
chore(deps): update typescript-eslint monorepo to v8.62.1 (#18754)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-01 17:48:03 +02:00
György Krajcsovits
39f54360ee
Merge remote-tracking branch 'origin/release-3.13' into krajo/merge-release-3.13-to-main 2026-07-01 16:18:37 +02:00
renovate[bot]
1718bc82d5
chore(deps): update dependency http-proxy-middleware to v3.0.7 [security] (#18970)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-01 13:42:20 +02:00
Bryan Boreham
bc962a2c49
Merge pull request #18417 from mmorel-35/revive-enable-default-rules
chore: fix unnecessary-format issues from revive
2026-07-01 12:40:36 +01:00
George Krajcsovits
40af9c2cdc
Merge pull request #19047 from prometheus/krajo/prep-release-3.13
Some checks failed
CI / Go tests (push) Has been cancelled
CI / More Go tests (push) Has been cancelled
CI / Go tests for 32-bit x86 (push) Has been cancelled
CI / Go tests for Prometheus upgrades and downgrades (push) Has been cancelled
CI / Go tests with previous Go version (push) Has been cancelled
CI / UI tests (push) Has been cancelled
CI / Go tests on Windows (push) Has been cancelled
CI / Mixins tests (push) Has been cancelled
CI / Compliance testing (push) Has been cancelled
CI / Check generated parser (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
CI / fuzzing (push) Has been cancelled
CI / codeql (push) Has been cancelled
CI / Build Prometheus for common architectures (push) Has been cancelled
CI / Build Prometheus for all architectures (push) Has been cancelled
CI / Report status of build Prometheus for all architectures (push) Has been cancelled
CI / Publish main branch artifacts (push) Has been cancelled
CI / Publish release artefacts (push) Has been cancelled
CI / Publish UI on npm Registry (push) Has been cancelled
chore: prepare release 3.13
2026-07-01 12:43:14 +02:00
Julius Volz
6f84549425
Merge pull request #18706 from akshajrawat/ui/rule-health-copy-button
web/ui: add copy button for rule names in rules and alerts page
2026-07-01 09:44:25 +02:00
Matthieu MOREL
e098647095 chore: fix unnecessary-format issues from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2026-07-01 07:08:20 +00:00
Akshaj Rawat
3e6e41d39e fix: show copy alert button only on hover or focus-within
Signed-off-by: Akshaj Rawat <akshajr11@gmail.com>
2026-06-30 13:10:27 +00:00
Julien Pivotto
352e36a760
promql: enable duration expressions by default
Duration expressions no longer require the promql-duration-expr feature
flag, which is now a no-op in both prometheus and promtool. The parser
option (ExperimentalDurationExpr) is kept and enabled by default in the
binaries, so downstream consumers of the parser can still keep it off.

Move the documentation from the feature flags page into the PromQL
querying basics.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-29 14:32:14 +02:00
Julien
8a29562305
Merge pull request #18625 from roidelapluie/feat-promql-duration-expression
UI: Support arithmetics in duration expression
2026-06-29 11:55:12 +02:00
Julien Pivotto
4836db84d3
ui/codemirror-promql: compare DurationRange by node id
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-29 11:36:39 +02:00
Julien Pivotto
29ec2cc32c
ui/codemirror-promql: pass node ids to getChild/getChildren in parser
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-29 11:30:59 +02:00
Julien Pivotto
25eaa9f358
ui/codemirror-promql: pass DurationExpr node id to getChild
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-29 11:13:13 +02:00
David Herges
c9272348b7 web/ui: render delete series form if admin api flag is enabled
Signed-off-by: David Herges <dherges@users.noreply.github.com>
2026-06-27 13:49:32 +00:00
Akshaj Rawat
8e6728155c fix: show copy rules button only on hover or focus-within
Signed-off-by: Akshaj Rawat <akshajr11@gmail.com>
2026-06-27 13:05:28 +00:00
Julien Pivotto
55556cbd06
ui/mantine-ui: format full sub-expression in min_of/max_of notes
Lead each min_of/max_of explanation with the fully formatted
sub-expression instead of a bare op() so nested occurrences of the same
operator stay distinguishable, e.g. foo[max_of(1, max_of(2, 3))]. Add a
test covering the nested case.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-25 14:53:07 +02:00
Julien Pivotto
77f88c9ec6
ui/mantine-ui: make duration-expression AST fields required | null
Drop the optional `?` on rangeExpr/offsetExpr/stepExpr and use the
existing `| null` convention so the compiler flags every construction
site that forgets to set them. This surfaced a latent bug in Graph.tsx
where the matrixSelector-to-vectorSelector conversion silently dropped
offsetExpr; it now carries the value over.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-25 14:52:55 +02:00
George Krajcsovits
4d88e31cc3
Merge pull request #19007 from prometheus/krajo/merge-rlease-3130rc1-to-main
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests for 32-bit x86 (push) Waiting to run
CI / Go tests for Prometheus upgrades and downgrades (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Compliance testing (push) Waiting to run
CI / Build Prometheus for common architectures (push) Blocked by required conditions
CI / Build Prometheus for all architectures (push) Blocked by required conditions
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
govulncheck / Run govulncheck (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
merge release 3.13.0-rc.1 to main
2026-06-23 12:53:05 +02:00
renovate[bot]
c59797d579
fix(deps): update module github.com/pb33f/libopenapi-validator to v0.13.11 (#18987)
* fix(deps): update module github.com/pb33f/libopenapi-validator to v0.13.11

* build: bump go.work go directive to 1.25.7 to match go.mod

libopenapi v0.38.1 and libopenapi-validator v0.13.11 declare go 1.25.7, which raised the root go.mod directive in the previous commit. The tracked go.work was left at 1.25.0.

A workspace's go directive must be >= every member module's, so Go commands (build, test, mod verify, lint) fail in workspace mode until go.work matches.

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

---------

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2026-06-23 10:17:01 +00:00
renovate[bot]
307d3bee63
fix(deps): update module github.com/prometheus/prometheus to v0.312.0 (#18881)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-23 08:52:23 +02:00
George Krajcsovits
bd96185f37
chore: prepare 3.13.0-rc.1 release (#19001)
Some checks failed
CI / Go tests (push) Has been cancelled
CI / More Go tests (push) Has been cancelled
CI / Go tests for 32-bit x86 (push) Has been cancelled
CI / Go tests for Prometheus upgrades and downgrades (push) Has been cancelled
CI / Go tests with previous Go version (push) Has been cancelled
CI / UI tests (push) Has been cancelled
CI / Go tests on Windows (push) Has been cancelled
CI / Mixins tests (push) Has been cancelled
CI / Compliance testing (push) Has been cancelled
CI / Check generated parser (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
CI / fuzzing (push) Has been cancelled
CI / codeql (push) Has been cancelled
CI / Build Prometheus for common architectures (push) Has been cancelled
CI / Build Prometheus for all architectures (push) Has been cancelled
CI / Report status of build Prometheus for all architectures (push) Has been cancelled
CI / Publish main branch artifacts (push) Has been cancelled
CI / Publish release artefacts (push) Has been cancelled
CI / Publish UI on npm Registry (push) Has been cancelled
Bump VERSION to 3.13.0-rc.1 and add the 3.13.0-rc.1 CHANGELOG section.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 16:44:30 +02:00
Julien Pivotto
84a7c1950c build: embed bundled web UI licenses instead of shipping a tarball
The mantine-ui Vite build now generates a third-party-licenses.txt via
rollup-plugin-license, collecting the notices of every npm package bundled
into the UI. The file is embedded in the binary and served at
/assets/third-party-licenses.txt.

This replaces the npm_licenses.tar.bz2 archive, which was built by sweeping
node_modules for license* files and shipped as a separate file in release
tarballs and Docker images.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-22 12:31:27 +02:00
György Krajcsovits
0e5b0eedfc
run make ui-bump-version
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2026-06-19 14:08:30 +02:00
Julien Pivotto
97295889e3 ui: use react-app-rewired to dedupe codemirror packages
The local codemirror-promql is consumed via pnpm's link: protocol and
carries its own node_modules, so its @codemirror/* and @lezer/* imports
resolve to a separate copy from react-app. That loads two instances of
@codemirror/state and breaks instanceof checks at runtime.

Add react-app-rewired with a config-overrides.js that aliases these
packages to react-app's single copy and drops CRA's ModuleScopePlugin
so the aliases take effect.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-19 12:59:52 +02:00
Julien
18fa2d8b8e
ui: link react-app to local codemirror-promql instead of an npm version (#18967)
Some checks are pending
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests for 32-bit x86 (push) Waiting to run
CI / Go tests for Prometheus upgrades and downgrades (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Compliance testing (push) Waiting to run
CI / Build Prometheus for common architectures (push) Waiting to run
CI / Build Prometheus for all architectures (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
react-app is not part of the pnpm workspace, so it pulled
@prometheus-io/codemirror-promql from the npm registry by exact version.
During a release, `make ui-bump-version` rewrote that pin to the new,
not-yet-published version, so the subsequent `pnpm install` failed with
ERR_PNPM_NO_MATCHING_VERSION.

Use pnpm's "link:" protocol to consume the locally built workspace package
instead. There is no version to publish or rewrite, react-app always builds
against the in-tree codemirror-promql, and its lockfile stays isolated (which
is why react-app was separated from the workspace in the first place).

build_ui.sh --all already builds the modules before react-app, so dist/ is
present at build time; `make ui-build` passes. Drop the dependency-rewriting
sed from ui_release.sh's bumpVersion accordingly.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-19 10:00:48 +02:00
Julien Pivotto
c6170da78a ui/codemirror-promql: offer duration units after a dangling digit in duration slots
When a complete duration is followed by a dangling digit (e.g. `go[5d1]`
or `go[5d:5d4]`), the parser emits an error node whose text is a non-empty
number. The user is building a compound duration, so keep offering duration
units instead of suggesting nothing. The empty slot case (`go[]`) still
offers no suggestions.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-18 13:12:14 +02:00
George Krajcsovits
6d0ecf7344
ui: update npm dependencies for 3.13 release (#18950)
Run `make update-npm-deps` to bump UI dependencies to their latest minor
versions (mantine 9.3.1, codemirror, typescript-eslint, rollup, prettier,
sass, sanitize-html and others).

The minor bump pulled in @codemirror/view 6.43.1 for the workspace's direct
dependencies while sibling @codemirror/* packages still resolved 6.43.0,
leaving two copies in the tree and breaking the TypeScript build (CodeMirror
requires a single @codemirror/view instance). Run `pnpm dedupe` in web/ui and
web/ui/react-app to collapse it to a single 6.43.1, which also removes other
duplicated subtrees. `make ui-build` passes.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 16:58:09 +02:00
George Krajcsovits
b84bd4a1e6
chore: update Go dependencies (#18949)
Run 'make update-all-go-deps' with the go1.25.0 toolchain to keep the
module compatible with the declared go 1.25.0 version.

Dependencies requiring a newer Go toolchain (k8s.io/*, google.golang.org/api,
github.com/pb33f/libopenapi*) were intentionally not upgraded.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 10:08:54 +00:00
George Krajcsovits
f579093cd8
chore: update Go dependencies for 3.13 release (#18938)
Run `make update-all-go-deps` with the Go toolchain pinned to 1.25.0
(`GOTOOLCHAIN=go1.25.0`) so the `go` directive stays at 1.25.0 and the
project keeps building with any Go 1.25.x. Dependency updates that would
raise their own minimum Go past 1.25.0 (Kubernetes v0.36.x, Consul
api >= v1.34, bufbuild/buf v1.70, google.golang.org/api v0.284) are left at
their current versions and can be picked up once the project moves to Go 1.26.

github.com/prometheus/common is updated to v0.68.1, which removed the
expfmt.WithUnit() encoder option (the unit is now written automatically when
set). Drop the now-removed option from the scrape manager test; it was a
no-op there because the test metric does not set a unit.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 11:39:43 +02:00
George Krajcsovits
3ea6c92a4c
Merge pull request #18927 from yashanil98/fix/issue-18841-sha256-rule-pagination-token
api: use SHA-256 for rule group pagination tokens
2026-06-16 14:49:54 +02:00
Julien
f8b921c084
Merge pull request #18797 from roidelapluie/roidelapluie/pnpm
chore(UI): Move to pnpm
2026-06-16 13:36:32 +02:00
Michael Hoffmann
143643b563 scrape: add more native-histogram related internal labels
This is a followup to our previous commit where we made convert_classic_histograms_to_nhcb
configurable at discovery time. We add the other native histogram labels
too here.

Signed-off-by: Michael Hoffmann <mhoffmann@cloudflare.com>
2026-06-15 13:17:46 +00:00
Bryan Boreham
121eaa1778
Merge pull request #18081 from DanCech/samples-read
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests for 32-bit x86 (push) Waiting to run
CI / Go tests for Prometheus upgrades and downgrades (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Compliance testing (push) Waiting to run
CI / Build Prometheus for common architectures (push) Waiting to run
CI / Build Prometheus for all architectures (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
govulncheck / Run govulncheck (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
promql: Add metric and stats to track total samples read per query

[FEATURE] PromQL: Expose per-query `samplesRead` (and `samplesReadPerStep` with `stats=all` and the `promql-per-step-stats` feature flag) in the query stats response, and add the `prometheus_engine_query_samples_read_total` engine counter. `samplesRead` reflects storage I/O distinct from `totalQueryableSamples`, which counts samples loaded into the evaluator (and so over-counts when a sample is reused across multiple range-vector windows).
[BUGFIX] PromQL: A range query whose `end` was not aligned to `step` caused subqueries inside it to evaluate past the parent's last actual step, inflating `peakSamples` in the query stats and against the `query.max-samples` limit, and wasting storage I/O reading samples that were never used in the result.
[BUGFIX] PromQL: A range query containing an at-modifier-unsafe function over a range-vector with an `@` modifier (e.g. `predict_linear(metric[60s] @ T, X)`) silently under-counted `totalQueryableSamples` for steps after step 0.
2026-06-15 13:26:56 +01:00
Yash Anil
8c41ca783e api: use SHA-256 for rule group pagination tokens
Replace the deprecated SHA-1 hash used to generate rule group pagination
tokens in getRuleGroupNextToken with SHA-256. The token is opaque and
compared server-side only, so this does not change the API contract. Add
a unit test covering the token format and determinism.

Fixes #18841

Signed-off-by: Yash Anil <yashanil98@gmail.com>
2026-06-14 16:35:47 -07:00
Julien Pivotto
b75f9bb61d ui/mantine-ui: clarify step() explain note resolves to 0 for instant queries
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-12 17:34:31 +02:00
Julien Pivotto
3b301bc229 ui/mantine-ui: match duration-expression note list font size
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-12 17:31:16 +02:00
Julien Pivotto
1418ade0b8 ui/codemirror-promql: only warn on top-level range() in subquery step
containsDurationRangeExpr scanned the whole step subtree, so a bounded
range() such as min_of(range(), 5m) wrongly triggered the not-meaningful
warning. Replace it with isTopLevelDurationRangeExpr, which checks only
the step DurationExpr's direct children, and add a regression test.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-12 17:25:49 +02:00
Julien Pivotto
ee2614fc68 ui/codemirror-promql: tidy duration autocomplete dedupe and tests
Remove two orphaned option-set constants from hybrid.test.ts that were
never asserted against. Reflow the grandParent type-id condition to
satisfy prettier. Include the string apply value in the dedupeCompletions
key so completions differing only by inserted text are not merged.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-12 17:25:49 +02:00
Julien Pivotto
7d59ef8c11 ui/lezer-promql: restore @ start()/end() modifier highlighting
The duration-expression change dropped AtModifierPreprocessors from the
modifier styleTags and added Start End, which are not grammar node names.
This removed highlighting for the @ start()/end() preprocessors while the
added entries were dead no-ops. Restore AtModifierPreprocessors and drop
Start End; keep the new DurationExpr styleTags line.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-12 17:25:49 +02:00
Julien Pivotto
0c0011fd22 ui/mantine-ui: share duration-expression explain notes and fix dedupe key
collectNotes and durationExprNote were duplicated verbatim in
ExplainView.tsx and Selector.tsx. The min_of/max_of dedupe key
interpolated formatDurationNode (which returns a ReactNode) into a
string, so both operands stringified to [object Object] and distinct
expressions collapsed to a single note.

Extract both helpers into a shared durationExprNotes module and build
the dedupe key from the string serializeDurationNode instead.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-12 17:25:36 +02:00
Julien Pivotto
1c7c6982ca ui/mantine-ui: serialize PromQL duration expressions in all slots
The display layer (format.tsx) renders duration expressions for matrix
ranges, subquery range/step, and offsets, but serialize.ts only handled
matrix ranges and rewrote them as max_of(<expr>,1s). Since serializeNode
builds the actual /query request for tree-view nodes, expressions were
dropped or altered, executing a different query than displayed.

Serialize rangeExpr/stepExpr/offsetExpr verbatim wherever present,
mirroring format.tsx, and drop the max_of(...,1s) rewrite. Export
serializeDurationNode for reuse. Add round-trip tests.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-12 17:25:31 +02:00
Julien Pivotto
8f58943059 ui/codemirror-promql: suppress completions in empty duration slots
When a duration slot is empty (matrix selector, subquery step, or offset
with nothing typed yet), offer no completions instead of the duration unit
list. Units are suggested once the user types a digit and duration-expression
functions once a letter is typed, which avoids noisy suggestions in positions
where no useful completion exists.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-12 17:04:24 +02:00
Julien Pivotto
a05561d7e6 ui/codemirror-promql: fix DurationExpr autocomplete noise in more positions
Three more cases where unwanted completions appeared:

1. Empty duration slot (`foo[]`, `foo offset `, `go[5d:]`): the cursor
   lands on the container node (MatrixSelector, OffsetExpr, SubqueryExpr)
   or on an error node inside those containers. DurationExpr functions
   were offered immediately. They are now stripped from all those
   "empty/bare-slot" paths; duration units remain. Functions appear once
   the user types a letter, via the Identifier/LabelName handler added
   previously.

2. Arithmetic mid-expression (`foo[5m+2ms+m`): an Identifier typed
   inside an error node that is itself inside a DurationExpr fell through
   to the general metric/function handler (DurationExpr is not in the
   Expr node group, so the containsChild guard did not fire). This
   produced metric completions like `mad_over_time`. Added an explicit
   DurationExpr parent check that short-circuits to DurationExpr
   suggestions only.

3. Import: DurationExpr type ID is now imported from lezer-promql and
   used for all parent checks instead of the string .name comparison.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-12 17:00:38 +02:00
Julien Pivotto
9b7b085f40 ui/codemirror-promql: tighten DurationExpr autocomplete triggers
Operators and function names are no longer offered as soon as the user
enters a duration number (e.g. typing `5` inside `[…]`).  They now
appear only once the user has actually started typing them:

* Duration units (ms/s/m/…) are still the sole suggestions while a
  bare number is being typed.
* After a complete duration atom (e.g. `5m`) the popup is silent; no
  stale operator/function suggestions bleed through when the user is
  still adding unit chars (fixing the `5m` → `5ms` noise).
* Arithmetic operators (`+`, `-`, `*`, `/`, `%`, `^`) are suggested
  once the user types the first operator character inside a
  DurationExpr (cursor lands on the Add/Sub/Mul/Div/Mod/Pow token whose
  parent is DurationExpr).
* Duration-expression functions (`step()`, `range()`, `min()`, `max()`)
  are suggested once the user types the first letter of the function
  name: either from scratch in an empty duration slot (Identifier inside
  error inside MatrixSelector/OffsetExpr/SubqueryExpr) or after a
  complete duration atom (LabelName in the same contexts).

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-06-12 17:00:38 +02:00