diff --git a/pkg/storage/chunk/client/object_client.go b/pkg/storage/chunk/client/object_client.go index 8a22686fb113a..6f767de532b33 100644 --- a/pkg/storage/chunk/client/object_client.go +++ b/pkg/storage/chunk/client/object_client.go @@ -5,9 +5,11 @@ import ( "context" "encoding/base64" "io" + "math/rand" "strings" "time" + "github.com/oklog/ulid" "github.com/pkg/errors" "github.com/grafana/loki/v3/pkg/storage/chunk" @@ -85,6 +87,7 @@ type client struct { keyEncoder KeyEncoder getChunkMaxParallel int schema config.SchemaConfig + entropy io.Reader } // NewClient wraps the provided ObjectClient with a chunk.Client implementation @@ -98,6 +101,7 @@ func NewClientWithMaxParallel(store ObjectClient, encoder KeyEncoder, maxParalle keyEncoder: encoder, getChunkMaxParallel: maxParallel, schema: schema, + entropy: rand.New(rand.NewSource(time.Now().UnixNano())), } } @@ -112,7 +116,8 @@ func (o *client) PutWal(ctx context.Context, segment *wal.SegmentWriter) error { if err != nil { return err } - return o.store.PutObject(ctx, "wal-segment-"+time.Now().UTC().Format(time.RFC3339Nano), bytes.NewReader(buffer.Bytes())) + newUlid := ulid.MustNew(ulid.Timestamp(time.Now()), o.entropy) + return o.store.PutObject(ctx, "loki-v2/wal/anon/"+newUlid.String(), bytes.NewReader(buffer.Bytes())) } // PutChunks stores the provided chunks in the configured backend. If multiple errors are