Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prometheus/remotewrite: Fix missing series ref mapping for native histogram #5517

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ Main (unreleased)
permanently fail to load with `id already exists` error. (@mattdurham)

- Allow the usage of encodings other than UTF8 to be used with environment variable expansion. (@mattdurham)


- Fixed an issue where native histogram time series were being dropped silently. (@krajorama)

### Enhancements

- The `loki.write` WAL now has snappy compression enabled by default. (@thepalbi)
Expand Down
13 changes: 13 additions & 0 deletions component/prometheus/remotewrite/remote_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"go.uber.org/atomic"

"github.com/prometheus/prometheus/model/exemplar"
"github.com/prometheus/prometheus/model/histogram"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/model/metadata"

Expand Down Expand Up @@ -109,6 +110,18 @@ func New(o component.Options, c Arguments) (*Component, error) {
}
return globalRef, nextErr
}),
prometheus.WithHistogramHook(func(globalRef storage.SeriesRef, l labels.Labels, t int64, h *histogram.Histogram, fh *histogram.FloatHistogram, next storage.Appender) (storage.SeriesRef, error) {
if res.exited.Load() {
return 0, fmt.Errorf("%s has exited", o.ID)
}

localID := prometheus.GlobalRefMapping.GetLocalRefID(res.opts.ID, uint64(globalRef))
newRef, nextErr := next.AppendHistogram(storage.SeriesRef(localID), l, t, h, fh)
if localID == 0 {
prometheus.GlobalRefMapping.GetOrAddLink(res.opts.ID, uint64(newRef), l)
}
return globalRef, nextErr
}),
prometheus.WithMetadataHook(func(globalRef storage.SeriesRef, l labels.Labels, m metadata.Metadata, next storage.Appender) (storage.SeriesRef, error) {
if res.exited.Load() {
return 0, fmt.Errorf("%s has exited", o.ID)
Expand Down