Skip to main content

Prometheus with Grafana from BASIC to ADVANCE level – Complete Prometheus Guide to Master DevOps Infra Monitoring

 

🔍 Introduction

Infrastructure monitoring is like the health monitor for your servers, applications, and services. It lets you know when things go wrong before your users do. And if you’re in DevOps, Prometheus and Grafana are the two tools you must master.

In this complete guide, we’ll take you from zero to hero in Prometheus and Grafana — from basic installation to advanced visualization and alerting. Ready to take your DevOps monitoring skills to the next level? Let’s go!


🚀 Getting Started with Prometheus

What is Prometheus?

Prometheus is an open-source systems monitoring and alerting toolkit built originally at SoundCloud. It’s designed for reliability and scalability, making it perfect for dynamic cloud environments.

Core Features

  • A powerful time series database

  • Pull-based model over HTTP

  • PromQL – a flexible query language

  • Integrated Alertmanager

  • Service discovery integrations (Kubernetes, EC2, etc.)

Prometheus Architecture

  • Prometheus Server – scrapes and stores metrics

  • Exporters – expose metrics

  • Pushgateway – for ephemeral jobs

  • Alertmanager – handles alerts

  • Grafana – for visualizing data


🛠️ Installing Prometheus

System Requirements

  • 1-2 GB RAM minimum

  • 2 CPU cores

  • Go or Docker (optional)

Step-by-Step Installation

Linux/macOS:

bash
wget https://github.com/prometheus/prometheus/releases/download/v2.x.x/prometheus-2.x.x.linux-amd64.tar.gz tar -xvf prometheus-2.x.x.linux-amd64.tar.gz cd prometheus-2.x.x.linux-amd64 ./prometheus

Windows:


🧾 Understanding Prometheus Configuration

prometheus.yml File

This is the heart of your Prometheus config. It includes:

  • global config (scrape intervals, timeouts)

  • scrape_configs for job targets

  • Relabel configs

Example:

yaml
scrape_configs: - job_name: 'node_exporter' static_configs: - targets: ['localhost:9100']

📊 Key Concepts in Prometheus

Time Series Data

Prometheus stores data as a time series — a stream of timestamped values belonging to the same metric and label set.

Metric Types

  • Counter: Only increases (e.g., HTTP requests)

  • Gauge: Goes up and down (e.g., memory usage)

  • Histogram/Summary: For latency, durations, etc.


📈 Instrumenting Applications

Use client libraries like:

  • Go: prometheus/client_golang

  • Java: simpleclient

  • Python: prometheus_client

  • Node.js: prom-client

Example in Python:

python
from prometheus_client import start_http_server, Counter c = Counter('http_requests_total', 'Description of counter') start_http_server(8000)

🧩 Exporters in Prometheus

What are Exporters?

Exporters expose metrics on behalf of another system (like MySQL, Redis, etc.)

Popular Exporters

  • Node Exporter – OS metrics

  • Blackbox Exporter – probe endpoints

  • MySQL Exporter

  • Docker, HAProxy, JMX


📣 Alerting with Prometheus

Setting Up Alertmanager

Install and run alertmanager. Configure it in prometheus.yml under alerting.

Creating Alerts

yaml
groups: - name: example rules: - alert: HighCPUUsage expr: node_cpu_seconds_total > 90 for: 1m labels: severity: critical annotations: summary: "High CPU usage detected!"

📺 Introduction to Grafana

Grafana is the UI layer. It connects to Prometheus and turns raw metrics into beautiful, interactive dashboards.


📥 Installing Grafana

  • Download and install from Grafana Downloads

  • Start the server and access at http://localhost:3000


📊 Creating Dashboards

  • Add Prometheus as a data source

  • Create a new dashboard

  • Use PromQL queries to fill panels

Example query:

promql
rate(http_requests_total[5m])

⚡ Advanced Grafana Visualization

  • Use variables to build dynamic dashboards

  • Annotations for marking events

  • Alert rules inside panels


🧪 Real-Time Monitoring Project

Let’s say we want to monitor a Node.js API.

  • Instrument it using prom-client

  • Expose metrics on /metrics

  • Scrape using Prometheus

  • Build a Grafana dashboard with memory, CPU, and request rate

  • Set up alerts to Slack for 5xx errors


📡 Scaling Prometheus

For high-scale environments:

  • Federation: Query one Prometheus from another

  • Remote Storage: Use Cortex, Thanos for long-term storage


🧠 DevOps Monitoring Best Practices

  • Use labels wisely – they are cardinality bombs!

  • Reduce query load – don’t overuse heavy queries

  • Alert with context – use annotations for clarity


✅ Conclusion

Mastering Prometheus and Grafana gives you superpowers in DevOps. You’ll be able to track every part of your infrastructure in real-time, build sleek dashboards, and act on alerts proactively.

This stack is open-source, scalable, and future-proof. So, whether you’re an SRE, DevOps engineer, or just monitoring curious — it’s time to go beyond basic logging and take full control of your infrastructure!


❓ FAQs

Q1: Can I use Prometheus without Grafana?
Yes, but Grafana offers far better visualization than Prometheus' built-in UI.

Q2: Is Prometheus suitable for cloud-native monitoring?
Absolutely! It integrates well with Kubernetes, EC2, and more.

Q3: Can I monitor Windows servers?
Yes, using exporters like windows_exporter.

Q4: Does Prometheus support logs?
No, Prometheus is for metrics. Use Loki for logs.

Q5: What's the best way to scale Prometheus for large infra?
Use Thanos or Cortex for horizontal scaling and long-term storage.

Comments

Popular posts from this blog

Create a Complete Online Co-Op Multiplayer Game in Godot 4

  Creating a Complete Online Co-Op Multiplayer Game in Godot 4 is a major but highly rewarding project. Godot 4 introduced significant improvements to its networking architecture, making it more capable of handling multiplayer games , including online co-op experiences . In this guide, we’ll walk you through building a basic online co-op multiplayer game using Godot 4’s high-level multiplayer API . This game will allow multiple players to connect over a network and interact in a shared game world. 🎮 Project Overview Game Concept A top-down 2D co-op game where players control characters that can move around, collect items, and interact with each other. All players will see each other's movements in real time. Key Features: Host or join a multiplayer session Synchronize player movement across the network Use Godot’s high-level multiplayer API Optional: Chat system or shared inventory 🧰 Tools & Technologies Godot 4.x GDScript Godot’s High-Level M...

Learn 11 Ads Platforms – Google Ads, Meta Ads, Microsoft Ads, LinkedIn Ads, TikTok Ads, X Ads, Pinterest Ads

  Digital advertising has become the backbone of online business growth. Whether you’re running an eCommerce store, promoting a service, or building your personal brand, advertising platforms give you the power to reach the right audience at the right time. In this blog, we’ll explore 11 top advertising platforms —from Google Ads to TikTok Ads—that every marketer and business owner should know in 2025. 1. Google Ads The largest and most powerful ad platform in the world. Ad types: Search Ads, Display Ads, YouTube Ads, Shopping Ads. Best for: Driving targeted traffic, lead generation, eCommerce sales. Why use it? Google processes over 8.5 billion searches daily , making it a goldmine for businesses. 2. Meta Ads (Facebook & Instagram Ads) Meta’s advertising platform covers Facebook, Instagram, Messenger, and Audience Network. Ad types: Image Ads, Video Ads, Carousel Ads, Reels Ads, Lead Forms. Best for: B2C businesses, brand awareness, community growt...

📈 Unleash Your Data Story: 2023 Tableau & Python Masterclass – Free Coupon Inside! 🚀

Introduction Unlock the power of data visualization in 2023 with our Tableau & Python Masterclass . This guide is your key to mastering the art of data storytelling, providing a unique blend of Tableau and Python expertise. Grab your free coupon today and dive into the world of impactful data narratives. The Foundation: Unleash Your Data Story Set the stage for your data storytelling journey with a solid foundation in our Tableau & Python Masterclass. Explore the synergy between two powerful tools, Tableau and Python, and learn how to craft compelling data stories. 📈 Unleash Your Data Story: 2023 Tableau & Python Masterclass – Free Coupon Inside! 🚀 Embark on an educational journey with our exclusive Tableau & Python Masterclass. Uncover the potential of combining Tableau and Python for impactful data storytelling. Don't miss out—grab your free coupon now and become a master storyteller. Navigating the Data Landscape Explore the vast landscape of data storytelling ...