Quick revision
The short answer
2 TB a day is about 23 MB/s on average, so with peaks of three to five times that we design for around 100 MB/s. Agents on each node read container output, add metadata and ship batches to a durable partitioned log such as Kafka that absorbs bursts, processors parse, redact and route, and storage keeps entries with a timestamp, a few low-cardinality labels, a trace id and a structured message. Indexing labels only and keeping compressed chunks in object storage is far cheaper than full-text indexing, and the search API combines a time range, label filters and text conditions, with live tail and retention tiers.
What to remember
In this answer, we sized 2 TB a day at about 23 MB/s average and planned for around 100 MB/s at peak. Agents add metadata and ship batches to Kafka, processors parse, redact and route, and entries carry a timestamp, low-cardinality labels, a trace id and a structured message. We compared full-text indexing with label indexing over compressed chunks in object storage and chose the cheaper label design by default, designed a search API of time range, labels and conditions with live tail, and set retention tiers of 7 days hot, 30 days warm and a year in archive.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
2 TB a day is about 23 MB/s on average, so with peaks of three to five times that we design for around 100 MB/s. Agents on each node read container output, add metadata and ship batches to a durable partitioned log such as Kafka that absorbs bursts, processors parse, redact and route, and storage keeps entries with a timestamp, a few low-cardinality labels, a trace id and a structured message. Indexing labels only and keeping compressed chunks in object storage is far cheaper than full-text indexing, and the search API combines a time range, label filters and text conditions, with live tail and retention tiers.
Why this question is asked
Logs are where engineers go when a dashboard says something is wrong but not why. A log system must swallow huge, bursty volumes that are mostly never read, and still find the right ten lines in seconds during an incident. Interviewers ask this design because the storage and indexing choice dominates the cost, and a candidate who indexes everything by default has not thought about the bill. In this answer, we will size the load, build the pipeline, define the data model, compare storage and indexing strategies, design the search API, and set retention tiers.
1Sizing the Load
2 TB per day divided by 86,400 seconds is about 23 MB/s on average. Logs are bursty: traffic peaks, deployments and above all incidents multiply volume, so we plan for three to five times the average, around 100 MB/s. If an average line is about 500 bytes, that is roughly 46,000 lines per second on average and 200,000 at peak, from 5,000 pods, so about 10 to 40 lines per second per pod.
Storage follows from retention. Logs compress well, often 5 to 10 times, so 2 TB of raw logs becomes perhaps 250 GB compressed per day. Keeping 30 days is about 7.5 TB compressed, and a year is about 90 TB, which is cheap in object storage and expensive on search-cluster SSDs. Keep that contrast in mind for the storage choice.
2The Pipeline
Each stage has one job, and the durable log in the middle decouples producers from consumers.
- Node agentsread container output and files, add service, pod, host, region, batch
- Durable partitioned logKafka topic, absorbs bursts, keeps 1 to 3 days
- Processorsparse, redact personal data, drop noise, route
- Storage and indexlabel index plus compressed chunks in object storage
- Query servicesearch API, live tail, alert rules on logs
5 layers, from the top down. Step through them one at a time.
The agents, such as Fluent Bit, Vector or the OpenTelemetry collector running as a DaemonSet, add metadata at the source, because only the node knows which pod and host a line came from. The durable log is what makes the pipeline safe: if processors or storage slow down, data waits in Kafka rather than being dropped on the nodes, and we can replay it after fixing a parser bug. Processors are where parsing and redaction happen, so personal data never reaches storage.
3The Data Model
Each entry has a timestamp, a small set of labels, a trace id when one exists, and the message. Labels are the fields almost every search filters on, and they must have few distinct values: service, environment, level, region. The message is preferably structured JSON, so fields like order_id or duration_ms can be searched without guessing at text formats.
Notice that order_id is in the message, not in the labels. A label with a value per order would explode the index, just as it does in metrics. The trace id connects the log line to the distributed trace of the same request, so an engineer can jump from an error log to the full call path.
4Choosing How to Store and Index
This is the decision that sets the cost. One option is a full-text index of every field, as Elasticsearch or OpenSearch does by default. Any word in any field can be found in milliseconds, but the index is often as large as the data, indexing costs a lot of CPU, and everything lives on fast disks in a cluster.
The other option, used by systems such as Grafana Loki, indexes only the labels and stores message bodies in compressed chunks in object storage. A query uses the label index and time range to select chunks, then scans them in parallel. It is many times cheaper to run, but a needle search, one rare word across all services for a week, has to scan a lot of data and is slower.
| Aspect | Full-text index | Labels plus chunks |
|---|---|---|
| Search by any word | milliseconds | seconds, scans matching chunks |
| Index size | similar to the data | tiny, labels only |
| Storage | SSD in the search cluster | object storage such as S3 |
| Ingest cost | high CPU for indexing | low, compress and upload |
| Best for | ad-hoc search over short periods | service and time filtered search, long retention |
For 2 TB a day, I would choose label indexing with object storage as the default, and add full-text indexing for a short hot window only for services that need it, such as security events.
5The Search API and Live Tail
A search combines three parts: a time range, label filters that narrow which chunks to read, and conditions on text or structured fields. Results are sorted by time, newest first by default, and paged.
Live tail streams new matching lines as they arrive, which is what engineers watch during a deployment. It is served from the processors' output stream rather than from storage, so it shows lines within a second or two.
6Retention Tiers
Most logs are read in the first few days or never. So we keep 7 days hot, in the fastest tier and with full-text search where enabled; 30 days warm, label-indexed in object storage; and a year in an archive tier, such as an infrequent-access storage class, which is searched rarely and can take minutes. Each tier is cheaper per gigabyte than the one before.
Retention can also differ by log class. Security and audit logs often must be kept for a year or more, while debug logs may only need three days. Setting tiers per class, rather than one rule for everything, is often the biggest saving of all.
7Follow-up questions
Why put Kafka between the agents and storage?
Because log volume is bursty and storage is not always available. Kafka absorbs a spike of five times normal for as long as its retention allows, lets processors catch up at their own pace, and allows replay if a parser bug corrupted a day of data. Without it, agents must buffer on nodes, and a long slowdown loses logs.
Should applications send logs directly to the log service?
Usually not. Writing to standard output and letting the node agent collect keeps applications simple and keeps working when the log service is slow; an application blocked on its logging call is a classic cause of outages.
How do we handle personal data in logs?
Redact or tokenise it in the processors, with rules for known fields such as emails and card numbers, and forbid logging full request payloads. Short retention for operational logs also limits exposure.
8Conclusion
In this answer, we sized 2 TB a day at about 23 MB/s average and planned for around 100 MB/s at peak. Agents add metadata and ship batches to Kafka, processors parse, redact and route, and entries carry a timestamp, low-cardinality labels, a trace id and a structured message. We compared full-text indexing with label indexing over compressed chunks in object storage and chose the cheaper label design by default, designed a search API of time range, labels and conditions with live tail, and set retention tiers of 7 days hot, 30 days warm and a year in archive.
Open with
First the numbers: 2 TB a day is about 23 MB per second on average, and logs spike three to five times during peaks and incidents, so I design for about 100 MB per second, roughly 200,000 lines per second at peak.
Then, if they want more
The pipeline is agents on each node, like Fluent Bit or the OpenTelemetry collector, reading container output, adding service, pod, host and region, and shipping batches to a durable partitioned log, Kafka, which absorbs bursts and allows replay. Processors then parse, redact personal data, drop noise and route to storage.
Each entry has a timestamp, a few low-cardinality labels such as service, environment and level, a trace id, and the message, preferably structured JSON, with high-cardinality things like order ids inside the message, not in labels. The big decision is indexing.
Full-text indexing of every field, Elasticsearch style, gives fast arbitrary search but the index is about as big as the data and lives on SSDs. Indexing only labels and keeping compressed chunks in object storage, Loki style, is far cheaper, and queries narrow by labels and time then scan chunks in parallel, which is slower only for needle searches.
I would default to the label design and add full text for a short window where needed. The search API takes a time range, label filters and text or field conditions, returns results sorted by time, and supports live tail. Retention is tiered: seven days hot, thirty days warm, a year in archive.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Design the pipeline, data model and search API of a log aggregation system that ingests...": https://scrivio-interview-library.netlify.app/architecture/system-design-problems/7314d6b111/