BeginnerLesson 2 of 11

Introduction to Prometheus

Learn what Prometheus is, why it became the default cloud-native monitoring system, and how its pull model differs from older monitoring stacks.

Simple Explanation (ELI5)

Prometheus is a system that regularly visits your apps, asks for their numbers, stores those numbers, and lets you search them later. Instead of waiting for apps to push data somewhere, Prometheus pulls metrics from endpoints like /metrics.

Real-world Analogy

Imagine a warehouse manager walking the floor every minute with a clipboard, checking stock, temperature, and machine status. That manager is Prometheus. Each machine that exposes its numbers is an exporter or instrumented app.

Technical Explanation

Prometheus is an open-source monitoring system and time-series database. It stores labeled time-series data, scrapes targets over HTTP, evaluates rules, and can send alerts to Alertmanager. It was built for dynamic environments like Kubernetes, where instances appear and disappear frequently.

CapabilityPrometheus BehaviorWhy It Matters
Collection modelPull-based scrapingSimple, auditable, target health is visible
StorageLocal TSDBFast reads for dashboards and alerts
Query languagePromQLRich aggregation and alert logic
DiscoveryStatic and service discoveryWorks in dynamic platforms like Kubernetes
AlertingRules + AlertmanagerDecouples signal generation from notification routing

Visual Representation

Targets
Apps
Exporters
Prometheus
Scrape + Store
Grafana
Alertmanager

Commands / Syntax

yaml
global:
  scrape_interval: 15s

scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]
bash
# Run Prometheus locally with Docker
docker run --name prometheus -p 9090:9090 \
  -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml \
  prom/prometheus

# Open UI
curl http://localhost:9090/-/ready
curl http://localhost:9090/api/v1/targets

Example (Real-world Use Case)

A platform team deploys Prometheus into a Kubernetes cluster to monitor API pods, ingress latency, node resources, kube-state-metrics, and application error rates. Prometheus becomes the data source for Grafana dashboards and SRE alerting.

Hands-on Section

  1. Create a minimal prometheus.yml with one static target.
  2. Run Prometheus in Docker and verify the UI on port 9090.
  3. Open the Status → Targets page and confirm the target is up.
  4. Run the expression up in the UI.

Try It Yourself

Debugging Scenarios

Important

Prometheus not collecting data is often not a storage problem. It is usually target reachability, bad discovery labels, or an incorrectly exposed /metrics endpoint.

Interview Questions

Beginner

What is Prometheus?

Prometheus is an open-source monitoring system and time-series database used to collect, store, query, and alert on metrics.

What kind of data does Prometheus store?

It stores labeled time-series data, where each metric sample has a timestamp, value, and set of labels.

What is the default scrape model in Prometheus?

Prometheus uses a pull model. It scrapes metrics from targets over HTTP.

What is PromQL?

PromQL is Prometheus Query Language, used to select, transform, and aggregate metrics.

What is Alertmanager used for?

Alertmanager receives alerts from Prometheus and handles grouping, deduplication, silencing, and routing to channels like Slack or email.

Intermediate

Why is pull-based monitoring useful in Kubernetes?

Prometheus can discover short-lived targets dynamically and show whether a target is reachable, which is useful in constantly changing clusters.

When is push allowed in Prometheus ecosystems?

Short-lived batch jobs can push final metrics to the Pushgateway, but Prometheus itself is still fundamentally scrape-oriented.

Why is Prometheus often paired with Grafana?

Prometheus is great at collection, querying, and rule evaluation, while Grafana provides more flexible dashboards and visualization options.

What are exporters?

Exporters translate metrics from systems that do not natively expose Prometheus format, such as Linux hosts, MySQL, or Redis.

What is a scrape target?

A scrape target is an endpoint that exposes metrics in Prometheus text format, usually over HTTP.

Scenario-based

A team wants apps to push metrics directly to Prometheus. Would you allow it?

Generally no. Prometheus is designed to scrape. For short-lived jobs, use Pushgateway carefully. For long-running services, expose a /metrics endpoint instead.

Prometheus is running but no data appears in Grafana. Where do you start?

Check target health in Prometheus first, then verify the Grafana data source, query range, and metric names. Do not start with Grafana styling.

How would you introduce Prometheus to a team using only shell scripts for monitoring?

Start with node exporter and a few high-value service metrics, show dashboards and alerting wins, then gradually replace ad hoc scripts with reproducible metric collection.

Your cluster scales up and down constantly. Why is Prometheus still a fit?

Because Prometheus supports service discovery and can track dynamic targets using Kubernetes metadata rather than fixed static IPs.

A service exports metrics but Prometheus still shows it as down. What do you check first?

I check whether Prometheus can reach the correct address and port, whether the path is correct, and whether labels or discovery are targeting the intended pod or service.

Summary

Prometheus became the standard for cloud-native monitoring because it combines pull-based collection, flexible querying, strong service discovery, and straightforward alerting. The next step is learning the metric data model that makes this possible.