TL;DR
Prometheus stores numbers (metrics). Loki stores text (logs). They are separate databases that only look like one because Grafana queries both and shows the results side by side. Prometheus pulls its data, Loki has it pushed by an agent, and the one place they meet is Prometheus monitoring the health of that agent.
If you spend enough time in DevOps or backend engineering, you'll eventually hear someone say, "We use Prometheus and Loki for our monitoring." People say it so fast, and so often, that it's easy to assume they are merged into one giant, all-knowing database.
Let's clear up the biggest misconception in observability right away: PrometheusAn open-source monitoring system and time-series database, originally built at SoundCloud and now a CNCF project. It stores numbers associated with a timestamp and is very fast at crunching them. does NOT contain your application logs, and it does not store LokiA log aggregation system inspired by Prometheus, built by Grafana Labs. It doesn't index the text of your logs, just the labels, making it highly cost-effective.'s log data. They are two completely separate databases, often running side-by-side, doing two completely different jobs.
- Prometheus is a database exclusively for numbers (metrics).
- Loki is a database exclusively for text (logs).
So, if they are completely separate databases, why does everyone group them together? And how are they actually connected? It comes down to a brilliant piece of UI trickery, and a hidden "meta" connection under the hood.
1. Grafana: The Glass Window
The main reason people think Prometheus and Loki are the same database is because of Grafana.
Grafana is the visual frontend—the glass window into your data. Under the hood, Grafana acts as a bilingual translator. When you build a dashboard to monitor your Django application, Grafana does a split-second routine:
- It turns to the left and sends a PromQLPrometheus Query Language. The specific syntax used to ask Prometheus to calculate and graph its numbers. query to Prometheus: "Give me the line graph for the API latency."
- It turns to the right and sends a LogQLLoki Query Language. Similar to PromQL, but used specifically for filtering and searching through massive amounts of text logs. query to Loki: "Give me the raw text error logs for that exact same API."
- It stitches them together on your screen so perfectly that it looks like they came from the same place.
They don't share data. They just share the same presentation screen.
2. Push vs. Pull: How They Actually Get Their Data
The second major difference is how data physically enters these databases. They use completely opposite network philosophies.
Prometheus uses a "Pull" modelIn a Pull model, the central server reaches out to grab data. In a Push model, the clients actively send their data to the central server.. Think of Prometheus as a health inspector. It walks around with a clipboard and actively knocks on the door of your Django application every 15 seconds (a common setting; the built-in default is one minute), scraping the /metrics endpoint to ask, "How much CPU are you using right now?" If your app is dead, Prometheus notes the failure by setting a special metric called up to 0, and walks away.
Loki uses a "Push" model. Loki doesn't knock on doors. It just sits there and waits. Instead, it relies on an agent called PromtailThe lightweight agent that ships with Loki. Its only job is to discover log files, attach labels to them, and push them to the Loki database., which runs on your application server. Promtail acts like a mail carrier—it reads your physical log files, stuffs them into an envelope, compresses them, and pushes (HTTP POST) them over the network to Loki's API.
A note on Promtail: Grafana deprecated Promtail in early 2025, and it reached end-of-life on March 2, 2026. Its replacement is Grafana Alloy. This series uses Promtail because it's simple to explain and still very common in existing setups. The concepts (tailing files, a positions bookmark, batching and pushing to Loki) carry over directly to Alloy.
3. The "Meta" Connection (Where They Finally Intersect)
I mentioned that Prometheus doesn't store your logs. But that doesn't mean Prometheus and Loki's ecosystem completely ignore each other. There is one powerful intersection point.
While Prometheus doesn't store the logs that Promtail collects, it does store the health metrics of Promtail itself.
Promtail is an application running quietly in the background of your Linux server. Like any good modern application, Promtail exposes its own internal health numbers. If you want to make sure your log pipeline isn't failing, you simply tell Prometheus to monitor the mail carrier!
You do this by adding a quick job to your prometheus.yml file:
scrape_configs:
- job_name: 'django_production'
static_configs:
- targets: ['localhost:8000']
# Prometheus now asks Promtail for its health!
- job_name: 'promtail'
static_configs:
- targets: ['localhost:9080']
Once you do this, Prometheus starts collecting internal numbers from Promtail, like promtail_read_bytes_total (how much log text it read) and promtail_sent_bytes_total (how much compressed data it sent to Loki).
Because we have these two numbers, we don't have to guess how well our logging pipeline is performing. We can actually prove it by writing a quick PromQL query in Grafana to calculate our exact live compression ratio:
sum(rate(promtail_read_bytes_total[5m])) / sum(rate(promtail_sent_bytes_total[5m]))
If this query returns a 5, it means Promtail is squashing your logs down by 5x before sending them over the network, saving you a lot of bandwidth.
Two small caveats. First, promtail_sent_bytes_total measures the whole network payload, including timestamps, labels and formatting, so this is an end-to-end ratio, not a pure compression score. It can even drop below 1 (more on that "negative compression" trap in Part 5). Second, promtail_read_bytes_total is technically exposed as a gauge, not a counter. Because it only grows for a given file, rate() works on it in practice, but don't be surprised if a linter complains.
By keeping logs and metrics separated, the architecture stays incredibly fast and resilient.
Up Next in the Series:
In the next post, we dive into exactly how Prometheus handles scraping thousands of numbers a second, and why the "Write-Ahead Log" is the most important concept to understand.
Part 2: How Prometheus Actually Uses RAM and Disk