← Back to Home
πŸ“Š

Introduction to Monitoring with Prometheus & Grafana

You can't fix what you can't see β€” monitoring is how you see.

⏱9 min readπŸ“šDevOps Fundamentals

Shipping software is only half the job β€” you also need to know it’s healthy once it’s running. Is the app slow? Is memory creeping up? Did errors just spike after that deploy? Monitoring answers these questions in real time, and Prometheus + Grafana are the most popular open-source pair for doing it.


🎯 Learning Objectives

By the end of this lesson you will:


Why Monitor at All?

Without monitoring you find out about problems from angry users, not your dashboards. Good monitoring lets you:

πŸ’‘ Observability in one sentence

Monitoring tells you that something is wrong; observability helps you understand why. Metrics, logs, and traces together give you observability.


The Three Pillars of Observability

Pillar Answers Example tool
Metrics β€œHow much / how many / how fast?” (numbers over time) Prometheus
Logs β€œWhat exactly happened, in detail?” Loki, ELK
Traces β€œWhere did the time go across services?” Zipkin, Jaeger

This section is about metrics β€” lightweight numeric measurements sampled over time, like CPU usage, request rate, or error count.


What is Prometheus?

Prometheus is a time-series database and monitoring system. Its job is to collect and store metrics, and let you query them.

Its defining feature is the pull model: instead of your apps pushing data out, Prometheus reaches out and scrapes an HTTP endpoint (usually /metrics) on each target on a schedule.

text
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   scrape /metrics   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Your App   β”‚ ◀────────────────── β”‚  Prometheus  β”‚
β”‚ (exposes   β”‚                     β”‚ (stores +    β”‚
β”‚  /metrics) β”‚ ──────────────────▢ β”‚  queries)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   numeric samples   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Metrics look like simple text β€” a name, optional labels, and a value:

text
http_requests_total{method="GET",status="200"} 1027
http_requests_total{method="GET",status="500"} 3
process_cpu_seconds_total 4412.5

The {...} part holds labels β€” dimensions you can filter and group by later.


What is Grafana?

Prometheus stores numbers, but staring at raw numbers is painful. Grafana is the visualization layer: it connects to Prometheus (and many other sources) and turns those metrics into dashboards β€” graphs, gauges, and tables β€” plus alerts.

Tool Role
Prometheus Collects, stores, and queries metrics
Grafana Visualizes metrics and builds dashboards

Together they form the classic open-source monitoring stack: Prometheus is the engine, Grafana is the windshield.


The Full Picture

text
Apps + Exporters ──/metrics──▢ Prometheus ──queries──▢ Grafana ──▢ You
                                 β”‚
                                 └──▢ Alertmanager ──▢ Slack / email / PagerDuty

An exporter is a small helper that exposes metrics for things that can’t do it themselves (a database, a Linux host, etc.). We’ll meet those next.


πŸ§ͺ Hands-on Lab

πŸ“

Spot the Metric

Given this scrape output, answer: how many total GET requests returned a server error (status 500)?

http_requests_total{method="GET",status="200"} 1027
http_requests_total{method="GET",status="500"} 3
http_requests_total{method="POST",status="200"} 88

🧠 Knowledge Check

Knowledge Check

How does Prometheus collect metrics from targets by default?

Knowledge Check

What is Grafana's main job in this stack?


πŸ’Ό Interview Preparation

Interview Q&A

Why is Prometheus's pull model useful in dynamic environments like Kubernetes?


Summary

You now understand why we monitor, the difference between metrics, logs, and traces, and the roles of Prometheus (collect + store + query) and Grafana (visualize + alert). Next, we’ll go hands-on with Prometheus itself: scraping, the data model, and querying with PromQL.

Up Next

Prometheus Fundamentals: Scraping & PromQL

You've mastered this lesson. Continue your journey to becoming a DevOps Engineer.

Start Next Lesson→