16878 Commits

Author SHA1 Message Date
Bartlomiej Plotka
3155c95c1f
feat: add fgprof debug pprof (wall-time profiling capability) (#18027)
Signed-off-by: bwplotka <bwplotka@gmail.com>
2026-02-06 10:23:54 +00:00
Bartlomiej Plotka
5e46e77754
refactor: use Appender mock for otlptranslator tests (#17999)
Signed-off-by: bwplotka <bwplotka@gmail.com>
2026-02-06 09:51:40 +00:00
Ganesh Vernekar
fe5cb190e6
tsdb: Add metrics for stale series compaction (#17957)
Signed-off-by: Ganesh Vernekar <ganesh.vernekar@reddit.com>
2026-02-06 09:05:56 +00:00
Julien
eaf47798af
promql: fix panic with @ modifier on empty ranges (#18020)
When using the @ modifier with a timestamp that has no data, several
PromQL range functions were panicking with "index out of range [0]
with length 0". This was introduced by #16797 which changed function
signatures to use concrete types instead of interfaces.

The panic occurred because functions were accessing array elements
(matrixVal[0], vectorVals[0][0]) without checking if the arrays were
empty first.

Fixes #18018

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-02-06 08:30:15 +00:00
zenador
4321a5573c
Use custom annotation for histogram quantile monotonicity info to provide more details (#15578)
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
2026-02-05 18:35:48 +01:00
Bartlomiej Plotka
c8e7f4e2a6
tests: Unify TestDiskFillingUpAfterDisablingOOO and avoid hiding errors (#18017)
* tests: Unify TestDiskFillingUpAfterDisablingOOO and avoid hiding errors

Signed-off-by: bwplotka <bwplotka@gmail.com>

* addressed comments

Signed-off-by: bwplotka <bwplotka@gmail.com>

---------

Signed-off-by: bwplotka <bwplotka@gmail.com>
2026-02-05 16:11:35 +00:00
Julien
37058a3154
Merge pull request #17975 from roidelapluie/roidelapluie/openapistats
OpenAPI: Add support for stats
2026-02-05 10:55:44 +01:00
Matt
cf9d093f8f
prw2: Move Remote Write 2.0 CT to be per Sample; Rename to ST (start timestamp) (#17411) (#17600)
Relates to
https://github.com/prometheus/prometheus/issues/16944#issuecomment-3164760343

Signed-off-by: bwplotka <bwplotka@gmail.com>
Signed-off-by: matt-gp <small_minority@hotmail.com>
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
2026-02-05 10:40:45 +01:00
Eric Eastwood
f0f40b970d
Document special labels that affect scraping and targets (__address__, __scheme__, __metrics_path__, __scrape_interval__, __scrape_timeout__) (#17765)
Signed-off-by: Eric Eastwood <contact@ericeastwood.com>
2026-02-04 13:42:37 +01:00
Bryan Boreham
3c1ed25605
[DOCS] Merge pull request #17998 from bboreham/clarify-library
Explain more about using Prometheus as a Go library
2026-02-04 10:53:42 +00:00
Ben Kochie
8d491cc642
tsdb: Migrate multi-errors to errors package (#17768)
Modernize tsdb package by migrating multi-error handling
to the standard library errors package.
* Add a modernized CloseAll helper.

Signed-off-by: SuperQ <superq@gmail.com>
2026-02-04 10:41:57 +01:00
Ben Kochie
859abfb35d
Reduce CI duplication (#18008)
Only run CI on pushes to main and release branches. Avoids duplicate
runs between pull_request and push.

Signed-off-by: SuperQ <superq@gmail.com>
2026-02-04 10:40:56 +01:00
Bartlomiej Plotka
7769495a4a
refactor: switch OTLP handler to AppendableV2 (#17996)
* refactor: switch OTLP handler to AppendableV2

Signed-off-by: bwplotka <bwplotka@gmail.com>

* addressed comments

Signed-off-by: bwplotka <bwplotka@gmail.com>

---------

Signed-off-by: bwplotka <bwplotka@gmail.com>
2026-02-03 16:44:40 +00:00
Arve Knudsen
3c44ca757d
storage: fix ToError() to return nil for empty partial errors (#18002)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2026-02-03 16:58:02 +01:00
Julius Volz
dbfc635a5a
Merge pull request #17611 from prometheus/default-hide-alert-annotations
Hide alert annotations by default
2026-02-03 15:23:11 +01:00
Arve Knudsen
51d33be878
web: switch from gopkg.in/yaml to go.yaml.in/yaml (#17979)
Replace gopkg.in/yaml.v2 and gopkg.in/yaml.v3 imports with
go.yaml.in/yaml/v2 and go.yaml.in/yaml/v3 respectively.

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2026-02-03 14:15:35 +00:00
zenador
c0ad853750
promql: Make it possible to add custom details in annotations and summarise multiple of the same annotation (#15577)
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>
2026-02-03 15:12:02 +01:00
Bryan Boreham
02c68154bc
Merge pull request #17548 from linasm/improve-BenchmarkJoinQuery
PromQL: Improve BenchmarkJoinQuery
2026-02-03 11:53:08 +00:00
Bryan Boreham
e75c893305
Merge pull request #17986 from mdxabu/improve-test-error-handling
tests: improve error handling and helper attribution in main_test.go
2026-02-03 11:15:04 +00:00
Bryan Boreham
1d5486caaa Explain more about using Prometheus as a Go library
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2026-02-03 09:09:52 +00:00
Bartlomiej Plotka
44d772b4e7
refactor: use Appender mock for tests (#17992)
Signed-off-by: bwplotka <bwplotka@gmail.com>
2026-02-02 15:56:11 +00:00
Bartlomiej Plotka
076369fad0
refactor: move OTLP handler to separate file (#17990)
Signed-off-by: bwplotka <bwplotka@gmail.com>
2026-02-02 14:36:00 +00:00
Bartlomiej Plotka
848b16d686
test: Add benchmark without storage + fix skipRecording mock feature (#17987)
* test: Add benchmark without storage

Signed-off-by: bwplotka <bwplotka@gmail.com>

make bench fair

Signed-off-by: bwplotka <bwplotka@gmail.com>

tmp

Signed-off-by: bwplotka <bwplotka@gmail.com>

* Apply suggestions from code review

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

---------

Signed-off-by: bwplotka <bwplotka@gmail.com>
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2026-02-02 12:44:11 +00:00
Julien
717d37bbca
Merge pull request #17988 from roidelapluie/roidelapluie/fixsmoothing
promql: fix smoothed interpolation across counter resets
2026-02-02 13:40:41 +01:00
Bartlomiej Plotka
7429a75932
scrape: switch scrape manager to AppenderV2 (#17978)
Signed-off-by: bwplotka <bwplotka@gmail.com>
2026-02-02 12:12:06 +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
Bartlomiej Plotka
eefa6178fb
fix: fix rare race on empty head.initialized() vs head.initTime() (#17963)
* fix: fix rare race on empty head.initized() vs head.initTime()

Relates to https://github.com/prometheus/prometheus/issues/17941

Signed-off-by: bwplotka <bwplotka@gmail.com>

* Apply suggestions from code review

Co-authored-by: Owen Williams <owen.williams@grafana.com>
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* addressed comments

Signed-off-by: bwplotka <bwplotka@gmail.com>

---------

Signed-off-by: bwplotka <bwplotka@gmail.com>
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
Co-authored-by: Owen Williams <owen.williams@grafana.com>
2026-02-02 09:13:02 +00:00
Abu
0495130e06 tests: improve error handling in main_test.go
- Add t.Helper() to getCurrentGaugeValuesFor helper function for better
  error attribution in test failures
- Add require.NoError checks for os.WriteFile calls in TestRuntimeGOGCConfig
  and TestHeadCompactionWhileScraping to catch file write failures
- Strengthen error handling in TestDocumentation to assert command success
  rather than silently continuing on failure
- Improve log message clarity in TestAgentSuccessfulStartup to accurately
  describe early exit scenario

These changes improve test reliability and follow Go testing best practices.

Signed-off-by: Abu <abdullahfakrudeen2020@gmail.com>
2026-02-02 14:40:03 +05:30
Bartlomiej Plotka
9657c23c37
storage: optimized fanoutAppenderV2 (#17976)
* storage: add BenchmarkFanoutAppenderV2

Signed-off-by: bwplotka <bwplotka@gmail.com>

* fix: optimized fanoutAppenderV2

Signed-off-by: bwplotka <bwplotka@gmail.com>

* optimized more

Signed-off-by: bwplotka <bwplotka@gmail.com>

---------

Signed-off-by: bwplotka <bwplotka@gmail.com>
2026-02-02 07:04:30 +00:00
Arve Knudsen
d9db76631d
tsdb: fix flaky TestWaitForPendingReadersInTimeRange tests (#17985)
The tests were flaky because they used hard-coded time.After(550ms)
waits, which had only 50ms margin over WaitForPendingReadersInTimeRange's
500ms poll interval. On slow CI runners, this margin wasn't reliable.

Use synctest for deterministic time control:
- Wrap test logic in synctest.Test() to use fake time
- Use synctest.Wait() to let goroutines reach dormant state
- Use time.Sleep() to advance fake time past the poll interval
- No more timing-dependent assertions

This makes the tests both reliable and ~60x faster (0.05s vs 3s).

Fixes both TestWaitForPendingReadersInTimeRange and
TestWaitForPendingReadersInTimeRange_AppenderV2.

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2026-02-01 15:52:26 +00:00
bwplotka
6c18bba5c6 Revert "storage: add BenchmarkFanoutAppenderV2"
This reverts commit 91b0f353b0698b7e5c663383809d250a11cdcfb1.
2026-01-30 15:54:52 +00:00
bwplotka
91b0f353b0 storage: add BenchmarkFanoutAppenderV2
Signed-off-by: bwplotka <bwplotka@gmail.com>
2026-01-30 15:53:59 +00:00
Julien Pivotto
e2d028a46e OpenAPI: Add support for stats
An oversight on the OpenAPI specification; which did not include stats.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-01-30 14:21:03 +01:00
Bartlomiej Plotka
88f6ee4c8e
tests(scrape): add TestScrapeLoopAppend_WithStorage (#17937)
Signed-off-by: bwplotka <bwplotka@gmail.com>
2026-01-30 11:44:07 +00:00
Julien
22f6d5d335
Merge pull request #17970 from roidelapluie/roidelapluie/ffapiopenapi
Features API: Add OpenAPI 3.1 and 3.2
2026-01-29 21:18:04 +01:00
Julius Volz
0c543d5a41
Merge pull request #17969 from 1seal/relabel-steps-linear
web/api: compute relabel_steps in a single pass
2026-01-29 20:55:25 +01:00
Björn Rabenstein
5af895cda9
Merge pull request #17944 from prometheus/beorn7/doc
promqltest: Document testing for counter reset hints in histograms
2026-01-29 15:33:26 +01:00
Bartlomiej Plotka
0fc70f3a62
tsdb: kill unused mint,maxt tracking (#17967)
Signed-off-by: bwplotka <bwplotka@gmail.com>
2026-01-29 14:26:40 +00:00
Julien Pivotto
3bc688e5cb Features API: Add OpenAPI 3.1 and 3.2
Now that #17825 is merged.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-01-29 14:29:22 +01:00
Julien
75f94903b3
Add OpenAPI 3.2 specification generation for Prometheus HTTP API (#17825)
* Add OpenAPI 3.2 specification generation for Prometheus HTTP API

This commit introduces an OpenAPI specification for the Prometheus API.
After testing multiple code-generation servers with built-in APIs, this
implementation uses an independent spec file outside of the critical path.
This spec file is tested with a framework present in this pull request.

The specification helps clients know which parameters they can use and is
served at /api/v1/openapi.yaml. The spec file will evolve with the
Prometheus API and has the same version number.

Downstream projects can tune the APIs presented in the spec file with
configuration options using the IncludePaths setting for path filtering.

In the future, there is room to generate a server from this spec file
(e.g. with interfaces), but this is out of scope for this pull request.

Architecture:
- Core OpenAPI infrastructure (openapi.go): Dynamic spec building,
  caching, and thread-safe spec generation
- Schema definitions (openapi_schemas.go): Complete type definitions
  for all API request and response types
- Path specifications (openapi_paths.go): Endpoint definitions with
  parameters, request bodies, and response schemas
- Examples (openapi_examples.go): Realistic request/response examples
- Helper functions (openapi_helpers.go): Reusable builders for common
  OpenAPI structures

Testing:
- Comprehensive test suite with golden file validation
- Test helpers package for API testing infrastructure
- OpenAPI compliance validation utilities

The golden file captures the complete specification for snapshot testing.
Update with: go test -run TestOpenAPIGolden -update-openapi-spec

REVIEWERS: The most important thing to check would be the OpenAPI golden
file (web/api/v1/testdata/openapi_golden.yaml). Test scenarios are important
as they test the actual OpenAPI spec validity.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>

* Add OpenAPI 3.1 support with version selection

Add support for both OpenAPI 3.1 and 3.2 specifications with version
selection via openapi_version query parameter. Defaults to 3.1 for
broader compatibility

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>

* Enhance OpenAPI examples and add helper functions

- Add timestampExamples helper for consistent time formatting
- Add exampleMap helper to simplify example creation
- Improve example summaries with query details
- Add matrix result example for range vector queries

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>

* web/api: Add AtST method to test helper iterators

Implement the AtST() method required by chunkenc.Iterator interface
for FakeSeriesIterator and FakeHistogramSeriesIterator test helpers.
The method returns 0 as these test helpers don't use start timestamps

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>

* OpenAPI: Add minimum coverage test

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>

* OpenAPI: Improve examples handling

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>

---------

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-01-29 13:36:13 +01:00
1seal
79b553499a web/api: compute relabel_steps in single pass
Signed-off-by: 1seal <security@1seal.org>
2026-01-29 12:22:54 +00:00
Bartlomiej Plotka
36ea75d203
scrape: fix flaky appender test (#17962)
Fixes https://github.com/prometheus/prometheus/issues/17941

Signed-off-by: bwplotka <bwplotka@gmail.com>
2026-01-29 10:50:17 +00:00
Arve Knudsen
020a0b30a0
notifier: fix flaky TestStop_DrainingEnabled and TestStop_DrainingDisabled race conditions (#17938)
Fix flaky TestStop_DrainingEnabled and TestStop_DrainingDisabled tests.
The tests used real HTTP servers and real time, making them susceptible to
race conditions and timing-dependent failures.
The solution is to convert both tests to use synctest for deterministic fake time.

---------

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2026-01-29 08:07:32 +01:00
Arve Knudsen
00a7faa2e3
tsdb: fix division by zero in stale series compaction (#17952)
Guard the stale series ratio calculation by checking numSeries > 0
before computing the ratio. This prevents division by zero when
the head has no series.

Fixes #17949

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2026-01-29 08:06:00 +01:00
Arve Knudsen
dc34b90f93
otlptranslator: fix silently swallowed error in addSumNumberDataPoints (#17954)
The createAttributes error was incorrectly returning nil instead of err,
causing errors to be silently discarded. This could lead to silent data
loss for sum metrics during OTLP ingestion.

Fixes #17953

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2026-01-28 13:58:50 +01:00
Callum Styan
97e7ef802c
remote write: simplify readability of timeseries filtering by using the slices package (#14318)
* simplify readability of timeseries filtering by using the slices package

Signed-off-by: Callum Styan <callumstyan@gmail.com>

* ensure that BenchmarkBuildTimeSeries doesn't account for the building of
the actual proto in the benchmark results, we only care about the
buildTimeSeries call

Signed-off-by: Callum Styan <callumstyan@gmail.com>

---------

Signed-off-by: Callum Styan <callumstyan@gmail.com>
2026-01-28 11:47:34 +00:00
Bartlomiej Plotka
2597a12080
st: Add a hidden 'st-storage' feature flag for PROM-60 (#17907)
Signed-off-by: bwplotka <bwplotka@gmail.com>
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
2026-01-28 09:05:54 +00:00
George Krajcsovits
8047b05b3c
chore(codeowners): promote matt-gp external github user to owner of AWS SD (#17946)
Branch protection means they cannot merge PRs to main/release branches.
Branch protection means they cannot approve things outside their area for
PRs to main/release branches.

Also add sysadmind (Joe) as ower of aws, to make sure he gets notified.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2026-01-28 08:20:06 +01:00
Julius Volz
5399eb9526
Merge pull request #17947 from zenador/docs-promql-info-func-ignore-info-metrics
docs: promql: Update docs about ignoring info metrics
2026-01-27 21:31:49 +01:00
Jeanette Tan
df31bfd59d Update docs about ignoring info metrics
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
2026-01-28 02:48:07 +08:00