Commit graph

1455 commits

Author SHA1 Message Date
Bryan Boreham
02c68154bc
Merge pull request #17548 from linasm/improve-BenchmarkJoinQuery
PromQL: Improve BenchmarkJoinQuery
2026-02-03 11:53:08 +00:00
Julien Pivotto
55193c3058 promql: fix smoothed interpolation across counter resets
Fix incorrect interpolation when counter resets occur in smoothed range
selector evaluation. Previously, the asymmetric handling of counter
resets (y1=0 on left edge, y2+=y1 on right edge) produced wrong values.

Now uniformly set y1=0 when a counter reset is detected, correctly
modeling the counter as starting from 0 post-reset.

This fixes rate calculations across counter resets. For example,
rate(metric[10s] smoothed) where metric goes from 100 to 10 (a reset)
now correctly computes 0.666... by treating the counter as resetting
to 0 rather than producing inflated values from the old behavior.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-02-02 11:54:35 +01:00
beorn7
b812c6457d promqltest: Document testing for counter reset hints in histograms
Signed-off-by: beorn7 <beorn@grafana.com>
2026-01-27 14:53:38 +01:00
Arve Knudsen
65f8482335 fix(promql): prevent panic in trimStringByBytes on invalid UTF-8
Add bounds check to prevent index out of range panic when
trimStringByBytes receives a string containing only UTF-8 continuation
bytes (0x80-0xBF). Previously, the loop would decrement size below 0
when no valid rune start byte was found, causing a panic.

A malicious query string with only continuation bytes could crash
the Prometheus server via the ActiveQueryTracker before the query
was parsed or validated.

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2026-01-24 16:06:42 +01:00
Bartlomiej Plotka
0d116b0994
tests(teststorage): Close Storage in the helper (#17902)
Signed-off-by: bwplotka <bwplotka@gmail.com>
2026-01-23 08:41:35 +00:00
zenador
9a49316c59
promql: info function: fix unit test for ignoring info metrics themselves (#17911)
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
2026-01-22 15:24:41 +01:00
Björn Rabenstein
82fec75982
Merge pull request #17626 from aviralgarg05/fix-promqltest-counter-reset-hint-comparison
promqltest: Add optional counter reset hint comparison for native histograms
2026-01-22 15:03:20 +01:00
Bartlomiej Plotka
04a3ef75f2
chore: remove testutil.T which is no longer needed since Go 1.13 (#17903)
testutil.T was needed before https://go.dev/doc/go1.13#testingpkgtesting

Now it's inconsistent and confusing, so let's kill it.

Signed-off-by: bwplotka <bwplotka@gmail.com>
2026-01-21 13:02:58 +00:00
zenador
e3b6eee437
promql: info function: fix series without identifying labels not being returned (#17898)
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 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 / 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
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
* promql: info function: fix series without identifying labels not being returned

---------

Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
2026-01-20 16:53:27 +01:00
Julius Volz
1d3d98ed16
Merge pull request #17644 from prometheus/binop-fill-modifier
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 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 / 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
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
PromQL: Add `fill*()` binop modifiers to provide default values for missing series
2026-01-19 20:05:52 +01:00
Julius Volz
05440ffc3b Add a few fill modifier tests with keyword-like metric names
Signed-off-by: Julius Volz <julius.volz@gmail.com>
2026-01-16 20:11:38 +01:00
Julius Volz
d3b6e61487 Put binop fill modifiers behind a feature flag
Some checks failed
CI / Go tests (push) Has been cancelled
CI / More Go tests (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 / Build Prometheus for common architectures (push) Has been cancelled
CI / Build Prometheus for all architectures (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 / 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
Signed-off-by: Julius Volz <julius.volz@gmail.com>
2026-01-15 11:18:48 +01:00
Julius Volz
57dd1f18b4 Add fill modifier PromQL tests
Signed-off-by: Julius Volz <julius.volz@gmail.com>
2026-01-15 07:56:23 +01:00
Julius Volz
af3277f832 PromQL: Add fill*() binop modifiers to provide default values for missing series
Signed-off-by: Julius Volz <julius.volz@gmail.com>
2026-01-15 07:56:21 +01:00
György Krajcsovits
70bc06718d
feat(tsdb): new AppenderV2 and AtST interface for chunks
No implementation yet. Just to test the shape of the interface.
AtST is implemented for trivial cases, anything else is hard coded
to return 0.

Ref: https://github.com/prometheus/prometheus/issues/17791

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2026-01-14 13:15:09 +01:00
Julien Pivotto
de0a864b5c Fuzzing: Move to go fuzzing
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-01-12 12:59:10 +01:00
Julien
f0eaf596fe
Merge pull request #17743 from RushabhMehta2005/optimization/extend-floats-prealloc
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 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 / 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
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
promql: preallocate slice in extendFloats optimization
2026-01-09 12:40:00 +01:00
Arve Knudsen
16703766f4
promql: fix info() returning empty when filtering by overlapping labels (#17817)
When filtering by a label that exists on both the input metric and
target_info (e.g., info(metric, {host_name="orbstack"}) where host_name
exists on both), the function incorrectly returned empty results.

The bug was in combineWithInfoVector: when no new labels were added
(because they all overlapped with base metric labels), the code entered
the "no match" filtering block even though an info series WAS matched.

The fix checks len(seenInfoMetrics) == 0 to correctly identify when no
info series matched. If an info series matched (seenInfoMetrics is
non-empty), the series is kept even if no new labels were added.

Fixes #17813

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2026-01-09 10:04:37 +01:00
Vilius Pranckaitis
6a81e4441e
promql: avoid unnecessary Metric.Get() calls in functions.go (#17676)
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 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 / 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
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Moved some Metric.Get() calls in PromQL functions to avoid unnecessary label extraction.
In many cases, this work was done to extract metric name, and was only used if annotations were emitted.

In the same go I also replaced labels.MetricName with model.MetricNameLabel, since the former was deprecated.

Signed-off-by: Vilius Pranckaitis <vpranckaitis@gmail.com>
2026-01-08 11:58:05 +00:00
Rushabh Mehta
fc330642e4 promql: Preallocate slice in extendFloats
Signed-off-by: Rushabh Mehta <mehtarushabh2005@gmail.com>
2026-01-06 22:06:30 +05:30
Ben Kochie
e14795bbf4
Remove copyright date from headers (#17785)
Remove copyright dates from various files as part of [PROM-50].

[PROM-50]: https://github.com/prometheus/proposals/blob/main/proposals/0050-remove-copyright-dates.md

Signed-off-by: SuperQ <superq@gmail.com>
2026-01-05 13:46:21 +01:00
Julius Volz
9da9e6daf4
Merge pull request #17687 from ADITYATIWARI342005/fix/utf8
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 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 / 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
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
promql/parser: fix UTF-8 label quoting in format_query endpoint
2025-12-28 12:08:07 +01:00
Julien
48e6f6a751
Merge pull request #17670 from roidelapluie/roidelapluie/promql-range
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 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 / 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
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
PromQL: duration expression: add range()
2025-12-26 16:31:18 +01:00
aviralgarg05
119e75d78b promqltest: Properly distinguish explicit counter_reset_hint specification
This commit addresses the PR feedback for issue #17615. The previous
implementation could not distinguish between:
- No counter reset hint specified (meaning "don't care")
- counter_reset_hint:unknown explicitly specified (meaning "verify it's unknown")

Changes:
- Added CounterResetHintSet field to parser.SequenceValue to track
  whether counter_reset_hint was explicitly specified in the test file
- Modified buildHistogramFromMap to set this flag when the hint is
  present in the descriptor map
- Updated newHistogramSequenceValue helper and histogramsSeries
  functions to propagate the flag through histogram series creation
- Updated yacc grammar to use the new helper function
- Modified compareNativeHistogram to accept the flag and only compare
  hints when explicitly specified

This allows tests to:
1. Not specify a hint (no comparison, backward compatible)
2. Explicitly specify counter_reset_hint:unknown (verify it's unknown)
3. Explicitly specify counter_reset_hint:gauge/reset/not_reset (verify match)

Fixes #17615

Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2025-12-19 23:32:08 +05:30
Julien Pivotto
37b97a0200 PromQL: Fix collision in unary negation with non-overlapping series.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2025-12-17 11:03:55 +01:00
Julien Pivotto
b336889d8f PromQL: Fix collision in label_join and label_replace with non-overlapping series.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2025-12-16 16:58:53 +01:00
ADITYA TIWARI
3a82dcc6c5 promql/parser: simplify BinaryExpr label formatting
Signed-off-by: ADITYA TIWARI <adityatiwari342005@gmail.com>
2025-12-16 12:31:39 +00:00
Aditya Tiwari
301b9eff44 Update comments to clarify label formatting method
Signed-off-by: Aditya Tiwari <142050150+ADITYATIWARI342005@users.noreply.github.com>
2025-12-16 12:31:39 +00:00
ADITYA TIWARI
2e4f5e8cfc promql/parser: consolidate label quoting logic
refactors binary expression formatting to reuse writeLabels() instead
of maintaining separate joinLabels() function. adds comprehensive
UTF-8 label tests for all expression types

Signed-off-by: ADITYA TIWARI <adityatiwari342005@gmail.com>
2025-12-16 12:31:39 +00:00
ADITYA TIWARI
5b299ef99e fix/promql/parser: Fix utf-8 label quoting in format_query endpoint
Signed-off-by: ADITYA TIWARI <adityatiwari342005@gmail.com>
2025-12-16 12:31:39 +00:00
Julien Pivotto
29878f7b91 promql: Optimize mergeSeriesWithSameLabelset for common case
Add fast path that returns early when no duplicate labelsets exist,
avoiding allocations in the common case. For the merge case, simplify
collision detection by checking for duplicate timestamps after sorting
instead of building a timestamp map, reducing memory overhead.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2025-12-15 11:56:34 +01:00
Julien Pivotto
6efbb873c7 promql: Fix collision error with delayed name removal for non-overlapping series
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2025-12-12 14:50:29 +01:00
Julien Pivotto
d0b122a711 PromQL: duration expression: add range()
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2025-12-10 16:27:18 +01:00
Julius Volz
4cad87cae8 PromQL: Fix insufficient cardinality checking for filter ops
Generally, binary operations between two vectors fail if there is a many-to-one
or one-to-many matching situation between series within a match group and no
`group_left()` or `group_right()` modifier is present. For filter ops this is
also generally the case, but there can be situations where multiple series on
one side can match a single series on the other side, but only 0 or 1 of those
multiple series remains after the filter operator has been applied. In this
case, the PromQL engine does not produce a matching error, since it only tracks
series matching for those series that survive the filtering. IMO this is
incorrect behavior (which can also erratically make a query sometimes fail and
sometimes succeed, depending on current sample values), and we should always
produce an error if there is a match error prior to applying the filter op.

This PR ensures that we do the cardinality / match tracking independently of
the result of the filter operation.

Signed-off-by: Julius Volz <julius.volz@gmail.com>
2025-12-10 11:31:46 +01:00
Julien
f73aba34cd
Merge pull request #17427 from roidelapluie/roidelapluie/ffapi
API: Add a /api/v1/features endpoint
2025-12-10 10:14:03 +01:00
Julien Pivotto
a5671a002f API: Add a /api/v1/features endpoint
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2025-12-09 16:13:14 +01:00
dongjiang
3239723098
Update golangci-lint and add modernize check (#17640)
Some checks failed
buf.build / lint and publish (push) Has been cancelled
CI / Go tests (push) Has been cancelled
CI / More Go tests (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 / Build Prometheus for common architectures (push) Has been cancelled
CI / Build Prometheus for all architectures (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
Scorecards supply-chain security / Scorecards analysis (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
* add modernize check

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>

* fix golangci lint

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>

---------

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
2025-12-05 09:29:10 +01:00
Julien
0279e14d4a
Merge pull request #17636 from roidelapluie/roidelapluie/starttime
Some checks failed
buf.build / lint and publish (push) Has been cancelled
CI / Go tests (push) Has been cancelled
CI / More Go tests (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 / Build Prometheus for common architectures (push) Has been cancelled
CI / Build Prometheus for all architectures (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
Scorecards supply-chain security / Scorecards analysis (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
Add start_timestamp field for unit tests
2025-12-04 10:47:24 +01:00
Jan Fajerski
ac5bdd66d7
Merge pull request #17634 from jan--f/sync-release-3.8
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 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 / 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
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Sync branch release-3.8
2025-12-03 21:26:45 +01:00
Julius Volz
39e11f50b2 Fix serialization for empty ignoring() in combination with group_x()
Currently both the backend and frontend printers/formatters/serializers
incorrectly transform the following expression:

```
up * ignoring() group_left(__name__) node_boot_time_seconds
```

...into:

```
up * node_boot_time_seconds
```

...which yields a different result (including the metric name in the result
vs. no metric name).

We need to keep empty `ignoring()` modifiers if there is a grouping modifier
present.

Signed-off-by: Julius Volz <julius.volz@gmail.com>
2025-12-03 14:15:16 +01:00
Julien Pivotto
1a853e23db Add start_timestamp field for unit tests.
This commit adds support for configuring a custom start timestamp
for Prometheus unit tests, allowing tests to use realistic timestamps
instead of starting at Unix epoch 0.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2025-12-03 11:20:23 +01:00
Jan Fajerski
fae20b73ff Merge branch 'release-3.8' into sync-release-3.8
Conflicts:
	storage/remote/write_handler.go
	storage/remote/write_handler_test.go
            Pick `main`

Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
2025-12-02 14:24:53 +01:00
aviralgarg05
488466246f promqltest: Fix test expectation for counter reset hint comparison
The test at line 1283 for avg_over_time(nhcb_metric[13m]) incorrectly
expected counter_reset_hint:gauge in the result. However, the actual
avg_over_time implementation does not explicitly set the CounterResetHint
to GaugeType on its output histogram.

With the new counter reset hint comparison logic added to the promqltest
framework (which compares hints when explicitly specified in expected
results), this incorrect expectation was now being caught.

This fix removes the incorrect counter_reset_hint:gauge from the expected
result, allowing the test to correctly verify the avg_over_time behavior
without asserting a specific hint value that the function does not set.

The counter reset hint comparison logic works as designed: if the expected
histogram has UnknownCounterReset (the default when not specified), no
comparison is performed. Only when a hint is explicitly specified in the
test expectation will it be compared against the actual result.

Fixes the test failure introduced by the counter reset hint comparison
feature in promqltest.

Signed-off-by: Aviral Garg <aviralg2106@gmail.com>
Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2025-11-30 18:07:51 +05:30
aviralgarg05
e894d7a271 promqltest: Add optional counter reset hint comparison for native histograms
This commit implements counter reset hint comparison in the promqltest
framework to address issue #17615. Previously, while test definitions
could specify a counter_reset_hint in expected native histogram results,
the framework did not actually compare this hint between expected and
actual results.

The implementation adds optional comparison logic to the
compareNativeHistogram function:
- If the expected histogram has UnknownCounterReset (the default),
  the hint is not compared (meaning "don't care")
- If the expected histogram explicitly specifies CounterReset,
  NotCounterReset, or GaugeType, it is verified against the actual
  histogram's hint

This allows tests to verify that PromQL functions correctly set or
preserve counter reset hints while maintaining backward compatibility
with existing tests that don't specify explicit hints.

Fixes #17615

Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2025-11-30 13:34:19 +05:30
harsh kumar
30be1483d1
instrumentation: add native histograms to complement high-traffic summaries (#17374)
This adds the following native histograms (with a few classic buckets for backwards compatibility), while keeping the corresponding summaries (same name, just without `_histogram`):

- `prometheus_sd_refresh_duration_histogram_seconds`
- `prometheus_rule_evaluation_duration_histogram_seconds`
- `prometheus_rule_group_duration_histogram_seconds`
- `prometheus_target_sync_length_histogram_seconds`
- `prometheus_target_interval_length_histogram_seconds`
- `prometheus_engine_query_duration_histogram_seconds`

Signed-off-by: Harsh <harshmastic@gmail.com>
Signed-off-by: harsh kumar <135993950+hxrshxz@users.noreply.github.com>
Co-authored-by: Björn Rabenstein <github@rabenste.in>
2025-11-27 18:45:35 +01:00
Andrew Hall
7bb95d548c
promql: Ensure that rate/increase/delta of histograms results in a gauge histogram. (#17608)
Some checks failed
buf.build / lint and publish (push) Has been cancelled
CI / Go tests (push) Has been cancelled
CI / More Go tests (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 / Build Prometheus for common architectures (push) Has been cancelled
CI / Build Prometheus for all architectures (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
Scorecards supply-chain security / Scorecards analysis (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
Signed-off-by: Andrew Hall <andrew.hall@grafana.com>
2025-11-26 18:18:01 +01:00
Faustas Butkus
e43f1bafca
chore: fix rangeEval comment (#17607)
Signed-off-by: Faustas Butkus <faustas.butkus@chronosphere.io>
2025-11-25 09:06:30 +00:00
Andrew Hall
1193e63896
PromQL: Modify RatioSampler to expose more methods for the benefit of downstream projects (#17516)
Methods added:
- `SampleOffset(metric *labels.Labels) float64` to calculate the sample offset for a given label set.
- `AddRatioSampleWithOffset(ratioLimit, sampleOffset float64) bool` to find out whether a given sample offset falls within a given ratio limit.

The already existing method `AddRatioSample(ratioLimit float64, sample *Sample) bool` is now implemented as a simple combination of the two other methods. Exposing these methods helps downstream projects to re-use the implementations including easier testing.

Signed-off-by: Andrew Hall <andrew.hall@grafana.com>
2025-11-18 15:44:40 +01:00
Linas Medziunas
de084ae0e7 [PromQL] Improve BenchmarkJoinQuery
Signed-off-by: Linas Medziunas <linas.medziunas@gmail.com>
2025-11-18 12:06:32 +02:00
zenador
c64dd612ef
PromQL: Fix bug with inconsistent results for queries with OR expression and EnableDelayedNameRemoval (#17161)
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
Signed-off-by: zenador <zenador@users.noreply.github.com>
Co-authored-by: Björn Rabenstein <github@rabenste.in>
2025-11-15 21:07:36 +01:00