πŸš€ 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

  1. Prometheus Server – Scrapes and stores metrics.

  2. Exporters – Agents that expose metrics (e.g., Node Exporter).

  3. Service Discovery – Finds dynamic targets.

  4. Alertmanager – Sends alerts to Slack, Email, PagerDuty, etc.

  5. 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:

  1. Counter – Always increases.

    • Example: http_requests_total
  2. Gauge – Goes up and down.

    • Example: node_memory_usage_bytes
  3. Histogram – Observes and categorizes values into buckets.

    • Example: Request durations.
  4. 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

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