* tsdb: fix prometheus_tsdb_head_chunks going negative after WAL replay
When truncateStaleSeries deletes a series (writing a full-range tombstone
to the WAL) and the same label set is immediately re-created, WAL replay
queues the following sequence on the same processor shard for the shared
memSeries pointer:
reset(mSeries, M mmappedChunks, walRef=old)
deleteSeriesByID(old)
reset(mSeries, N mmappedChunks, walRef=new)
deleteSeriesByID correctly subtracts M from the gauge but does not clear
series.mmappedChunks. The subsequent reset subtracts M again, driving
prometheus_tsdb_head_chunks negative when M > N.
Fix by setting series.mmappedChunks = nil in deleteSeriesByID after
accounting for those chunks.
Fixes#10884
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Jorge Creixell <jcreixell@gmail.com>
* Simplify test
- Re-use appending helper
- Cleanup comments
Signed-off-by: Jorge Creixell <jcreixell@gmail.com>
* Improve comments in test
Signed-off-by: Jorge Creixell <jcreixell@gmail.com>
* Fix formatting
Signed-off-by: Jorge Creixell <jcreixell@gmail.com>
* Improve comment
Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com>
Signed-off-by: Jorge Creixell <jcreixell@gmail.com>
---------
Signed-off-by: Jorge Creixell <jcreixell@gmail.com>
Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com>
* Add logic to Head.Init(...) for fast startup
Signed-off-by: Rushabh Mehta <mehtarushabh2005@gmail.com>
* Add unit tests
Signed-off-by: Rushabh Mehta <mehtarushabh2005@gmail.com>
* Empty commit to retrigger CI
Signed-off-by: Rushabh Mehta <mehtarushabh2005@gmail.com>
* Empty commit to retrigger CI
Signed-off-by: Rushabh Mehta <mehtarushabh2005@gmail.com>
* Make readSeriesStateFile return a struct directly, fix small nits, remove test
Signed-off-by: Rushabh Mehta <mehtarushabh2005@gmail.com>
* Fix test for readSeriesStateFile function
Signed-off-by: Rushabh Mehta <mehtarushabh2005@gmail.com>
* Fix some more nits, add extra testcase
Signed-off-by: Rushabh Mehta <mehtarushabh2005@gmail.com>
---------
Signed-off-by: Rushabh Mehta <mehtarushabh2005@gmail.com>
Add Outscale VM service discovery using osc-sdk-go, including optional secret_key_file support, metrics, docs, and configuration examples. Document the default region (eu-west-2).
Signed-off-by: Aurelien Duboc <aurelienduboc96@gmail.com>
Two cases in compactBuckets caused a panic when fed malformed histogram
data (e.g. via a crafted protobuf message):
1. All spans have zero length: after the zero-length span removal pass,
spans becomes empty. The subsequent loop called emptyBucketsHere(),
which accessed spans[0] and panicked with index out of range.
Fixed by the early return added in the previous commit (already on
this branch via the roidelapluie/histogram-compact-zero-spans fix).
2. More buckets than spans describe: iSpan can reach len(spans) before
all buckets are consumed, causing emptyBucketsHere() to access
spans[iSpan] out of bounds.
Fixed by adding iSpan < len(spans) to the loop guard.
Both fixes in compactBuckets are defensive layers. The primary fix is
in the protobuf parser: checkNativeHistogramConsistency now validates
that span total length matches bucket count before calling Compact(),
returning a proper error for malformed input instead of panicking.
Found by FuzzParseProtobuf.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
Add a new FuzzParseProtobuf fuzz target that exercises the protobuf
exposition-format parser
Reduce per-target fuzz time to 4m to keep budget acceptable with
the additional target.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
When last_over_time or first_over_time is applied to a subquery that
contains functions like abs(), round(), etc., the DropName flag should
be preserved. Previously, the flag was unconditionally overwritten based
solely on the function name, ignoring the input series state.
This fix checks if the input series (from a subquery) already has
DropName=true and respects that flag by using OR logic.
Before this fix:
last_over_time(abs(metric)[10m:]) incorrectly returned {__name__="metric", ...}
After this fix:
last_over_time(abs(metric)[10m:]) correctly returns {...} without __name__
The same behavior applies to first_over_time().
Fixes#18397
---------
Signed-off-by: Vamsi Mathala <vmathala@redhat.com>
Bump github.com/pb33f/libopenapi to v0.34.4, which upgrades github.com/buger/jsonparser
to v1.1.2 to address CVE-2026-32285.
Signed-off-by: Tomer Gabay <10978711+sTomerG@users.noreply.github.com>
Apply the same io.LimitReader guard (decodeReadLimit = 32 MiB) to the
OTLP write decoder that remote read already use, so that a gzip-encoded request
body cannot decompress to unbounded memory.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
This PR fixes minor grammar and wording issues in the README to improve clarity and readability.
Changes include:
- Fix capitalization ("You" → "you")
- Improve sentence clarity
No functional changes.
Signed-off-by: Prapti Gupta <gupta.prapti509@gmail.com>
The previous implementation relied on real wall-clock time and busy-loops
(time.Sleep + polling loops) to detect when compaction had finished, making
it both slow and flaky especially on busy CI envs and also on Windows due to timer imprecision).
Now both the subtests run on windows.
The delay value can be increased (1s → 5s) at zero cost to test runtime
Also cleaned up shared logic into small helpers and split the no-delay and
delay-enabled cases into separate subtests for clarity.
Signed-off-by: machine424 <ayoubmrini424@gmail.com>
This adds 'databases' role to digitalocean_sd_config to discover DigitalOcean
Managed Database clusters. It follows the multi-role design pattern by
introducing a 'role' parameter (default: 'droplets').
Includes:
- Support for Managed Databases API.
- Pagination handling for Databases API.
- Comprehensive meta labels for database targets.
- Updated documentation and tests.
Signed-off-by: Vladimir Skesov <skesov@gmail.com>
- Use an absolute path for the console templates directory to align with rules.
- Rewrite waitForPrometheus using require.Eventually for cleaner
error reporting and to fix a bug where the function could return nil
even when the server never became ready.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
* promql: add test for info() with data label matcher when info series goes stale
When info() is called with a data label matcher that doesn't match
the empty string (e.g. {data=~".+"}), samples at timestamps where
no info series is available should be dropped rather than falling
back to the original un-enriched series.
This case was missing from the test suite.
* docs: document info() behavior when info series is unavailable
Document that when no matching info series exists at a timestamp,
data label matchers that don't match the empty string cause the
sample to be dropped, while empty-matching matchers or no selector
return the series unenriched.
* promql: add test cases for info() fallback when info series goes stale
Add test cases for info(metric, {data=~".*"}) and info(metric) to
complement the existing info(metric, {data=~".+"}) test case, making
the behavioral contrast explicit: empty-matching matchers and no
selector fall back to the unenriched series, while non-empty-matching
matchers drop the sample.
---------
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Use the same dayjs + useLocalTime pattern from the query page's
TimeInput component so the datetime pickers respect the user's
global "use local time" setting. Adds valueFormat with seconds
precision and stores timestamps as milliseconds internally.
Signed-off-by: Vijay Govindarajan <vijay.govindarajan91@gmail.com>
Address review feedback from juliusv:
- Move delete series UI into the existing TSDB Status page instead of
creating a new top-level page, keeping the navigation minimal
- Use Textarea instead of TextInput for multi-line series selectors
- Use DateTimePicker from @mantine/dates for time range inputs
- Separate error/success states for delete vs clean tombstones
operations, showing alerts in the appropriate card
- Fix warning text to use quoted "Clean Tombstones"
- Remove standalone DeleteSeriesPage.tsx, revert App.tsx routing and
settingsSlice.ts changes
Signed-off-by: Vijay Govindarajan <vijay.govindarajan91@gmail.com>
Without this, navigating directly to /delete-series under a path
prefix (e.g. /prometheus/delete-series) would fail to detect the
prefix correctly.
Signed-off-by: Vijay Govindarajan <vijay.govindarajan91@gmail.com>
Adds a web UI page for the delete_series and clean_tombstones admin
APIs, making it easier to manage time series data without using curl
commands directly.
The page provides:
- A form to specify PromQL series selectors for deletion
- Optional start/end time range filters
- A clean tombstones button to reclaim disk space after deletion
- Warning and confirmation feedback
Fixes#17010
Signed-off-by: Vijay Govindarajan <vijay.govindarajan91@gmail.com>
getMagicLabel had no bounds check on the quantile slice for the Summary
case. fieldsDone for an empty-quantile summary is set inside Series(),
not getMagicLabel. A caller driving Next() without calling Series() at
the _sum step would allow fieldPos to advance to 0 and index into an
empty slice.
Add the same out-of-bounds guard that the histogram branch already has,
and a regression test that exercises Next()-only iteration over a
summary with no quantiles.
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
Add test cases for two edge cases in the info() function:
- Enrichment when inner series are missing one identifying label
- Conflicting labels across different info metrics should error
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
QueryForStateSeries built Select matchers from the raw rule labels,
which can contain Go template expressions such as
`instance_{{ $labels.instance }}`. The stored ALERTS_FOR_STATE series
carry the per-instance evaluated values (e.g. `instance_0`), so the
unevaluated template string never matched, leaving seriesByLabels empty
and silently skipping restoration for every active alert.
Fix by omitting any label whose value contains `{{` from the matcher
list. Static labels (including `__name__` and `alertname`) are never
templated and continue to scope the query to the correct rule. The
in-memory lookup against evaluated alert labels that follows is
unaffected, so the single-query-per-rule optimisation introduced in
#13980 is fully preserved.
Fixes#16883
Ref #13980
Ref #18364
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>