Skip to content

Support Start TimeStamp (ST) & Created Timestamp (CT) on PRW2#7371

Open
SungJin1212 wants to merge 6 commits intocortexproject:masterfrom
SungJin1212:Support-ST
Open

Support Start TimeStamp (ST) & Created Timestamp (CT) on PRW2#7371
SungJin1212 wants to merge 6 commits intocortexproject:masterfrom
SungJin1212:Support-ST

Conversation

@SungJin1212
Copy link
Member

@SungJin1212 SungJin1212 commented Mar 24, 2026

Prometheus has updated its model to use Start Timestamps (ST) at the sample/histogram level instead of Created Timestamps (CT) at the series level. This PR implements support for ingesting both start timestamps (ST) and created timestamps (CT, as a fallback for pre-Prometheus v3.8.0 model) via Prometheus Remote Write (PRW) 2.0.

Which issue(s) this PR fixes:
Fixes #7060

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@dosubot dosubot bot added the type/feature label Mar 24, 2026
@SungJin1212 SungJin1212 marked this pull request as draft March 24, 2026 08:43
Signed-off-by: SungJin1212 <tjdwls1201@gmail.com>
Signed-off-by: SungJin1212 <tjdwls1201@gmail.com>
@SungJin1212 SungJin1212 changed the title Support Start TimeStamp on PRW2 Support Start TimeStamp (ST) & Created Timestamp (CT) on PRW2 Mar 24, 2026
Signed-off-by: SungJin1212 <tjdwls1201@gmail.com>
Signed-off-by: SungJin1212 <tjdwls1201@gmail.com>
Signed-off-by: SungJin1212 <tjdwls1201@gmail.com>
if hp.StartTimestampMs != 0 && hp.TimestampMs != 0 {
// TODO(SungJin1212): Change to AppendHistogramSTZeroSample after update the Prometheus v3.9.0+
if _, err = app.AppendHistogramCTZeroSample(ref, copiedLabels, hp.TimestampMs, hp.StartTimestampMs, h, fh); err != nil && !errors.Is(err, storage.ErrOutOfOrderCT) {
level.Warn(logutil.WithContext(ctx, i.logger)).Log("msg", "failed to append start timestamp for histogram", "user", userID, "series", copiedLabels.String(), "timestamp", hp.TimestampMs, "start_timestamp", hp.StartTimestampMs, "err", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging per sample is impossible to run at scale.

Maybe consider adding a metric like this

 // In newIngesterMetrics():
  startTimestampFail: promauto.With(r).NewCounter(prometheus.CounterOpts{
      Name: "cortex_ingester_start_timestamp_failures_total",
      Help: "The total number of start timestamp zero samples that errored on ingestion.",
  }),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sound good, what about setting these logs as Debug and adding some metrics to track them?

Signed-off-by: SungJin1212 <tjdwls1201@gmail.com>
@SungJin1212 SungJin1212 marked this pull request as ready for review March 25, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PRW2: create zero sample with created timestamp

2 participants