From d8b8678bd17d3ec335e10ffabf2e40af3e2807d7 Mon Sep 17 00:00:00 2001 From: Sebastian Rabenhorst <4246554+rabenhorst@users.noreply.github.com> Date: Wed, 8 Dec 2021 16:07:51 +0100 Subject: [PATCH] Log time series details for out-of-order samples in remote write receiver (#9894) * Improved out-of-order sample logs in write handler Signed-off-by: Sebastian Rabenhorst sign commit Signed-off-by: Sebastian Rabenhorst Inlined logAppendError Signed-off-by: Sebastian Rabenhorst Update storage/remote/write_handler.go Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com> Fixed fmt Signed-off-by: Sebastian Rabenhorst * Improved out-of-order sample logs in write handler Signed-off-by: Sebastian Rabenhorst sign commit Signed-off-by: Sebastian Rabenhorst Inlined logAppendError Signed-off-by: Sebastian Rabenhorst --- storage/remote/write_handler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/storage/remote/write_handler.go b/storage/remote/write_handler.go index 42e106038..1807543ff 100644 --- a/storage/remote/write_handler.go +++ b/storage/remote/write_handler.go @@ -54,7 +54,6 @@ func (h *writeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { case nil: case storage.ErrOutOfOrderSample, storage.ErrOutOfBounds, storage.ErrDuplicateSampleForTimestamp: // Indicated an out of order sample is a bad request to prevent retries. - level.Error(h.logger).Log("msg", "Out of order sample from remote write", "err", err.Error()) http.Error(w, err.Error(), http.StatusBadRequest) return default: @@ -98,6 +97,10 @@ func (h *writeHandler) write(ctx context.Context, req *prompb.WriteRequest) (err for _, s := range ts.Samples { _, err = app.Append(0, labels, s.Timestamp, s.Value) if err != nil { + switch errors.Cause(err) { + case storage.ErrOutOfOrderSample, storage.ErrOutOfBounds, storage.ErrDuplicateSampleForTimestamp: + level.Error(h.logger).Log("msg", "Out of order sample from remote write", "err", err.Error(), "series", labels.String(), "timestamp", s.Timestamp) + } return err }