Distributors, ingesters, queriers (briefly)
Both ELK and Loki are sharded write-paths plus sharded read-paths plus a backing store; they differ mainly in HOW they choose the partition key — ELK shards by hash(doc_id), Loki streams by hash(label-set).
We've shaped the data going in, through, and out. Now zoom out to the moving parts of the backend — but only briefly, because the choices we already made determine most of what matters here.
Scene 10
Distributors, ingesters, queriers (briefly)
- Watch
- Try it
- Predict
- Capture
Two mini-stacks. LEFT (ELK): agents → coordinating node → data nodes; the partition key is hash(doc_id), and each shard has a replica shadow on a neighboring data node. RIGHT (Loki): agents → distributors → consistent-hash ring → ingesters; each stream has 3 replicas (RF=3), and ingesters periodically flush to the object store. Reads on Loki fan out from queriers to BOTH ingesters and the object store. The bottom strip names the vocabulary collision: shard (ELK) vs stream (Loki) — same achievement, different partition-key choice.
Highlighted lines are the ones running in the diagram right now.
def on_index(doc):shard_id = hash(doc.id) mod num_shardsprimary = routing_table.primary(shard_id)replicas = routing_table.replicas(shard_id) # RF-1primary.write(doc)for r in replicas:r.write(doc) # in-sync replication
def on_push(line):key = hash(canonicalize(line.label_set))owners = ring.successors(key, n=replication_factor) # RF=3acks = 0for ingester in owners:if ingester.send(line):acks += 1return acks >= quorum # 2 of 3
def execute(query):plan = frontend.split(query) # frontend → scheduleringester_chunks = [i.query(plan) for i in ring.owners(plan.label_set)]store_chunks = object_store.fetch(plan.time_range)return merge(ingester_chunks, store_chunks)
Where this sits in Build a distributed logging stack (ELK / Loki)
Scene 10 of 12. Both ELK and Loki are sharded write-paths plus sharded read-paths plus a backing store; they differ in the partition key — hash(doc_id) vs hash(label-set).
Up next. Every choice from scenes 02 through 10 is now a knob. Pick a workload and ship a configuration the verifier won't reject.
All 12 scenes in Build a distributed logging stack (ELK / Loki) · Every curriculum