π Day 25/30: DevOps Interview Preparation Challenge


Series: 30 Days DevOps Interview Preparation
Author: Tathagat Gaikwad
Topic: Prometheus β Setup, Metrics & Exporters
Monitoring is the backbone of modern DevOps and Site Reliability Engineering (SRE). Without proper observability, itβs nearly impossible to maintain reliable systems. Today, weβll explore Prometheus, one of the most widely adopted monitoring and alerting systems in the DevOps world.
πΉ What is Prometheus?
Prometheus is an open-source monitoring and alerting toolkit, initially developed at SoundCloud. Today, it is part of the Cloud Native Computing Foundation (CNCF) and is considered a standard for monitoring Kubernetes and cloud-native applications.
Key Features:
Pull-based model: Prometheus scrapes metrics from targets via HTTP endpoints (
/metrics
).Time-series database (TSDB): Stores data efficiently with labels.
PromQL (Prometheus Query Language): Allows powerful queries.
Service discovery: Works seamlessly in dynamic environments (e.g., Kubernetes, AWS EC2).
Integration with Grafana: For visualization.
Alertmanager: For handling alerts.
πΉ Prometheus Architecture
Prometheus Server β Scrapes and stores metrics.
Exporters β Agents that expose metrics (e.g., Node Exporter).
Service Discovery β Finds dynamic targets.
Alertmanager β Sends alerts to Slack, Email, PagerDuty, etc.
Visualization β Grafana or Prometheus UI.
πΉ Setting up Prometheus (Locally or on AWS EC2)
1. Install Prometheus
Binary Installation:
wget https://github.com/prometheus/prometheus/releases/latest/download/prometheus-*.linux-amd64.tar.gz tar -xvf prometheus-*.tar.gz cd prometheus-* ./prometheus --config.file=prometheus.yml
Docker Run:
docker run -p 9090:9090 prom/prometheus
Prometheus UI β http://localhost:9090
2. Basic Configuration (prometheus.yml
)
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
3. Add Node Exporter (System Metrics)
wget https://github.com/prometheus/node_exporter/releases/latest/download/node_exporter-*.linux-amd64.tar.gz
tar -xvf node_exporter-*.tar.gz
cd node_exporter-*
./node_exporter
Node Exporter exposes system metrics at β http://localhost:9100/metrics
Update prometheus.yml
:
scrape_configs:
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100']
Restart Prometheus and check targets in UI.
πΉ Metrics in Prometheus
Prometheus provides 4 primary metric types:
Counter β Always increases.
- Example:
http_requests_total
- Example:
Gauge β Goes up and down.
- Example:
node_memory_usage_bytes
- Example:
Histogram β Observes and categorizes values into buckets.
- Example: Request durations.
Summary β Similar to histogram but adds quantiles.
- Example: 95th percentile latency.
πΉ Exporters
Exporters are components that expose system/service metrics in Prometheus format.
Node Exporter β OS metrics (CPU, memory, disk, network).
Blackbox Exporter β HTTP, TCP, ICMP probes.
MySQL Exporter β Database performance.
Kube-State-Metrics β Kubernetes object states.
cAdvisor β Container-level metrics.
π― Interview Preparation Questions & Answers
Q1. Why Prometheus over traditional monitoring tools?
π Prometheus is lightweight, pull-based, time-series optimized, and cloud-native. Traditional tools rely on push-based models and struggle with dynamic environments like Kubernetes.
Q2. Difference between Counter and Gauge metrics?
π Counter = only increases (total requests handled).
π Gauge = fluctuates (CPU, memory usage).
Q3. What is an Exporter in Prometheus?
π Exporter exposes metrics of a service/system in Prometheus-compatible format.
Q4. How does Prometheus achieve High Availability?
π By using federated setups or external projects like Thanos, Cortex, or VictoriaMetrics for scaling and long-term storage.
Q5. Can Prometheus monitor Kubernetes natively?
π Yes. Prometheus integrates with Kubernetes service discovery and monitors pods, nodes, and cluster state seamlessly.
π‘ Key Takeaways
Prometheus is the de facto monitoring tool for cloud-native DevOps.
Core components: Prometheus Server, Exporters, Alertmanager, Grafana.
Metrics are time-series, categorized into Counter, Gauge, Histogram, and Summary.
Exporters extend Prometheus to any system (databases, OS, cloud services).
A must-know tool for DevOps Engineers & SREs.
π Day 26 Topic: Grafana β Dashboards & Visualization π¨
#DevOps #Prometheus #Monitoring #30DaysOfDevOps #SRE #Observability
Subscribe to my newsletter
Read articles from Tathagat Gaikwad directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
