Skip to content

Fix RW2 exemplars to be attached to samples per spec#18014

Open
AftAb-25 wants to merge 1 commit intoprometheus:mainfrom
AftAb-25:fix/rw2-exemplars-attached-to-samples
Open

Fix RW2 exemplars to be attached to samples per spec#18014
AftAb-25 wants to merge 1 commit intoprometheus:mainfrom
AftAb-25:fix/rw2-exemplars-attached-to-samples

Conversation

@AftAb-25
Copy link
Copy Markdown

@AftAb-25 AftAb-25 commented Feb 5, 2026

Fixes #17857

[BUGFIX] Remote Write: Fix RW2 exemplars to be attached to samples in the same TimeSeries per spec.

Which issue(s) does the PR fix:

  1. Modified populateV2TimeSeries to:
    Match exemplars with their corresponding samples/histograms by series labels
    Attach exemplars to the same TimeSeries as their samples/histograms
    Drop exemplars that don’t have matching samples/histograms (per spec)

2.Updated the TimeSeries count logic:
Changed from nPendingSamples + nPendingExemplars + nPendingHistograms
To nPendingSamples + nPendingHistograms (since exemplars no longer create separate entries)

3.Updated tests:
Modified the "exemplars only" test case for V2 to expect that exemplars are dropped when there are no matching samples

Does this PR introduce a user-facing change?

Yes, this PR introduces a user-facing change, but it's a bug fix.

What changes
1.Exemplars are now attached to samples in the same message (per spec)
2.Exemplars without samples are dropped (per spec)
Impact
1.Receivers that follow the RW 2.0 spec: no change needed
2.Receivers relying on the old buggy format: may need updates

The implementation now correctly follows the RW 2.0 spec where exemplars are attached to samples in the same TimeSeries message, similar to how scrape protocols and OTLP handle exemplars.

Previously, exemplars were sent as separate TimeSeries entries without
samples, which violates the Remote Write 2.0 specification requirement
that 'At least one element in samples or in histograms MUST be provided'.

This change modifies populateV2TimeSeries to:
- Match exemplars with their corresponding samples/histograms by series labels
- Attach exemplars to the same TimeSeries as their samples/histograms
- Drop exemplars that don't have matching samples/histograms (per spec)

The implementation now correctly follows the RW 2.0 spec where exemplars
are attached to samples in the same TimeSeries message, similar to how
scrape protocols and OTLP handle exemplars.

Fixes prometheus#17857

Signed-off-by: aftab <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(sending RW2): RW2 sends disconnected exemplars without samples

1 participant