Lesson 01 of 17 · Foundations
Kafka, EFK and monitoring: who does what
Before learning Kafka, place it next to the tools it is most often confused with. Monitoring (Prometheus and Grafana) answers 'is it healthy?' with numbers over time; logging (EFK: Elasticsearch, Fluent Bit, Kibana) answers 'what exactly happened?' with searchable text; Kafka hands business events from the programs that create them to the programs that need them. What each one stores, who reads it, how data gets in, what Kafka can and cannot do, and how the three work together.
Three tools that look alike
Monitoring, logging and Kafka all take data from your applications and send it somewhere else, so they are easy to mix up. They answer different questions for different readers:
| Monitoring (Prometheus → Grafana) | Logging (EFK: Elasticsearch, Fluent Bit, Kibana) | Kafka | |
|---|---|---|---|
| Question it answers | Is it healthy? How many, how fast, how full? | What exactly happened, and why did it fail? | Who else needs to know that this happened? |
| What it carries | Metrics: numbers over time (http_requests_total, latency, memory) |
Log lines: text written by programs (ERROR payment declined for order 123) |
Events: business facts (order 123 placed, 42.50 EUR) |
| Main reader | A person: dashboards, alerts, on-call | A person: searching while debugging | Other programs: services, pipelines, databases |
| How data gets in | Prometheus pulls (scrapes /metrics every 15–30 s) |
Fluent Bit pushes log lines it reads from files | Producers push; consumers pull at their own pace |
| Storage | Time-series database: compact numbers, weeks to months | Search index: every word indexed, days to months | Ordered log per topic: hours to forever, replayable |
| How you query | PromQL: rate(http_requests_total[5m]) |
KQL / full-text: level:ERROR and order:123 |
You don't search Kafka: you read a topic from an offset |
| Typical result | A graph and an alert | A list of matching lines | Another system did its work |
Think of a hospital. Monitoring is the heart-rate monitor beside the bed: a few numbers, all the time, and an alarm if one goes wrong. Logging is the patient's notes: every detail written down, so a doctor can look up exactly what happened at 3 a.m. Kafka is the hospital's internal post system: when a doctor orders a test, the order goes once into the post, and the lab, the pharmacy and the billing office each get their copy and do their part.
Monitoring in one minute: Prometheus and Grafana
- Your application exposes metrics at an HTTP endpoint, usually
/metrics. - Prometheus visits every endpoint every 15–30 seconds (a scrape) and stores the numbers as time series.
- Grafana draws them as dashboards; Alertmanager sends alerts when a rule is true for long enough.
- Metrics are cheap: one number per series per scrape, whatever the traffic. They tell you that something is wrong, rarely why.
More: Observability with OpenTelemetry (start with Observability fundamentals) and Scaling Prometheus to production (start with kube-prometheus-stack).
Logging in one minute: EFK
- Applications write log lines to stdout or files.
- Fluent Bit (one per node) reads them, parses them, adds Kubernetes labels and pushes them on.
- Elasticsearch indexes every line so you can search billions of them in seconds.
- Kibana is the search screen and dashboards for logs.
- Logs tell you why: the exact error, the request ID, the stack trace. They cost more than metrics, because every line is stored and indexed.
More: Centralized logging with EFK (start with EFK architecture).
Kafka in one minute
- An application (a producer) writes events to a topic: "order 123 was placed".
- Kafka stores them in order, on several servers, for as long as you choose.
- Any number of other applications (consumers) read the topic, each at its own pace, and can re-read history.
- Kafka has no screens: no dashboards, no search page, no alerts. It is plumbing between programs.
What Kafka can do
| Capability | Example |
|---|---|
| Decouple services | Checkout writes "order placed" once; billing, shipping and email react without checkout knowing them |
| Fan out | One event stream feeds ten consumers, each independently |
| Buffer spikes and outages | A sale produces 50× the normal traffic; consumers catch up later, and nothing is lost |
| Replay history | A new fraud model reads the last 30 days of orders; a fixed bug reprocesses yesterday |
| Stream database changes (CDC) | Every row change in PostgreSQL flows to search, cache and analytics (Debezium) |
| Process streams in real time | Count orders per minute, join clicks with orders, detect fraud in seconds (Flink, Kafka Streams) |
| Feed analytics and data lakes | Events land in ClickHouse, S3 or a warehouse for dashboards and reports |
| Keep an audit trail | An ordered, durable record of logins, permission changes or payments |
| Carry logs and metrics too | A durable buffer in front of Elasticsearch or a metrics backend at very large scale |
What Kafka cannot do (use something else)
| You want… | Kafka? | Use instead |
|---|---|---|
| Dashboards and graphs | ✘ | Grafana, Kibana, Superset |
| Alerts on thresholds | ✘ | Prometheus + Alertmanager, Grafana alerting |
| Search logs by word or field | ✘ | Elasticsearch / OpenSearch, Loki |
| Ask "average latency per endpoint in the last hour" | ✘ | Prometheus (metrics) or an analytics store |
| Collect data by itself | ✘ | Producers: your code, Fluent Bit, Debezium, the OpenTelemetry Collector |
| A request that needs an answer now | ✘ | An HTTP or gRPC API call |
How they work together
They are not competitors; a mature platform usually runs all three.
1. Kafka as a buffer inside a logging pipeline (large scale)
apps ─► Fluent Bit ─► Kafka topic logs.app ─► Logstash / Connect sink ─► Elasticsearch ─► Kibana
└─► S3 archive (cheap, long retention)
2. Monitoring and logging watch Kafka itself
Kafka brokers ─► /metrics (JMX exporter) ─► Prometheus ─► Grafana: lag, under-replicated partitions
Kafka brokers ─► server logs ─► Fluent Bit ─► Elasticsearch ─► Kibana: errors, authorizer denials
3. Business events build their own dashboards
orders ─► Kafka ─► Flink (orders per minute) ─► ClickHouse ─► Grafana revenue panel
- Pattern 1 is worth it when the log volume is huge, Elasticsearch must be protected from spikes, or several teams need the same logs. Small setups send Fluent Bit straight to Elasticsearch.
- Pattern 2 is how you operate Kafka (lesson 15).
- Pattern 3 is the end-to-end example in lesson 12.
Don't use Kafka as your monitoring system
Teams sometimes send every metric through Kafka "because it's there". Prometheus already handles metrics efficiently, with a query language and alerting built in. Add Kafka to a monitoring or logging pipeline only for a clear reason: buffering at very large scale, several independent consumers, or long replay.
Try it: monitoring, logging, tracing, Kafka or an API call?
- Page the on-call engineer when the error rate is above 2% for 5 minutes.
- Find every log line for request ID
7f3a…across six services. - When a user changes their email, update the CRM, the newsletter tool and the search index.
- Show the payment service's p99 latency for the last 7 days.
- The checkout page needs the current stock level before showing "Buy".
- Load every order of the last two years into a new analytics database.
- See which service made a slow request slow.
- Keep a tamper-evident record of every permission change for auditors.
Going deeper
- The three signals of observability are metrics, logs and traces; OpenTelemetry collects all three with one agent. Kafka is not a signal: it is a transport that can carry any of them, or business events.
- At very large scale, some companies do run telemetry through Kafka (the OpenTelemetry Collector has Kafka exporters and receivers) to decouple collection from storage. It is an architecture decision with a cost, not a default.
- Events can also become metrics: a stream processor counts orders per minute and exposes or stores the result, so the business dashboard and the technical dashboard sit side by side in Grafana.
Recap
- Monitoring (Prometheus → Grafana): numbers over time, pulled by scraping, for dashboards and alerts.
- Logging (EFK): text lines, pushed by Fluent Bit, indexed for search while debugging.
- Kafka: business events written by producers and read by other programs, in order, replayable.
- Kafka has no dashboards, search or alerts, and it collects nothing by itself.
- The three work together: Kafka can buffer logs, Prometheus and EFK watch Kafka, and events can feed their own dashboards.
This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.