๐Ÿš€ Day 26 of 30 Days DevOps Interview Prep Challenge

Series: 30 Days DevOps Interview Preparation
Author: Tathagat Gaikwad

Topic: Prometheus + Grafana: Dashboards from Prometheus Metrics


๐Ÿ“– Introduction

Monitoring is a critical pillar of DevOps and Site Reliability Engineering (SRE). Without proper observability, itโ€™s nearly impossible to ensure system reliability, identify bottlenecks, or proactively respond to failures.

Two of the most popular tools for monitoring in the cloud-native ecosystem are Prometheus and Grafana. While Prometheus is focused on metrics collection and storage, Grafana specializes in visualization and alerting. Together, they form a powerful monitoring and observability stack.

In this blog, weโ€™ll cover:

  • The theory behind Prometheus and Grafana

  • Practical steps to build dashboards

  • Common interview questions with detailed answers


๐Ÿ”น What is Prometheus?

Prometheus is an open-source systems monitoring and alerting toolkit originally developed at SoundCloud. It has become a CNCF graduated project and is widely used for monitoring Kubernetes and microservices.

Key Features:

  • Time-series database: Stores metrics in time series format.

  • Pull model: Prometheus scrapes metrics from applications via HTTP endpoints (default /metrics).

  • PromQL: A powerful query language for analyzing and aggregating data.

  • Service discovery: Automatically detects targets in dynamic environments like Kubernetes.

  • Alerting: Integrated with Alertmanager to notify via email, Slack, PagerDuty, etc.

Example Metric Endpoint:

Applications expose metrics in plain text format:

http_requests_total{method="GET", handler="/home"} 15432
http_requests_total{method="POST", handler="/login"} 895

๐Ÿ”น What is Grafana?

Grafana is an open-source analytics and visualization platform. It integrates with various data sources (Prometheus, Loki, ElasticSearch, InfluxDB, etc.) and allows users to create interactive dashboards.

Key Features:

  • Data Source Agnostic: Works with Prometheus and other tools.

  • Visualization: Graphs, heatmaps, gauges, tables, etc.

  • Alerts: Threshold-based alerts with integrations.

  • Dashboards: Pre-built templates and custom dashboards.


๐Ÿ”น Why Use Prometheus + Grafana Together?

Prometheus and Grafana are complementary tools:

  • Prometheus โ†’ Collects, stores, and queries metrics.

  • Grafana โ†’ Visualizes and alerts on those metrics.

This combination allows teams to:

  • Detect anomalies (e.g., CPU spikes, memory leaks)

  • Monitor application health in real time

  • Generate SLA/SLO reports

  • Set up proactive alerting


โš™๏ธ Practical: Building a Grafana Dashboard from Prometheus

Step 1: Run Prometheus

# prometheus.yml (basic config)
scrape_configs:
  - job_name: 'node'
    static_configs:
      - targets: ['localhost:9100']

Run Prometheus:

./prometheus --config.file=prometheus.yml

Step 2: Run Node Exporter

./node_exporter

(Node Exporter exposes Linux system metrics like CPU, memory, disk, network.)

Step 3: Run Grafana (Docker Example)

docker run -d -p 3000:3000 grafana/grafana

Step 4: Add Prometheus as a Data Source

  1. Log in to Grafana (http://localhost:3000)

  2. Go to Configuration โ†’ Data Sources โ†’ Add Prometheus

  3. Set URL to http://localhost:9090

  4. Save & Test

Step 5: Build Dashboard

  1. Go to Create โ†’ Dashboard โ†’ Add Panel

  2. Enter PromQL query, e.g.:

     rate(node_cpu_seconds_total[5m])
    
  3. Choose visualization (graph, gauge, table).

  4. Save dashboard.

โœ… Now you have a real-time dashboard powered by Prometheus metrics!


๐ŸŽฏ Interview Preparation โ€“ Detailed Q&A

Q1: What is the role of Prometheus in monitoring?

Answer: Prometheus is a metrics-based monitoring tool that scrapes metrics from targets, stores them in a time-series database, and allows querying using PromQL. It is designed for reliability in distributed environments like Kubernetes.


Q2: Why do we use Grafana with Prometheus?

Answer: Prometheus is excellent at collecting and storing metrics, but it has limited visualization capabilities. Grafana integrates with Prometheus to provide dashboards, charts, alerts, and insights that make the data more actionable.


Q3: How does Prometheus collect data?

Answer: Prometheus uses a pull-based model. It scrapes metrics endpoints (usually /metrics) exposed by applications or exporters. For cases where pulling is not possible, Prometheus supports a Pushgateway.


Q4: What is PromQL?

Answer: PromQL (Prometheus Query Language) is used to query and aggregate metrics. Example:

rate(http_requests_total[5m])

This calculates the per-second increase in http_requests_total over the last 5 minutes.


Q5: How do you create a Grafana dashboard from Prometheus metrics?

Answer:

  1. Add Prometheus as a data source in Grafana.

  2. Create a new dashboard & panel.

  3. Use PromQL queries to fetch metrics.

  4. Apply visualization (line graph, gauge, etc.).

  5. Set thresholds/alerts for monitoring.


Q6: Can Prometheus send alerts without Grafana?

Answer: Yes. Prometheus has an Alertmanager component that handles alerting independently. However, Grafana provides a user-friendly interface for alerts, making it easier to manage.


๐Ÿ’ก Key Takeaways

  • Prometheus is for metrics collection & storage

  • Grafana is for visualization & alerting

  • Together, they form a complete monitoring stack

  • PromQL is a must-know for DevOps interviews

  • Hands-on practice with Node Exporter + Prometheus + Grafana will strengthen your skills


โœ… Thatโ€™s Day 26! You now have both theory + practical setup + interview Q&A on Prometheus & Grafana dashboards.

#DevOps #Monitoring #Prometheus #Grafana #Observability #InterviewPreparation

0
Subscribe to my newsletter

Read articles from Tathagat Gaikwad directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Tathagat Gaikwad
Tathagat Gaikwad