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.
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>
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>
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>
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>
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>
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>
* 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>