AlgoViz

ELK Stack

medium 30 min

The ELK Stack is Elasticsearch, Logstash and Kibana: a place to collect, clean, store and search logs from many machines.

See it run

A log line from a file to a chart, what happens in a crash, and how old data leaves.

Operations

One log line

The payment service logs an error. Follow the line until someone sees it.

Step 1 of 6

Written to a file

Server 1app writes a fileShipperLogstashElasticsearchKibana

request not slowed

The app writes the line and goes on. It does not wait for anything.

Step 1: Written to a file

def one_line(line):    batch = shipper.read(line)    event = logstash.filter(batch)    elasticsearch.bulk("logs-pay-prod", event)    wait_for_refresh()    return kibana.search("log.level : error")
Delay
Seconds
Where it waits
File, queue, index

Say where the line waits at each step. That shows you know what can be lost.

In the real world

The same elk stack doing real jobs. Pick one and step through it.

A noisy service fills the disk of one node.

Step 1 of 4

85 percent

Server 1app writes a fileShipperLogstashElasticsearch85% usedKibana
Disk
85%

low mark

No new shards are placed on this node.

Step 1: 85 percent

Common mistakes

The bugs interviewers watch for, with the fix beside each.

  • Logging straight to the cluster

    critical

    A slow Elasticsearch then slows every user request.

    Wrong
    es.index(index="logs", document=line)
    Right
    print(json.dumps(line))   # the shipper does the rest
  • Ids as field names

    critical

    Each id becomes a field until the limit of 1,000 refuses documents.

    Wrong
    {"users": {"4711": "ok"}}
    Right
    {"user.id": "4711", "status": "ok"}
  • Deleting documents by age

    major

    Deleted documents stay on disk until merges, and the cluster works hard.

    Wrong
    POST logs-*/_delete_by_query
    Right
    "delete": { "min_age": "30d",  "actions": { "delete": {} } }
  • One shard for each service and hour

    major

    Every shard costs memory, and a search uses a thread for each.

    Wrong
    logs-pay-2026.11.23-10
    Right
    logs-pay-prod   # rolls over by size
  • Changing the filestream id

    minor

    The state is lost and files are read again from the start.

    Wrong
    id: checkout-log-v2
    Right
    id: checkout-log   # never change

Interview tips

  • How to explain it

    • A shipper with a notebook.
    • Parsing into fields.
    • A search engine, and a screen.
  • Where data can wait

    • In the log files.
    • In the Logstash queue.
    • In Kafka, replicated.
  • Reach for it when

    • Logs come from many machines.
    • People search by any field.
    • You can run a cluster or pay for one.
  • Do not use it for

    • Alerting on simple rates.
    • Records that must be exact.
    • Secrets and personal data.