Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 16, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 16, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 16, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 16, 2025

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025

      Minecraft licensing robbed us of this controversial NFL schedule release video

      May 16, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The power of generators

      May 16, 2025
      Recent

      The power of generators

      May 16, 2025

      Simplify Factory Associations with Laravel’s UseFactory Attribute

      May 16, 2025

      This Week in Laravel: React Native, PhpStorm Junie, and more

      May 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025
      Recent

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Operating Systems»Linux»How to Set Up Prometheus and Grafana on Ubuntu: A Step-by-Step Guide

    How to Set Up Prometheus and Grafana on Ubuntu: A Step-by-Step Guide

    March 19, 2025

    Monitoring your systems doesn’t have to be a chore. If you’re running an Ubuntu server and want to keep tabs on performance metrics—like CPU usage, memory, or disk I/O—Prometheus and Grafana are a dream team. Prometheus collects the data, and Grafana turns it into beautiful, easy-to-read dashboards. I’ve set this up a few times myself, and while it might seem daunting at first, it’s pretty straightforward once you break it down. Let’s walk through it together, step by step, and get your monitoring stack running on Ubuntu.

    For this guide, I am running a Ubuntu 24.04 (a solid LTS release as of March 2025) system in my AWS account , but it should work fine on previous versions like 22.04 too. You’ll need sudo privileges and a basic comfort with the terminal. Let’s start configuration.

    Step 1: Update Your System

    First things first—let’s make sure your Ubuntu system is fresh and ready. Open your terminal and run:

    apt update && sudo apt upgrade -y 
    

    This grabs the latest package lists and updates everything installed. It’s a good habit to start with, especially when you’re about to add new software.

    Step 2: Install Prometheus

    Prometheus is the engine here—it scrapes metrics from your system and stores them. We’ll install it manually using the precompiled binary, which gives us full control.

    1. Create a Prometheus User: To keep things tidy and secure, let’s set up a dedicated system user for Prometheus:
      sudo useradd --no-create-home --shell /bin/false prometheus
      
    2. Make Directories: Prometheus needs a couple of spots to store its data and config:
      sudo mkdir /etc/prometheus
      sudo mkdir /var/lib/prometheus
      sudo chown prometheus:prometheus /etc/prometheus /var/lib/prometheus
      
    3. Download Prometheus: Head to the Prometheus download page (or use curl to grab the latest version). As of March 2025, the latest stable release might be something like 2.53.x—check prometheus.io/download/ to confirm. Here’s how I usually download it:
      wget https://github.com/prometheus/prometheus/releases/download/v2.53.4/prometheus-2.53.4.linux-amd64.tar.gz
      

      Adjust the version number if it’s different.

    4. Extract and Move Files: Unpack the tarball and move the binaries and config files where they belong:
      tar xvf prometheus-2.53.4.linux-amd64.tar.gz
      cd prometheus-2.53.4.linux-amd64
      sudo cp prometheus promtool /usr/local/bin/
      sudo cp -r consoles console_libraries /etc/prometheus/
      sudo cp prometheus.yml /etc/prometheus/
      sudo chown -R prometheus:prometheus /etc/prometheus
      
    5. Set Up a Service To run Prometheus automatically, create a systemd service file:
      sudo nano /etc/systemd/system/prometheus.service
      

      Paste this in:

      
      [Unit]
      Description=Prometheus Monitoring
      Wants=network-online.target
      After=network-online.target
      
      [Service]
      User=prometheus
      Group=prometheus
      Type=simple
      ExecStart=/usr/local/bin/prometheus 
          --config.file /etc/prometheus/prometheus.yml 
          --storage.tsdb.path /var/lib/prometheus/ 
          --web.console.templates=/etc/prometheus/consoles 
          --web.console.libraries=/etc/prometheus/console_libraries
      
      [Install]
      WantedBy=multi-user.target
      
      

      Save it (Ctrl+O, Enter, Ctrl+X in nano) and enable the service:

      sudo systemctl daemon-reload
      sudo systemctl start prometheus
      sudo systemctl enable prometheus
      
    6. Check It’s Running:

      Visit http://your-server-ip:9090 in your browser. If you see the Prometheus UI, you’re rock. It’s scraping its own metrics by default—pretty cool, right?

      Install Prometheus on Ubuntu
      Prometheus Dashboard

    Step 3: Install Node Exporter (Optional but Recommended)

    Prometheus is great, but it needs exporters to pull system-level metrics. Node Exporter is perfect for this—it grabs stuff like CPU, memory, and disk stats.

    1. Download Node Exporter: Grab the latest version from the Prometheus download page:
      wget https://github.com/prometheus/node_exporter/releases/download/v1.9.0/node_exporter-1.9.0.linux-amd64.tar.gz
      
    2. Extract and Install
      tar xvf node_exporter-1.9.0.linux-amd64.tar.gz
      sudo cp node_exporter-1.9.0.linux-amd64/node_exporter /usr/local/bin/
      sudo useradd --no-create-home --shell /bin/false node_exporter
      sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter
      
    3. Set Up a Service: Lets create a systemd file first
      sudo nano /etc/systemd/system/node_exporter.service
      

      Add this:

      
      [Unit]
      Description=Node Exporter
      Wants=network-online.target
      After=network-online.target
      
      [Service]
      User=node_exporter
      Group=node_exporter
      Type=simple
      ExecStart=/usr/local/bin/node_exporter
      
      [Install]
      WantedBy=multi-user.target
      
      

      Save, then start it:

      sudo systemctl daemon-reload
      sudo systemctl start node_exporter
      sudo systemctl enable node_exporter
      
    4. Update Prometheus Config: Edit /etc/prometheus/prometheus.yml:
      sudo nano /etc/prometheus/prometheus.yml
      

      Add this under scrape_configs:

      
      - job_name: 'node_exporter'
        static_configs:
          - targets: ['localhost:9100']
      
      
    5. Restart Prometheus:
      sudo systemctl restart prometheus
      

    Step 4: Install Grafana

    Now, let’s get Grafana running to visualize all this data. It’s the pretty face of our setup.

    1. Add Grafana Repository: Install some dependencies first
      sudo apt install -y apt-transport-https software-properties-common wget
      

      Then add the GPG key and repo:

      wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
      echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
      
    2. Install Grafana: Run the following command to grafana on your Ubuntu system.
      sudo apt update
      sudo apt install grafana -y
      
    3. Start Grafana: Enable and start it:
      sudo systemctl start grafana-server
      sudo systemctl enable grafana-server
      
    4. Access Grafana: Go to http://your-server-ip:3000. Log in with the default credentials: admin / admin.
      Install Grafana on Ubuntu
      Grafana login screen

      After login, It will prompt you to change the password—do it.

    Step 5: Connect Grafana to Prometheus

    Now its time to tie it all together.

    5.1. Add Prometheus as a Data Source

    1. In Grafana, click the gear icon (Configuration) > “Data Sources” > “Add data source”.
    2. Select “Prometheus.” Set the URL to http://localhost:9090 (or your server’s IP if it’s remote).
    3. Click “Save & Test” —if it says “Data source is working,” you’re set.
    Connect Grafana with Prometheus
    Connect Grafana with Prometheus

    5.2 Import a Dashboard

    1. Click the “+” icon > “Import”.
    2. Use dashboard ID 1860 (Node Exporter Full—it’s a classic).
    3. Select your Prometheus data source and hit “Import”.
    4. All set, you’ve got a slick dashboard showing your system metrics.
    Adding Node_exporter Dashboard to Graphana
    Node_exporter Dashboard in Graphana

    You can use any pre defined dashboards for various data sources based on your requirements.

    Step 6: Explore and Customize

    Take a minute to poke around. Grafana’s dashboards are super flexible—you can tweak panels, add alerts, or build your own from scratch. If you’re monitoring more than one machine, just install Node Exporter on each and update your prometheus.yml with their IPs.

    Wrapping Up

    That’s it! You’ve got Prometheus scraping metrics and Grafana showing them off. It’s a powerful combo—once you start digging into the data, you’ll wonder how you managed without it. I’ve used this setup to catch memory leaks and disk issues before they became disasters. What do you think—gonna give it a shot? Let me know how it goes!

    The post How to Set Up Prometheus and Grafana on Ubuntu: A Step-by-Step Guide appeared first on TecAdmin.

    Source: Read More

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleRilasciato PeerTube 7.1: Miglioramenti per i Podcast e una Riproduzione più Stabile
    Next Article Mastering Docker Containers: Advanced Tips for Sysadmins in 2025

    Related Posts

    News & Updates

    Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

    May 16, 2025
    News & Updates

    Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

    May 16, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    10 Artificial Intelligence APIs for Developers

    Development

    Shadowenv performs a set of manipulations to the process environment

    Linux

    Meet Aioli: A Unified Optimization Framework for Language Model Data Mixing

    Development

    How to Set Up Signal Proxy to Help Bypass Censorship in Russia and Venezuela

    Development

    Highlights

    NestJS on Deno?

    June 13, 2024

    Comments Source: Read More 

    Knowledge Transfer from Vision Foundation Models for Efficient Training of Small Task-specific Models

    May 15, 2024

    PyPI Attack: ChatGPT, Claude Impersonators Deliver JarkaStealer via Python Libraries

    November 22, 2024

    CVE-2025-3861 – WordPress Prevent Direct Access Unauthorized Access Vulnerability

    April 25, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.