|
|
|
|
@ -209,8 +209,12 @@ func (s *stream) Push( |
|
|
|
|
var rateLimitedSamples, rateLimitedBytes int |
|
|
|
|
defer func() { |
|
|
|
|
if outOfOrderSamples > 0 { |
|
|
|
|
validation.DiscardedSamples.WithLabelValues(validation.OutOfOrder, s.tenant).Add(float64(outOfOrderSamples)) |
|
|
|
|
validation.DiscardedBytes.WithLabelValues(validation.OutOfOrder, s.tenant).Add(float64(outOfOrderBytes)) |
|
|
|
|
name := validation.OutOfOrder |
|
|
|
|
if s.unorderedWrites { |
|
|
|
|
name = validation.TooFarBehind |
|
|
|
|
} |
|
|
|
|
validation.DiscardedSamples.WithLabelValues(name, s.tenant).Add(float64(outOfOrderSamples)) |
|
|
|
|
validation.DiscardedBytes.WithLabelValues(name, s.tenant).Add(float64(outOfOrderBytes)) |
|
|
|
|
} |
|
|
|
|
if rateLimitedSamples > 0 { |
|
|
|
|
validation.DiscardedSamples.WithLabelValues(validation.StreamRateLimit, s.tenant).Add(float64(rateLimitedSamples)) |
|
|
|
|
@ -253,12 +257,12 @@ func (s *stream) Push( |
|
|
|
|
|
|
|
|
|
// The validity window for unordered writes is the highest timestamp present minus 1/2 * max-chunk-age.
|
|
|
|
|
if s.unorderedWrites && !s.highestTs.IsZero() && s.highestTs.Add(-s.cfg.MaxChunkAge/2).After(entries[i].Timestamp) { |
|
|
|
|
failedEntriesWithError = append(failedEntriesWithError, entryWithError{&entries[i], chunkenc.ErrOutOfOrder}) |
|
|
|
|
failedEntriesWithError = append(failedEntriesWithError, entryWithError{&entries[i], chunkenc.ErrTooFarBehind}) |
|
|
|
|
outOfOrderSamples++ |
|
|
|
|
outOfOrderBytes += len(entries[i].Line) |
|
|
|
|
} else if err := chunk.chunk.Append(&entries[i]); err != nil { |
|
|
|
|
failedEntriesWithError = append(failedEntriesWithError, entryWithError{&entries[i], err}) |
|
|
|
|
if err == chunkenc.ErrOutOfOrder { |
|
|
|
|
if chunkenc.IsOutOfOrderErr(err) { |
|
|
|
|
outOfOrderSamples++ |
|
|
|
|
outOfOrderBytes += len(entries[i].Line) |
|
|
|
|
} |
|
|
|
|
@ -324,11 +328,12 @@ func (s *stream) Push( |
|
|
|
|
if len(failedEntriesWithError) > 0 { |
|
|
|
|
lastEntryWithErr := failedEntriesWithError[len(failedEntriesWithError)-1] |
|
|
|
|
_, ok := lastEntryWithErr.e.(*validation.ErrStreamRateLimit) |
|
|
|
|
if lastEntryWithErr.e != chunkenc.ErrOutOfOrder && !ok { |
|
|
|
|
outOfOrder := chunkenc.IsOutOfOrderErr(lastEntryWithErr.e) |
|
|
|
|
if !outOfOrder && !ok { |
|
|
|
|
return bytesAdded, lastEntryWithErr.e |
|
|
|
|
} |
|
|
|
|
var statusCode int |
|
|
|
|
if lastEntryWithErr.e == chunkenc.ErrOutOfOrder { |
|
|
|
|
if outOfOrder { |
|
|
|
|
statusCode = http.StatusBadRequest |
|
|
|
|
} |
|
|
|
|
if ok { |
|
|
|
|
|