Sharded
Several writers, each owning one storage shard, and a reader group per shard. Ingest scales with writers, queries with readers.
How it works
Each writer holds the Lease on one storage shard. A entry routes to a shard by a hash of its namespace and stream labels, under the routing epoch in effect at its timestamp, and any writer accepts any entry and forwards it to the shard's owner. Each shard gets its own reader group, and a query fans out to every group and merges the results. Adding writers schedules a new epoch: new shards take data from the next aligned hour, and old data never moves.
Deploy
A shared bucket is required: grant S3 access first. Hover a field to see what it does:
1apiVersion: telemetry.plural.sh/v1alpha12kind: Logs3metadata:41 name: logs52 namespace: telemetry6spec:73 mode: Sharded84 config:95 retention: 14d10 storage:116 path: logs12 objectStore:137 type: Aws14 aws:158 region: us-east-1169 bucket: acme-telemetry17 write:1810 durability: applied1911 flushIntervalSeconds: 1020 sharding:2112 leaseDurationSeconds: 152213 segmentDurationSeconds: 360023 request:2414 maxQueryEntries: 50002515 queryConcurrency: 1626 elasticsearch:2716 streamFields: [kubernetes.namespace_name]28 writer:2917 replicas: 33018 resources:31 requests: { cpu: "1", memory: 2Gi }32 limits: { memory: 4Gi }3319 cacheVolume:34 persistentVolumeClaim:35 accessModes: [ReadWriteOnce]36 resources: { requests: { storage: 20Gi } }37 reader:3820 replicas: 23921 cacheVolume:40 emptyDir: { sizeLimit: 20Gi }4122 ingress:42 enabled: true43 hostname: logs.acme.internal44 ingressClass: nginx- 1nameAlso names the ServiceAccount the IAM role binds to, and the
logs-writerandlogs-readerServices (justlogsin Standalone mode). - 2namespaceThe Kubernetes namespace the pods run in. Tenant namespaces for your data are separate and come from NamespaceAuthentication resources.
- 3mode
Standalone(the default) runs one pod that reads and writes.Shardedruns a writer StatefulSet and one reader StatefulSet per storage shard, which scale independently. - 4configRendered into the server's config file. The operator rolls the pods when it changes.
- 5retentionHow long data is kept, counted from ingestion, as
14d,2wor36h. Default14d. - 6pathObject-key prefix inside the bucket; shard suffixes are appended. Must match the prefix in the IAM policy. Default
logs. - 7type
Aws,Gcp,Azure,LocalorInMemory. WithAwsand no key references, the pod uses its Pod Identity credentials. - 8regionBucket region. Add
endpoint(andallowHTTPif needed) for S3-compatible stores such as MinIO. - 9bucketCan be shared by all three databases, as long as their
pathprefixes differ. - 10durabilityWhen a write is acknowledged:
applied(default) once in memory,writtenonce in SlateDB's mutable state,durableonce uploaded to object storage. - 11flushIntervalSecondsHow often writers flush to object storage, and so how far readers can lag behind. Default
10. - 12leaseDurationSecondsHow long a shard Lease survives without renewal before another writer may take the shard over. Default
15;renewIntervalSeconds(default5) must be lower. - 13segmentDurationSecondsWidth of a time partition. Queries prune whole segments by time. Keep it stable for a dataset. Default
3600. - 14maxQueryEntriesMost log lines one query returns. Default
5000. - 15queryConcurrencyConcurrent query work per pod. Default
16.maxInFlightQueryBytes(128 MiB) bounds memory. - 16streamFieldsFor
_bulkingest: document fields promoted to stream labels. Keep them low-cardinality; other fields become structured metadata. - 17replicasWriter count, which is also the storage shard count. Raise it at any time; new shards take writes from the next aligned hour. It cannot be lowered.
- 18resourcesDefaults to 250m CPU and 512Mi memory requests with a 2Gi limit. Budget for the write buffer: 64 MiB per shard, plus up to two frozen buffers being flushed.
- 19cacheVolumeMounted at
/var/cache/logsas the disk tier of the block cache (512 MiB RAM and 10 GiB disk by default). A PVC keeps it warm across restarts. Set exactly one ofemptyDirorpersistentVolumeClaim. - 20replicasReplicas per reader group. Each storage shard gets its own group, which opens only that shard; any reader answers any query by asking the other groups over gRPC. Default
2in Sharded mode. Scale freely, or setautoscalingto scale each group on CPU. - 21cacheVolumeAn
emptyDiris enough: a restarted reader refills its cache from the bucket. - 22ingressOptional. One hostname that routes
/writeto the writers and/readto the readers. AddtlsandpathPrefixas needed.
Apply it with kubectl apply -f logs.yaml, then add credentials and connect your tools. The operator rolls the pods whenever the spec changes.
kubectl -n telemetry get logs
# NAME MODE READY AGE
# logs Sharded True 2m
kubectl -n telemetry port-forward svc/logs-reader 3100 &
curl -u grafana:"$PASSWORD" http://localhost:3100/read/ns/payments/loki/api/v1/labelsAn empty data array is expected until the collector has sent something.
Scaling
- Writers: raise
spec.writer.replicas. See scaling for how many writers your peak rate needs and how to size each one. New pods start first, and the new shards take writes from the next aligned hour. Existing data stays where it is, so scale-down is blocked until it expires. - Readers:
spec.reader.replicassets the replicas per reader group. Change it at any time, or setspec.reader.autoscalingto scale each group on CPU. New groups appear as writers add shards. See reader groups. - Heavy queries: raise
request.queryConcurrencyandrequest.maxInFlightQueryBytestogether with reader memory.