Skip to content

Commit

Permalink
prometheus.remote_write: fix missing series ref mapping for native hi…
Browse files Browse the repository at this point in the history
…stogram (#5517)

Signed-off-by: György Krajcsovits <[email protected]>
Co-authored-by: Paschalis Tsilias <[email protected]>
  • Loading branch information
krajorama and tpaschalis authored Oct 17, 2023
1 parent 49b569e commit 5794224
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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

0 comments on commit 5794224

Please sign in to comment.