๐ 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
Log in to Grafana (
http://localhost:3000
)Go to Configuration โ Data Sources โ Add Prometheus
Set URL to
http://localhost:9090
Save & Test
Step 5: Build Dashboard
Go to Create โ Dashboard โ Add Panel
Enter PromQL query, e.g.:
rate(node_cpu_seconds_total[5m])
Choose visualization (graph, gauge, table).
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:
Add Prometheus as a data source in Grafana.
Create a new dashboard & panel.
Use PromQL queries to fetch metrics.
Apply visualization (line graph, gauge, etc.).
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
Subscribe to my newsletter
Read articles from Tathagat Gaikwad directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
