Skip to main content

Observability with prometheus (installation)

 

How to Install Prometheus 3.0: A Beginner-Friendly Guide

Prometheus 3.0 is a robust tool for monitoring and alerting, providing insights into your system's performance. Here's a step-by-step guide to help you install and set up Prometheus on a Linux-based server.


Step 1: Prepare Your Environment

  1. Update Your System Make sure your system is up-to-date:

    sudo apt update && sudo apt upgrade -y
  2. Install Required Tools Ensure you have wget or curl installed to download Prometheus:

    sudo apt install wget curl -y

Step 2: Download Prometheus 3.0

  1. Visit the official Prometheus downloads page. Alternatively, you can use wget to download the binary directly:

    wget https://github.com/prometheus/prometheus/releases/download/v3.0.0/prometheus-3.0.0.linux-amd64.tar.gz
  2. Extract the downloaded file:

    tar -xvzf prometheus-3.0.0.linux-amd64.tar.gz cd prometheus-3.0.0.linux-amd64

Step 3: Move Prometheus to a Suitable Location

  1. Move Prometheus and its files to /usr/local/bin/:

    sudo mv prometheus /usr/local/bin/ sudo mv promtool /usr/local/bin/
  2. Move the default configuration and libraries to /etc/prometheus:

    sudo mkdir /etc/prometheus sudo mv prometheus.yml /etc/prometheus/

Step 4: Create a Prometheus User

To enhance security, run Prometheus under a dedicated user:

sudo useradd --no-create-home --shell /bin/false prometheus

Update ownership of Prometheus directories:

sudo chown -R prometheus:prometheus /etc/prometheus sudo chown prometheus:prometheus /usr/local/bin/prometheus sudo chown prometheus:prometheus /usr/local/bin/promtool

Step 5: Configure Prometheus as a Service

  1. Create a systemd service file:

    sudo nano /etc/systemd/system/prometheus.service
  2. Add the following configuration:

    [Unit] Description=Prometheus Monitoring System 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/ [Install]  WantedBy=multi-user.target
  3. Reload systemd to apply the new service:

    sudo systemctl daemon-reload
  4. Start and enable the Prometheus service:

    sudo systemctl start prometheus sudo systemctl enable prometheus

Step 6: Verify Installation

  1. Check the status of the Prometheus service:

    sudo systemctl status prometheus
  2. Access the Prometheus web interface: Open your browser and go to:

    Replace <your-server-ip> with your server’s IP address.

  3. http://<your-server-ip>:9090


Step 7: Configure Prometheus Targets

  1. Open the Prometheus configuration file:

    sudo nano /etc/prometheus/prometheus.yml
  2. Add or modify the scrape_configs section to include your monitoring targets:

    scrape_configs: - job_name: 'example-job' static_configs: - targets: ['localhost:9090']
  3. Restart Prometheus to apply changes:

    sudo systemctl restart prometheus


Comments

Popular posts from this blog

Observability with grafana and prometheus (SSO configutation with active directory)

How to Set Up Grafana Single Sign-On (SSO) with Active Directory (AD) Grafana is a powerful tool for monitoring and visualizing data. Integrating it with Active Directory (AD) for Single Sign-On (SSO) can streamline access and enhance security. This tutorial will guide you through the process of configuring Grafana with AD for SSO. Prerequisites Active Directory Domain : Ensure you have an AD domain set up. Domain: bazboutey.local AD Server IP: 192.168.170.212 Users: grafana (for binding AD) user1 (to demonstrate SSO) we will end up with a pattern like this below Grafana Installed : Install Grafana on your server. Grafana Server IP: 192.168.179.185 Administrator Privileges : Access to modify AD settings and Grafana configurations. Step 1: Configure AD for LDAP Integration Create a Service Account in AD: Open Active Directory Users and Computers. Create a user (e.g., grafana ). Assign this user a strong password (e.g., Grafana 123$ ) and ensure it doesn’t expire. Gather Required AD D...

Deploying a Scalable Monitoring Stack Lab on AWS using Terraform and Ansible

Deploying a Scalable Monitoring Stack Lab on AWS using Terraform and Ansible Introduction Effective monitoring is a cornerstone of cloud infrastructure management, ensuring high availability and performance. This guide provides a professional walkthrough on deploying Prometheus , Grafana , and Node Exporter on AWS using Terraform for infrastructure provisioning and Ansible for configuration management. This lab will create a prometheus server and a grafana server, It will install node exporter on both server. You should be able to see the metrics in grafana, we already install a node exporter dashboard for the user. The diagram below will give you an idea of what the architecture will look like If you want to replicate this lab, you can find the complete code repository here: GitHub - MireCloud Terraform Infra .  Infrastructure Setup with Terraform 1. Creating a Dedicated VPC To ensure isolation, we define a VPC named Monitoring with a CIDR block of 10.0.0.0/16 . reso...

Building a Static Website on AWS with Terraform

The Journey to a Fully Automated Website Deployment A few weeks ago, I found myself needing to deploy a simple static website . Manually setting up an S3 bucket, configuring permissions, and linking it to a CloudFront distribution seemed like a tedious process. As someone who loves automation, I decided to leverage Terraform to simplify the entire process. Why Terraform? Infrastructure as Code (IaC) is a game-changer. With Terraform, I could:  Avoid manual setup errors  Easily reproduce and  Automate security best practices Instead of clicking through AWS settings, I wrote a few Terraform scripts and deployed everything in minutes. Let me walk you through how I did it!  Architecture Overview The architecture consists of three main components: User:  The end user accesses the website via a CloudFront URL.  CloudFront Distribution:  Acts as a content delivery network (CDN) to distribute content efficiently, reduce latency, and enhance security. It ...