From 8c3eca84db3b2feae44fac43fc918cc69fad07ec Mon Sep 17 00:00:00 2001 From: Serge Catudal Date: Thu, 21 Oct 2021 16:58:40 -0400 Subject: [PATCH] Fix remote write receiver endpoint for exemplars (#9414) Signed-off-by: Serge Catudal --- tsdb/head_append.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tsdb/head_append.go b/tsdb/head_append.go index 10c7d0795..bd2888930 100644 --- a/tsdb/head_append.go +++ b/tsdb/head_append.go @@ -305,12 +305,20 @@ func (s *memSeries) appendable(t int64, v float64) error { // AppendExemplar for headAppender assumes the series ref already exists, and so it doesn't // use getOrCreate or make any of the lset sanity checks that Append does. -func (a *headAppender) AppendExemplar(ref uint64, _ labels.Labels, e exemplar.Exemplar) (uint64, error) { +func (a *headAppender) AppendExemplar(ref uint64, lset labels.Labels, e exemplar.Exemplar) (uint64, error) { // Check if exemplar storage is enabled. if !a.head.opts.EnableExemplarStorage || a.head.opts.MaxExemplars.Load() <= 0 { return 0, nil } + + // Get Series s := a.head.series.getByID(ref) + if s == nil { + s = a.head.series.getByHash(lset.Hash(), lset) + if s != nil { + ref = s.ref + } + } if s == nil { return 0, fmt.Errorf("unknown series ref. when trying to add exemplar: %d", ref) }