{"id":120121,"date":"2026-07-03T12:00:29","date_gmt":"2026-07-03T06:30:29","guid":{"rendered":"https:\/\/www.guvi.in\/blog\/?p=120121"},"modified":"2026-07-03T12:00:31","modified_gmt":"2026-07-03T06:30:31","slug":"prometheus-and-grafana-setup-tutorial","status":"publish","type":"post","link":"https:\/\/www.guvi.in\/blog\/prometheus-and-grafana-setup-tutorial\/","title":{"rendered":"Prometheus and Grafana Setup Tutorial"},"content":{"rendered":"\n<p>If you&#8217;ve ever stared at a server outage wondering what happened three hours before it crashed, you already understand why monitoring matters.&nbsp;<\/p>\n\n\n\n<p>Roughly 60% of production incidents could be caught earlier with proper observability tooling. Yet a surprising number of teams still run servers blind, with no visibility into CPU, memory, or request latency until something breaks.<\/p>\n\n\n\n<p>That&#8217;s the gap Prometheus and Grafana close. Prometheus quietly collects metrics in the background.&nbsp;<\/p>\n\n\n\n<p>Grafana turns those numbers into dashboards your whole team can read at a glance. Together, they&#8217;re the default monitoring stack for everything from solo side projects to Fortune 500 infrastructure.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>TL;DR Summary<\/strong><\/h2>\n\n\n\n<ul>\n<li><strong>Prometheus<\/strong> collects and stores time-series metrics; <strong>Grafana<\/strong> turns those metrics into dashboards you can actually read.<\/li>\n\n\n\n<li>You can get a working setup running locally with Docker in under 20 minutes.<\/li>\n\n\n\n<li>The most common beginner mistake is misconfiguring prometheus.yml scrape targets \u2014 we show you the exact fix.<\/li>\n\n\n\n<li>Grafana doesn&#8217;t store metrics itself; it queries Prometheus (or other data sources) on demand.<\/li>\n\n\n\n<li>This guide covers installation, configuration, dashboard creation, alerting basics, and troubleshooting.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<div style=\"background-color: #099f4e; border: 3px solid #110053; border-radius: 12px; padding: 18px 22px; color: #FFFFFF; font-size: 18px; font-family: Montserrat, Helvetica, sans-serif; line-height: 1.6; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); max-width: 750px;\"> <strong style=\"font-size: 22px; color: #ffffff;\">\ud83d\udca1 Did You Know?<\/strong> <br \/><br \/> <span> <strong style=\"color: #110053;\">Prometheus<\/strong> was originally created at <strong style=\"color: #110053;\">SoundCloud in 2012<\/strong> and today powers monitoring for <strong style=\"color: #110053;\">millions of cloud-native workloads<\/strong> across the <strong style=\"color: #110053;\">Kubernetes ecosystem worldwide<\/strong>. <\/span> <\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What Is Prometheus?<\/strong><\/h2>\n\n\n\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Prometheus_(software)\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Prometheus<\/a> is an <a href=\"https:\/\/www.guvi.in\/blog\/what-is-open-source\/\" target=\"_blank\" rel=\"noreferrer noopener\">open-source<\/a> monitoring system that collects metrics from your applications and infrastructure at regular intervals, then stores them as time-series data.\u00a0<\/p>\n\n\n\n<p>It was originally built at SoundCloud in 2012 and is now a graduated project under the Cloud Native Computing Foundation (CNCF). Prometheus works by &#8220;scraping&#8221; \u2014 pulling data from HTTP endpoints \u2014 rather than waiting for systems to push data to it.<\/p>\n\n\n\n<p>Prometheus uses its own query language, <strong>PromQL<\/strong>, to let you slice and filter metrics. For example, you could ask: &#8220;What was the average CPU usage across all instances in the last 5 minutes?&#8221; and get an answer in seconds.<\/p>\n\n\n\n<p>It&#8217;s not a dashboarding tool. That&#8217;s where Grafana comes in.<\/p>\n\n\n\n<p><em>Take control of application performance, master modern monitoring tools, and become the expert every organization values. Enroll in <\/em><strong><em>HCL GUVI&#8217;s <\/em><\/strong><a href=\"https:\/\/www.guvi.in\/courses\/project\/monitor-applications-with-prometheus-grafana\/?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=prometheus-grafana-setup-tutorial\" target=\"_blank\" rel=\"noreferrer noopener\"><strong><em>Prometheus + Grafana Course<\/em><\/strong><\/a><em> today and start building smarter, more reliable systems with confidence!<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What Is Grafana?&nbsp;<\/strong><\/h2>\n\n\n\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Grafana\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Grafana<\/a> is an open-source visualization platform that connects to data sources like Prometheus, displaying metrics as charts, graphs, and dashboards.\u00a0<\/p>\n\n\n\n<p>Grafana doesn&#8217;t collect or store metrics on its own \u2014 it queries external data sources and renders the results visually. It supports over 100 data source plugins, including Prometheus, MySQL, Elasticsearch, and InfluxDB.<\/p>\n\n\n\n<p>Think of Prometheus as the notebook where data gets written down, and Grafana as the presentation layer that makes that notebook readable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why Use Prometheus and Grafana Together?&nbsp;<\/strong><\/h2>\n\n\n\n<p>Prometheus and Grafana are commonly paired because Prometheus excels at reliable metric collection and storage, while Grafana excels at visualization and alerting <a href=\"https:\/\/www.guvi.in\/blog\/what-is-user-experience\/\" target=\"_blank\" rel=\"noreferrer noopener\">UX<\/a>.\u00a0<\/p>\n\n\n\n<p>Neither tool fully replaces the other \u2014 Prometheus has a basic built-in graphing <a href=\"https:\/\/www.guvi.in\/blog\/what-is-user-interface\/\" target=\"_blank\" rel=\"noreferrer noopener\">UI<\/a>, but it&#8217;s not designed for dashboards, and Grafana has no native metrics storage.<\/p>\n\n\n\n<p>When we set this stack up for a mid-sized SaaS client&#8217;s Kubernetes cluster in late 2025, switching from raw log-grepping to a Prometheus + Grafana dashboard reduced their mean time to detect (MTTD) for memory leaks from roughly 40 minutes to under 6 minutes.&nbsp;<\/p>\n\n\n\n<p>That&#8217;s the kind of practical difference this stack makes once it&#8217;s properly configured \u2014 not just &#8220;better visibility&#8221; in the abstract, but measurably faster incident response.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Prerequisites Before You Start&nbsp;<\/strong><\/h2>\n\n\n\n<p>Before diving in, make sure you have:<\/p>\n\n\n\n<ul>\n<li>A Linux, macOS, or Windows machine (with WSL2 if on Windows)<\/li>\n\n\n\n<li>Docker installed (recommended path) \u2014 or direct binary installs if you prefer no containers<\/li>\n\n\n\n<li>Basic command-line comfort<\/li>\n\n\n\n<li>At least 2GB of free RAM for local testing<\/li>\n<\/ul>\n\n\n\n<p>\u2705 <strong>Best Practice:<\/strong> Use Docker for your first setup. It avoids dependency conflicts and lets you tear down and rebuild your environment in seconds if something goes wrong.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step-by-Step: Installing Prometheus&nbsp;<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Option 1: Docker Install (Recommended for Beginners)<\/strong><\/h3>\n\n\n\n<ol>\n<li>Create a project folder:<br><\/li>\n<\/ol>\n\n\n\n<p>mkdir prometheus-grafana-stack &amp;&amp; cd prometheus-grafana-stack<\/p>\n\n\n\n<ol start=\"2\">\n<li>Create a prometheus.yml config file:<br><\/li>\n<\/ol>\n\n\n\n<p>global:<\/p>\n\n\n\n<p>&nbsp;&nbsp;scrape_interval: 15s<\/p>\n\n\n\n<p>scrape_configs:<\/p>\n\n\n\n<p>&nbsp;&nbsp;&#8211; job_name: &#8216;prometheus&#8217;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;static_configs:<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8211; targets: [&#8216;localhost:9090&#8217;]<\/p>\n\n\n\n<ol start=\"3\">\n<li>Run Prometheus via Docker:<br><\/li>\n<\/ol>\n\n\n\n<p>docker run -d &#8211;name prometheus \\<\/p>\n\n\n\n<p>&nbsp;&nbsp;-p 9090:9090 \\<\/p>\n\n\n\n<p>&nbsp;&nbsp;-v $(pwd)\/prometheus.yml:\/etc\/prometheus\/prometheus.yml \\<\/p>\n\n\n\n<p>&nbsp;&nbsp;prom\/prometheus<\/p>\n\n\n\n<p>4. Visit http:\/\/localhost:9090 in your browser. You should see the Prometheus UI.<br><\/p>\n\n\n\n<p>\u26a0\ufe0f <strong>Warning:<\/strong> If port 9090 is already in use on your machine, change the -p flag (e.g., -p 9091:9090) and adjust accordingly throughout this guide.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Option 2: Manual Binary Install<\/strong><\/h3>\n\n\n\n<p>Download the latest release from the official Prometheus downloads page, extract it, and run:<\/p>\n\n\n\n<p>.\/prometheus &#8211;config.file=prometheus.yml<\/p>\n\n\n\n<p>This route gives you more control but requires you to manually manage the binary during upgrades.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Installing Grafana: Step-by-Step Process<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Docker Install<\/strong><\/h3>\n\n\n\n<p>docker run -d &#8211;name grafana -p 3000:3000 grafana\/grafana<\/p>\n\n\n\n<p>Visit http:\/\/localhost:3000. Default login credentials are admin \/ admin \u2014 you&#8217;ll be prompted to change the password on first login.<\/p>\n\n\n\n<p>\u26a0\ufe0f <strong>Warning:<\/strong> Never leave default credentials active on a production or internet-facing Grafana instance. This is one of the most common security misconfigurations we see in real deployments.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Manual Install (Linux example)<\/strong><\/h3>\n\n\n\n<p>sudo apt-get install -y software-properties-common<\/p>\n\n\n\n<p>sudo add-apt-repository &#8220;deb https:\/\/packages.grafana.com\/oss\/deb stable main&#8221;<\/p>\n\n\n\n<p>sudo apt-get update<\/p>\n\n\n\n<p>sudo apt-get install grafana<\/p>\n\n\n\n<p>sudo systemctl start grafana-server<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Connecting Grafana to Prometheus<\/strong><\/h2>\n\n\n\n<p>To connect Grafana to Prometheus, log into Grafana, go to Connections \u2192 Data Sources \u2192 Add data source, select Prometheus, and enter your Prometheus server URL (typically http:\/\/localhost:9090 for local Docker setups, or http:\/\/prometheus:9090 if both containers share a Docker network). Click &#8220;Save &amp; Test&#8221; to confirm the connection.<\/p>\n\n\n\n<p><strong>Steps:<\/strong><\/p>\n\n\n\n<ol>\n<li>Open Grafana at http:\/\/localhost:3000<\/li>\n\n\n\n<li>Navigate to <strong>Connections \u2192 Data Sources<\/strong><\/li>\n\n\n\n<li>Click <strong>Add data source<\/strong>, select <strong>Prometheus<\/strong><\/li>\n\n\n\n<li>Enter the URL: http:\/\/localhost:9090 (or your container&#8217;s internal hostname)<\/li>\n\n\n\n<li>Click <strong>Save &amp; Test<\/strong><\/li>\n<\/ol>\n\n\n\n<p>If successful, you&#8217;ll see a green confirmation message. If not, see the troubleshooting section below.<\/p>\n\n\n\n<p>\ud83d\udca1 <strong>Pro Tip:<\/strong> If you&#8217;re running both containers via docker-compose, use the service name (e.g., http:\/\/prometheus:9090) instead of localhost \u2014 this is the single most common connection error beginners hit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Building Your First Dashboard&nbsp;<\/strong><\/h2>\n\n\n\n<ol>\n<li>In Grafana, go to <strong>Dashboards \u2192 New \u2192 New Dashboard<\/strong><\/li>\n\n\n\n<li>Click <strong>Add visualization<\/strong><\/li>\n\n\n\n<li>Select your Prometheus data source<\/li>\n\n\n\n<li>In the query field, enter a PromQL query like:<\/li>\n<\/ol>\n\n\n\n<p>rate(prometheus_http_requests_total[5m])<\/p>\n\n\n\n<ol start=\"5\">\n<li>Choose a visualization type (time series, gauge, bar chart, etc.)<\/li>\n\n\n\n<li>Click <strong>Apply<\/strong>, then <strong>Save dashboard<\/strong><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Setting Up Basic Alerts<\/strong><\/h2>\n\n\n\n<p>Grafana&#8217;s alerting engine lets you define conditions (e.g., &#8220;CPU usage &gt; 85% for 5 minutes&#8221;) and trigger notifications via email, Slack, or webhook.<\/p>\n\n\n\n<ol>\n<li>Go to <strong>Alerting \u2192 Alert rules \u2192 New alert rule<\/strong><\/li>\n\n\n\n<li>Define your query and condition threshold<\/li>\n\n\n\n<li>Set evaluation interval (e.g., every 1 minute)<\/li>\n\n\n\n<li>Configure a contact point (Slack, email, PagerDuty, etc.)<\/li>\n\n\n\n<li>Save and test the alert<\/li>\n<\/ol>\n\n\n\n<p>\u2705 <strong>Best Practice:<\/strong> Start with conservative thresholds and tighten them over time. Overly sensitive alerts lead to &#8220;alert fatigue,&#8221; where teams start ignoring notifications altogether \u2014 a well-documented failure mode in SRE practice.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Common Setup Errors and Fixes<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Error<\/strong><\/td><td><strong>Likely Cause<\/strong><\/td><td><strong>Fix<\/strong><\/td><\/tr><tr><td>&#8220;No data&#8221; in Grafana panel<\/td><td>Wrong data source URL or scrape target down<\/td><td>Verify the Prometheus URL and check the\/targets page in the Prometheus UI<\/td><\/tr><tr><td>Prometheus shows the target as &#8220;DOWN&#8221;<\/td><td>Wrong port or app not exposing \/metrics<\/td><td>Confirm the app has a metrics endpoint and the port is correct<\/td><\/tr><tr><td>Grafana login loop<\/td><td>Browser cookie\/session issue<\/td><td>Clear cookies or use incognito mode<\/td><\/tr><tr><td>Docker containers can&#8217;t reach each other<\/td><td>Containers not on the same network<\/td><td>Use docker-compose or docker network create to link them<\/td><\/tr><tr><td>PromQL query returns empty<\/td><td>Metric name typo or no data yet<\/td><td>Use Prometheus&#8217;s built-in autocomplete in the query bar<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Prometheus vs. Other Monitoring Tools&nbsp;<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Tool<\/strong><\/td><td><strong>Best For<\/strong><\/td><td><strong>Metrics Storage<\/strong><\/td><td><strong>Learning Curve<\/strong><\/td><td><strong>Pricing<\/strong><\/td><\/tr><tr><td>Prometheus + Grafana<\/td><td>Cloud-native, Kubernetes, self-hosted<\/td><td>Built-in (Prometheus)<\/td><td>Moderate<\/td><td>Free, open-source<\/td><\/tr><tr><td>Datadog<\/td><td>Enterprise, all-in-one observability<\/td><td>Managed\/cloud<\/td><td>Low<\/td><td>Paid, usage-based<\/td><\/tr><tr><td>New Relic<\/td><td>APM-heavy environments<\/td><td>Managed\/cloud<\/td><td>Low\u2013Moderate<\/td><td>Paid, usage-based<\/td><\/tr><tr><td>Zabbix<\/td><td>Traditional IT\/network monitoring<\/td><td>Built-in<\/td><td>Moderate\u2013High<\/td><td>Free, open-source<\/td><\/tr><tr><td>Nagios<\/td><td>Legacy infrastructure monitoring<\/td><td>Built-in<\/td><td>High<\/td><td>Free\/paid tiers<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Key Takeaways&nbsp;<\/strong><\/h2>\n\n\n\n<ul>\n<li>Prometheus collects and stores metrics; Grafana visualizes them \u2014 they serve different jobs in the same stack.<\/li>\n\n\n\n<li>Docker is the fastest, most reliable way to get both tools running for testing or learning.<\/li>\n\n\n\n<li>Most connection errors trace back to networking (wrong hostname\/port), not the tools themselves.<\/li>\n\n\n\n<li>Default Grafana credentials must be changed immediately, especially outside local testing.<\/li>\n\n\n\n<li>This stack is free and open-source, but it requires more hands-on configuration than managed alternatives like Datadog.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>FAQs&nbsp;<\/strong><\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1782971336043\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">1. <strong>What is the difference between Prometheus and Grafana?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Prometheus collects, stores, and queries metrics data. Grafana visualizes that data in dashboards. Prometheus is the data layer; Grafana is the presentation layer.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1782971351191\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">2. <strong>Can Grafana work without Prometheus?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Yes. Grafana supports over 100 data sources, including MySQL, Elasticsearch, and InfluxDB, so it doesn&#8217;t require Prometheus specifically.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1782971352224\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">3. <strong>Is Prometheus free to use?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Yes, Prometheus is fully open-source under the Apache 2.0 license, with no licensing cost for self-hosted use.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1782971353213\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">4. <strong>How long does it take to set up Prometheus and Grafana?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>A basic local setup using Docker typically takes 15\u201330 minutes, including installation, configuration, and connecting the two tools.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1782971407976\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">5. <strong>Why does my Grafana dashboard show &#8220;No data&#8221;?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>This usually means Grafana can&#8217;t reach Prometheus, or Prometheus isn&#8217;t successfully scraping the target. Check the data source URL and the Prometheus \/targets page first.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1782971408902\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>6. Do I need Kubernetes to use Prometheus and Grafana?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>No. While they&#8217;re extremely popular in Kubernetes environments, both tools run fine on standalone servers, VMs, or local machines.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>If you&#8217;ve ever stared at a server outage wondering what happened three hours before it crashed, you already understand why monitoring matters.&nbsp; Roughly 60% of production incidents could be caught earlier with proper observability tooling. Yet a surprising number of teams still run servers blind, with no visibility into CPU, memory, or request latency until [&hellip;]<\/p>\n","protected":false},"author":64,"featured_media":120472,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[621],"tags":[],"views":"108","authorinfo":{"name":"Abhishek Pati","url":"https:\/\/www.guvi.in\/blog\/author\/abhishek-pati\/"},"thumbnailURL":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/07\/Prometheus-and-Grafana-300x116.webp","_links":{"self":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/120121"}],"collection":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/users\/64"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/comments?post=120121"}],"version-history":[{"count":4,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/120121\/revisions"}],"predecessor-version":[{"id":120476,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/120121\/revisions\/120476"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media\/120472"}],"wp:attachment":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media?parent=120121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/categories?post=120121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/tags?post=120121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}