Skip to content

Update Prometheus and Loki#5035

Merged
thampiotr merged 13 commits intomainfrom
thampiotr/update-prom-and-loki
Dec 11, 2025
Merged

Update Prometheus and Loki#5035
thampiotr merged 13 commits intomainfrom
thampiotr/update-prom-and-loki

Conversation

@thampiotr
Copy link
Contributor

@thampiotr thampiotr commented Dec 9, 2025

PR Description

This finally gets rid of our Prometheus fork.
Not all new experimental features in Prometheus are exposed. Instead there are some TODOs left in the code to GH issues which should address this. This is to keep the PR smaller and prioritise the work accordingly.

Which issue(s) this PR fixes

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated
  • Config converters updated

dec.HonorTimestamps = c.HonorTimestamps
dec.TrackTimestampsStaleness = c.TrackTimestampsStaleness
dec.Params = c.Params
dec.ScrapeNativeHistograms = &copyScrapeNativeHistograms
Copy link
Contributor Author

@thampiotr thampiotr Dec 9, 2025

Choose a reason for hiding this comment

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

This setting is now per-scrape-job, moved from manager-wide setting above.

@thampiotr thampiotr force-pushed the thampiotr/update-prom-and-loki branch from 28536ff to 744a5d0 Compare December 9, 2025 13:52
@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2025

💻 Deploy preview deleted (Update Prometheus and Loki).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Prometheus dependencies to v3.8.0 (module version v0.308.0) and Loki dependencies to v3.6.2, representing a significant upgrade to the latest versions of these core components. The changes primarily involve migrating to new Prometheus API patterns and updating import paths for remote write functionality.

Key Changes

  • Migrated from config.RemoteWriteProtoMsg to remote.WriteMessageType for remote write protocol types, importing from github.com/prometheus/client_golang/exp/api/remote instead of github.com/prometheus/prometheus/config
  • Removed EnableNativeHistogramsIngestion from scrape.Options in favor of setting ScrapeNativeHistograms directly in scrape configurations
  • Added TODO comments with GitHub issue links for new experimental Prometheus features (EnableCreatedTimestampZeroIngestion, EnableTypeAndUnitLabels, appendMetadata) that are not yet exposed in Alloy components

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/component/prometheus/write/queue/types.go Updated imports and type references from config.RemoteWriteProtoMsg to remote.WriteMessageType
internal/component/prometheus/scrape/scrape.go Removed EnableNativeHistogramsIngestion from scrape options, added ScrapeNativeHistograms to scrape config, added TODOs for new experimental features
internal/component/prometheus/remotewrite/types.go Updated remote write protocol type imports and usage
internal/component/prometheus/receive_http/receive_http.go Updated handler initialization with new parameters, added TODO comments for unexposed features, aliased prometheus/storage/remote import to avoid conflicts
internal/component/prometheus/operator/common/crdmanager.go Simplified scrape manager creation with empty options, added TODOs for experimental features
go.sum Updated dependency hashes for Prometheus v0.308.0, Loki v3.6.2, and related AWS SDK, DigitalOcean, Docker, Hetzner, Linode, and etcd dependencies
go.mod Updated Prometheus to v0.308.0, Loki to v3.6.2, and consolidated dependency declarations
docs/sources/shared/reference/components/prom-operator-scrape.md Clarified scrape_native_histograms documentation from "ingest native histograms" to "scrape native histograms from targets"
CHANGELOG.md Added entries documenting Prometheus v3.8.0 and Loki v3.6.2 updates

@thampiotr thampiotr marked this pull request as ready for review December 10, 2025 14:04
@thampiotr thampiotr requested review from a team and clayton-cornell as code owners December 10, 2025 14:04
@github-actions
Copy link
Contributor

github-actions bot commented Dec 10, 2025

🔍 Dependency Review

Below is a review of the dependency changes in go.mod, what changed upstream between the “as-is” and “to-be” versions, and the concrete code updates needed to adopt them. For each dependency you’ll find a status and collapsible details with evidence and example diffs.

Note: The largest change here is moving Prometheus to v3.8.0 (module tag v0.308.0) and dropping the fork/replace directives. That upgrade includes several breaking API changes that this PR already addresses.


github.com/prometheus/prometheus v0.305.1-0.20250818080900-0a40df33fb4e (with grafana fork replace) -> v0.308.0 — ❌ Changes Needed

Status: Breaking changes required code updates. This PR implements them. Below is a summary of what changed and the exact code updates needed (with evidence).

Key upstream changes relevant between v3.6.x → v3.8.0:

  • Remote write “protobuf message” types moved to client_golang/exp (not in prometheus/config anymore).
  • remote.WriteHandler signature extended (new enableTypeAndUnitLabels, appendMetadata).
  • ScrapeManager options: EnableNativeHistogramsIngestion moved out of scrape.Options into per-scrape config (ScrapeConfig.ScrapeNativeHistograms pointer).
  • Additional toggles added (AppendMetadata, EnableTypeAndUnitLabels, EnableCreatedTimestampZeroIngestion).
  • Some label constants usage was standardized via prometheus/common/model (e.g., MetricNameLabel).

Evidence in this PR:

  • Imports switched from “prometheus/config” message types to “client_golang/exp/api/remote”.
  • remote write handler construction updated to new signature.
  • scrape.Options no longer uses EnableNativeHistogramsIngestion; per-scrape configs now set ScrapeNativeHistograms pointer.
  • Tests updated to set ScrapeNativeHistograms as a pointer and to expect it in rendered configs.
  • Places that constructed metric name labels were updated to use model.MetricNameLabel.

Concrete code updates to apply (already in this PR):

  1. Remote write message type constants moved:
  • Before:
- import "github.com/prometheus/prometheus/config"
+ import "github.com/prometheus/client_golang/exp/api/remote"

- PrometheusProtobufMessageV1 = string(config.RemoteWriteProtoMsgV1)
- PrometheusProtobufMessageV2 = string(config.RemoteWriteProtoMsgV2)
+ PrometheusProtobufMessageV1 = string(remote.WriteV1MessageType)
+ PrometheusProtobufMessageV2 = string(remote.WriteV2MessageType)

- if err := config.RemoteWriteProtoMsg(r.ProtobufMessage).Validate(); err != nil {
+ if err := remote.WriteMessageType(r.ProtobufMessage).Validate(); err != nil {
     ...
  }
  1. NewWriteHandler signature:
  • Before:
- import "github.com/prometheus/prometheus/storage/remote"
- import "github.com/prometheus/prometheus/config"

- supportedRemoteWriteProtoMsgs := config.RemoteWriteProtoMsgs{config.RemoteWriteProtoMsgV1}
- ingestCTZeroSample := false

- handler: remote.NewWriteHandler(
+ import (
+   expremote "github.com/prometheus/client_golang/exp/api/remote"
+   promremote "github.com/prometheus/prometheus/storage/remote"
+ )

+ supportedRemoteWriteProtoMsgs := expremote.MessageTypes{expremote.WriteV1MessageType}
+ ingestCTZeroSample := false
+ enableTypeAndUnitLabels := false
+ appendMetadata := false

+ handler: promremote.NewWriteHandler(
     logger,
     reg,
     fanout,
     supportedRemoteWriteProtoMsgs,
-    ingestCTZeroSample,
+    ingestCTZeroSample,
+    enableTypeAndUnitLabels,
+    appendMetadata,
   ),
  1. ScrapeManager Options and per-scrape native histograms:
  • Before (EnableNativeHistogramsIngestion lived in scrape.Options):
- opts := &scrape.Options{
-   EnableNativeHistogramsIngestion: c.args.Scrape.ScrapeNativeHistograms,
- }
- c.scrapeManager, err = scrape.NewManager(opts, logger, nil, app, unregisterer)
+ // Now native histograms are controlled per-target in ScrapeConfig (ScrapeNativeHistograms).
+ c.scrapeManager, err = scrape.NewManager(&scrape.Options{}, logger, nil, app, unregisterer)
  • Set per-scrape in decoders/builders (pointer):
+ copyScrapeNativeHistograms := c.ScrapeNativeHistograms
+ dec.ScrapeNativeHistograms = &copyScrapeNativeHistograms
  • Tests updated to expect pointer:
+ ScrapeNativeHistograms:         falsePtr,
  1. Forwarded config conversion for remote write protobuf message:
  • Before:
- ProtobufMessage: config.RemoteWriteProtoMsg(rw.ProtobufMessage),
+ ProtobufMessage: remote.WriteMessageType(rw.ProtobufMessage),
  1. Label name constant usage (metric name):
  • Before:
- import "github.com/prometheus/prometheus/model/labels"
+ import "github.com/prometheus/common/model"

- builder.Add(labels.MetricName, metric)
+ builder.Add(model.MetricNameLabel, metric)
  1. Write queue types wrapper for protobuf message moved:
  • Before:
- type RemoteWriteProtoMsg config.RemoteWriteProtoMsg
+ type RemoteWriteProtoMsg remote.WriteMessageType

- case string(config.RemoteWriteProtoMsgV1):
-   *s = RemoteWriteProtoMsg(config.RemoteWriteProtoMsgV1)
+ case string(remote.WriteV1MessageType):
+   *s = RemoteWriteProtoMsg(remote.WriteV1MessageType)

Additional knobs introduced upstream you may want to expose later (captured and TODO’d in code):

  • EnableCreatedTimestampZeroIngestion
  • EnableTypeAndUnitLabels
  • AppendMetadata

References (relevant upstream changes):

  • Prometheus v3.8.0 release and PRs: Remote write handler and exp API migration; scrape native histograms configuration moved per-target.
  • Removal of fork/replace: replace github.com/prometheus/prometheus => github.com/grafana/prometheus (…) is now gone; upstream is usable at v0.308.0.

github.com/prometheus/client_golang/exp (new) -> v0.0.0-20250914183048-a974e0d45e0a — ⚠️ Needs Review

Status: Introduced as a new direct dependency. Required for the new experimental remote write API types used by Prometheus v3.8.0.

What changed / how to use:

  • Remote write “protobuf message” enums/types now live under:
    • github.com/prometheus/client_golang/exp/api/remote
    • Types: WriteV1MessageType, WriteV2MessageType, MessageTypes and Validate() helpers.

Example updates (already in this PR):

- import "github.com/prometheus/prometheus/config"
+ import "github.com/prometheus/client_golang/exp/api/remote"

- PrometheusProtobufMessageV1 = string(config.RemoteWriteProtoMsgV1)
- PrometheusProtobufMessageV2 = string(config.RemoteWriteProtoMsgV2)
+ PrometheusProtobufMessageV1 = string(remote.WriteV1MessageType)
+ PrometheusProtobufMessageV2 = string(remote.WriteV2MessageType)

- if err := config.RemoteWriteProtoMsg(r.ProtobufMessage).Validate(); err != nil {
+ if err := remote.WriteMessageType(r.ProtobufMessage).Validate(); err != nil {
    ...
 }

Use this exp module only where necessary (remote write msg types). No additional code changes required beyond the import and type swaps shown above.


github.com/prometheus/common v0.67.1 -> v0.67.4 — ✅ Safe

Status: Patch-level update with bug fixes and small improvements. No breaking changes detected.

Note:

  • You’ve standardized on github.com/prometheus/common/model.MetricNameLabel in a few places (good practice), but this change wasn’t strictly required by this bump.

No project code changes required beyond what’s already done.


github.com/prometheus/sigv4 v0.2.1 -> v0.3.0 — ✅ Safe

Status: Minor release. No breaking changes affecting your usage via prometheus/prometheus/config’s SigV4Config were found. Existing config mapping continues to work.

No project code changes required.


github.com/prometheus/exporter-toolkit v0.14.1 -> v0.15.0 — ✅ Safe

Status: Minor release, generally additive fixes and TLS/HTTP handling improvements. This module is indirect here and no project code imports changed.

No project code changes required.


github.com/grafana/loki/v3 v3.0.0-main (pseudoversion) -> v3.6.2 — ✅ Safe

Status: You’ve switched from a pinned main commit to the released v3.6.2. No breaking API changes detected for the usage in this repo. This also aligns with “Updated Loki dependencies to v3.6.2” in your CHANGELOG.

No project code changes required.


github.com/grafana/loki/pkg/push 053429d -> 2f85998 — ✅ Safe

Status: Internal pseudo-version bump tied to the Loki update. No code in this repo appears to rely on breaking surface from this package beyond existing usage.

No project code changes required.


github.com/grafana/walqueue bb0dba7 -> d055c48 — ✅ Safe

Status: Internal package bump. Your write/queue code keeps using the same types.ConnectionConfig conversion; the public fields consumed remain compatible.

No project code changes required.


github.com/docker/docker v28.5.1+incompatible -> v28.5.2+incompatible — ✅ Safe

Status: Patch release. No relevant breaking changes for your usage.

No project code changes required.


AWS SDK for Go v2 (core and submodules) — minor bumps — ✅ Safe

Changed:

  • aws-sdk-go-v2: 1.39.4 -> 1.39.6
  • config: 1.31.15 -> 1.31.17
  • feature/ec2/imds: 1.18.11 -> 1.18.13
  • credentials/internal/endpoints/presigned-url/sso/ssooidc/sts/ecs/ec2/lightsail, etc: minor bumps

Status: All are patch/minor updates. No breaking API changes surfaced that affect typical usage. Your code compiles unchanged.

No project code changes required.


go.etcd.io/etcd/api/v3 v3.6.4 -> v3.6.6 — ✅ Safe

Status: Patch update. No breaking API changes for typical use.

No project code changes required.


Notes

  • Replaces removed:

    • The Prometheus fork replace was removed. You are now on upstream github.com/prometheus/prometheus v0.308.0. This is a good long-term move; the PR includes the required code changes for upstream compatibility.
    • The fsnotify replace (1.8.0 → 1.7.0) has been removed. Upstream Prometheus now works with the current fsnotify, so this pin is no longer necessary.
  • New direct dep added:

    • github.com/prometheus/client_golang/exp is new and required to reference the remote write message types used post-Prometheus v3.7+. This is the sanctioned location for those types now.
  • Tests updated:

    • Expect per-scrape ScrapeNativeHistograms (pointer) rather than a global manager option.
    • Error messages around invalid remote write message types changed to the new exp API wording (e.g., “unknown type for remote write protobuf message …”).

If you want to maintain behavior parity with pre-3.8 Prometheus, consider exposing (and wiring through) the new toggles introduced upstream:

  • EnableCreatedTimestampZeroIngestion
  • EnableTypeAndUnitLabels
  • AppendMetadata

These are TODO’d in the code already:

  • internal/component/prometheus/operator/common/crdmanager.go
  • internal/component/prometheus/receive_http/receive_http.go
  • internal/component/prometheus/scrape/scrape.go

@thampiotr thampiotr requested a review from a team as a code owner December 10, 2025 15:16
@thampiotr thampiotr force-pushed the thampiotr/update-prom-and-loki branch from 063c88c to 4522bbd Compare December 10, 2025 15:40
Copy link
Contributor

@kalleep kalleep left a comment

Choose a reason for hiding this comment

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

This is great! LGTM

@thampiotr thampiotr merged commit 01c4a62 into main Dec 11, 2025
46 checks passed
@thampiotr thampiotr deleted the thampiotr/update-prom-and-loki branch December 11, 2025 09:40
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants