> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Why Prometheus and Grafana

> Explains using Prometheus for time series metrics collection and Grafana for visualization in Kubernetes environments, covering PromQL, scraping, labels, dashboards, and monitoring best practices.

You already have the fundamentals: you know what metrics are, understand the four golden signals (latency, traffic, errors, saturation), and how SLIs/SLOs/SLAs define what “healthy” looks like. The next step is choosing and deploying the monitoring tooling that collects, stores, and visualizes those metrics.

![A slide titled "Monitoring Fundamentals – Complete" showing three panels: example metrics (backend HTTP duration, pod restarts, CPU utilization, 5xx rate), a framework for useful metrics (traffic, errors, latency, saturation), and definitions of healthy targets (SLAs, SLOs, SLIs).](https://mintcdn.com/kodekloud-c4ac6d9a/qM9vA-hQoWNCxcKa/images/Grafana-Prometheus-for-Metrics-Driven-Observability/Prometheus-and-Grafana-Introduction/Why-Prometheus-and-Grafana/monitoring-fundamentals-metrics-slas-slos-slis.jpg?fit=max\&auto=format\&n=qM9vA-hQoWNCxcKa\&q=85\&s=af8a8462e498570434fc9ed8a9f448e1)

Overview: Prometheus for collection and storage, Grafana for visualization. Below we explain how each fits into your observability stack and why they’re a popular paired solution for cloud-native systems.

Prometheus: origins and core concepts

* Born at SoundCloud in 2012 to solve monitoring for dynamic, containerized architectures.
* Influenced by Google’s Borgmon: a dimensional metrics model where each metric has key/value labels.
* Uses PromQL (Prometheus Query Language) to query time series data.

Example of Prometheus’ dimensional model:

```text theme={null}
metric_name{key_1="value_1a",key_2="value_2a"} 10
metric_name{key_1="value_1a",key_2="value_2b"} 2
```

Example applied to HTTP request counts:

```text theme={null}
http_requests_total{endpoint="/items", request_method="GET"} 10
http_requests_total{endpoint="/items", request_method="PUT"} 2
http_requests_total{endpoint="/search", request_method="GET"} 4
```

Why labels matter: instead of proliferating metric names for every endpoint/method combination, Prometheus keeps a single metric name and uses labels to slice and aggregate data efficiently. Prometheus stores time-stamped samples and exposes a rich query surface via PromQL: [https://prometheus.io/docs/prometheus/latest/querying/basics/](https://prometheus.io/docs/prometheus/latest/querying/basics/)

Prometheus and Kubernetes

Prometheus adoption accelerated with Kubernetes. In 2016 Prometheus became the second CNCF project after Kubernetes; together they form a natural fit:

![A slide showing the Prometheus logo labeled “Standard for Monitoring” connected by arrows to a Kubernetes box labeled “Standard for Container Orchestration,” with SoundCloud and Cloud Native Computing Foundation logos and a timeline marking 2012 and 2016.](https://mintcdn.com/kodekloud-c4ac6d9a/qM9vA-hQoWNCxcKa/images/Grafana-Prometheus-for-Metrics-Driven-Observability/Prometheus-and-Grafana-Introduction/Why-Prometheus-and-Grafana/prometheus-monitoring-kubernetes-cncf-2012-2016.jpg?fit=max\&auto=format\&n=qM9vA-hQoWNCxcKa\&q=85\&s=65ad92053bb9bb4612bb516fd6b6e1d1)

* Designed for dynamic, ephemeral workloads (pods come and go).
* Works equally well for processes on VMs, containers outside Kubernetes, or static targets.

How Prometheus discovers and ingests metrics

Applications and exporters expose metrics over HTTP (commonly at `/metrics`). Prometheus polls (scrapes) these endpoints on a schedule defined in its configuration. Scrape jobs group related targets (for example, replicas behind a service).

Simple static scrape config:

```yaml theme={null}
global:
  scrape_interval: 15s

scrape_configs:
- job_name: "backend-service"
  static_configs:
  - targets:
    - "backend-service.default.svc.cluster.local:5421"
```

In production Kubernetes deployments you’ll usually use Kubernetes service discovery instead of static targets so Prometheus can follow pods as they scale or move.

Prometheus is primarily pull-based: it scrapes HTTP endpoints. For short-lived processes that can’t be scraped, consider the Pushgateway ([https://prometheus.io/docs/practices/pushing/](https://prometheus.io/docs/practices/pushing/)) — but use it sparingly, since pushing changes metric semantics and can introduce lifecycle complexity.

Grafana: visualization and data-source flexibility

* Started in 2014 as a fork of Kibana; evolved into a powerful, data-source-agnostic visualization platform.
* Connects to many backends: Prometheus, Elasticsearch, InfluxDB, CloudWatch, and more.
* Grafana Labs maintains open-source Grafana and provides commercial offerings (Grafana Cloud, enterprise features).

![A simple diagram showing Grafana on the left, maintained by Grafana Labs in the center, which operates on OpenCore to the right and builds commercial products below.](https://mintcdn.com/kodekloud-c4ac6d9a/qM9vA-hQoWNCxcKa/images/Grafana-Prometheus-for-Metrics-Driven-Observability/Prometheus-and-Grafana-Introduction/Why-Prometheus-and-Grafana/grafana-labs-opencore-commercial-products-diagram.jpg?fit=max\&auto=format\&n=qM9vA-hQoWNCxcKa\&q=85\&s=d374c18724f961dec55c0691dba0699c)

Why pair Prometheus + Grafana?

* Prometheus: efficient time-series collection, dimensional labels, PromQL.
* Grafana: flexible dashboards, templating, alerting integrations, multi-datasource views.
* Together they form a widely adopted OSS monitoring stack that gives you control over retention, cost, and scaling — at the expense of managing the infrastructure yourself.

Comparison at a glance

| Component | Role | Strengths | Typical use |
| - | - | - | - |
| Prometheus | Metrics collection & TSDB | Dimensional labels, PromQL, ecosystem of exporters | Scrape application/exporter endpoints; power queries and alerting |
| Grafana | Visualization & dashboards | Multi-datasource, templating, alerting UI | Build dashboards from Prometheus metrics and other sources |
| Pushgateway | Push buffer for metrics | Allows short-lived jobs to publish metrics | Use sparingly for non-scrapable workloads |

Observability pipeline (summary)

* Applications/exporters expose Prometheus-format metrics at HTTP endpoints.
* Prometheus scrapes those endpoints, timestamps samples, and stores them in its TSDB.
* Grafana connects to Prometheus as a data source and visualizes metrics in dashboards.

In short: applications/exporters → Prometheus (ingest & store) → Grafana (visualize & alert).

Recommendations and next steps

* Start by instrumenting key endpoints and services with Prometheus-style metrics (use labels consistently).
* Use Kubernetes service discovery for scraping in cluster deployments.
* Prototype dashboards in Grafana focusing on your four golden signals and SLO-backed alerts.
* Decide early whether to self-manage retention/scale or use hosted options (e.g., Grafana Cloud) to simplify operations.

Useful links and references

* Prometheus: [https://prometheus.io](https://prometheus.io)
* PromQL basics: [https://prometheus.io/docs/prometheus/latest/querying/basics/](https://prometheus.io/docs/prometheus/latest/querying/basics/)
* Grafana: [https://grafana.com](https://grafana.com)
* Prometheus push practices (Pushgateway): [https://prometheus.io/docs/practices/pushing/](https://prometheus.io/docs/practices/pushing/)

You’ll soon deploy Prometheus and Grafana into a Kubernetes cluster from scratch — instrumenting services, configuring scrape jobs and service discovery, and building dashboards to monitor what matters.

> [card] [Watch Video](https://learn.kodekloud.com/user/courses/grafana-prometheus-for-metrics-driven-observability/module/86c79392-532c-42b7-8908-18bf0a84210b/lesson/afa7258e-0063-429f-a93a-cba071503d37)

> [card] [Practice Lab](https://learn.kodekloud.com/user/courses/grafana-prometheus-for-metrics-driven-observability/module/86c79392-532c-42b7-8908-18bf0a84210b/lesson/f1add59a-9370-44c0-ba47-2369728cc845)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.