Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
222 views12 pages

Prometheus and Grafana Complete Installation Guide

This document provides a comprehensive guide for installing Prometheus and Grafana, detailing the steps required for each phase including user creation, configuration, and service management. It covers the installation of Prometheus, Node Exporter, and Grafana, as well as adding data sources and monitoring servers. The document acknowledges the resources and support received during the setup process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
222 views12 pages

Prometheus and Grafana Complete Installation Guide

This document provides a comprehensive guide for installing Prometheus and Grafana, detailing the steps required for each phase including user creation, configuration, and service management. It covers the installation of Prometheus, Node Exporter, and Grafana, as well as adding data sources and monitoring servers. The document acknowledges the resources and support received during the setup process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Grafana Installation Documentation

Prometheus | Grafana Installation


Grafana Server: 192.168.0.149

This Document Covers:

Phase 01: Prometheus Installation


1. Creating Prometheus User
2. Prometheus Configuration Directories
3. Prometheus Binary Download
4. Extract Prometheus .tar Folder
5. Copy Prometheus Binaries Files
6. See Prometheus.yml File Configuration
7. Firewall
8. Permissions
9. Starting Prometheus
10. Create Prometheus Systemd Service file
Phase 02: Node Exporter Installation
1. Download Latest Node Exporter Version
2. Unzip Node Exporter Contents
3. Move The Binaries
4. Systemd Service for Node Exporter
5. Create a User & Start the Service
6. Verify Node Exporter is Running
Phase 03: Grafana Installation
1. Download Grafana GPG Keys
2. Create Grafana Repo
3. Install Grafana
4. Start the Grafana server with system
5. Configure the Grafana server to start at boot using systemd
Phase 04: Adding Data Source In Grafana
1. Click On The gear Icon - Administration
2. Prometheus
3. Prometheus URL
Phase 05: Adding Servers In Prometheus To Monitor
1. Check Server Architecture
2. Download Node Exporter Package
3. Move The Binaries
4. Systemd Service for Node Exporter
5. Create a User & Start the Service
6. Add Server To Prometheus Targets
7. Verify In Prometheus
SERVER SIDE: vm-grafana-149:
• Creating Prometheus User: By following command you can create Prometheus user. -M mean it will not create its home directory. -r will create this user as
system user. It means it’s ID will be chosen from system UID. -s /bin/false will set Prometheus user shell to false.

• Prometheus Configuration Directories: Since we are installing Prometheus from source, you need to create the respective configuration directories.

• Prometheus Binary Download: You can download Prometheus binaries from its official page which URL is: PageURL
Prometheus Downloading Version: https://github.com/prometheus/prometheus/releases/download/v3.2.0/prometheus-3.2.0.linux-amd64.tar.gz

1
Grafana Installation Documentation

• Downloading Prometheus: Here we can extract .tar folder of Prometheus. -x fill extract the files, -z uses gzip to uncompress the folder.

• Copy Prometheus Binaries Files: Copy the two Prometheus binary files, prometheus and promtool, under the extracted Prometheus archive directory to
the /usr/local/bin directory..

• See Prometheus.yml File Configuration: Here you can see the Prometheus file configuration

2
Grafana Installation Documentation

• Firewall: In your case, you may need to allow port 9090 for Prometheus from firewall. However, in my case I am not using any firewall

• Permissions: The command ensures that the Prometheus user has ownership of all files and directories inside /etc/prometheus, allowing it to read and modify
its configuration files.

• Starting Prometheus: To start Prometheus with our basic configuration file,run:

• Create Prometheus Systemd Service file: To be able to run Prometheus as a service, you need to create a systemd service file. So go into /etc/systemd/system/
directory and create prometheus.service file.

3
Grafana Installation Documentation

• Reload Systemd: Reload systemd daemon configuration. And Start and Enable Prometheus service to run at boot time.:

Phase 02: Node Exporter Installation


• Download Latest Node Exporter Version: Go into /tmp/ directory and download the latest node exporter version. In my case, I am downloading this
https://github.com/prometheus/node_exporter/releases/download/v1.9.0/node_exporter-1.9.0.linux-amd64.tar.gz version. Command is: curl -LO
https://github.com/prometheus/node_exporter/releases/download/v1.9.0/node_exporter-1.9.0.linux-amd64.tar.gz

• Unzip Node Exporter Contents: Unzip the version contents by this command: tar xvf node_exporter-1.9.0.linux-amd64.tar.gz

• Move The Binaries: Go into node_exporter-1.9.0.linux-amd64 directory by this command: cd node_exporter-1.9.0.linux-arm64/. Then move node_exporter
binary to this /usr/local/bin/ directory by following command mv node_exporter /usr/local/bin/

4
Grafana Installation Documentation

• Systemd Service for Node Exporter: Go into /etc/systemd/system/ directory and create a node_exporter.service file.

• File Content: Following should be in this file:


[Unit]
Description=Node Exporter
After=network.target

[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter

[Install]
WantedBy=multi-user.target

• Create a User & Start the Service: You need to create a system user for node exporter by this command useradd -rs /bin/false node_exporter and then reload
daemon

5
Grafana Installation Documentation

• Verify Node Exporter is Running: Run this command: curl http://localhost:9100/metrics to check is node exporter working fine. If everything is set up correctly,
you'll see a long list of system metrics.

Phase 03: Grafana Installation


• Download Grafana GPG Keys: This command downloads the Grafana GPG key, which is required to verify and securely install Grafana packages from its official
repository. Command is: wget -q -O gpg.key https://rpm.grafana.com/gpg.key. This command rpm --import gpg.key is used to import keys.

• Create Grafana Repo: Create /etc/yum.repos.d/grafana.repo with the following content


[grafana]
name=grafana
baseurl=https://rpm.grafana.com
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://rpm.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

• Install Grafana: To install Grafana OSS, run the following command. Command is: dnf install -y grafana:

6
Grafana Installation Documentation

• Start the Grafana server with systemd: To start the service, run the following commands: 1: systemctl daemon-reload, 2: systemctl start grafana-server

• Configure the Grafana server to start at boot using systemd: To configure the Grafana server to start at boot, run the following command. Command is systemctl
enable grafana-server.service

7
Grafana Installation Documentation

Phase 04: Adding Data Source In Grafana


• Click On The gear Icon - Administration: Go to the Administration tab and then click on the “Go to connections” button. Then click on “Add data source” as in
second screenshot.

8
Grafana Installation Documentation

• Prometheus: Click on Prometheus.

• Prometheus URL: Give its appropriate name and give the URL of your Prometheus server. And the click on “Save and test”.

Phase 05: Adding Servers In Prometheus To Monitor


• Check Server Architecture: First of all you need to check your server architecture so that you can download the required node exporter package to install:

• Download Node Exporter Package: Now download the relevant node exporter package. You can use following command: wget
https://github.com/prometheus/node_exporter/releases/download/v1.9.0/node_exporter-1.9.0.linux-amd64.tar.gz

9
Grafana Installation Documentation

• Move The Binaries: Go into node_exporter-1.9.0.linux-amd64 directory by this command: cd node_exporter-1.9.0.linux-arm64/. Then move node_exporter
binary to this /usr/local/bin/ directory by following command mv node_exporter /usr/local/bin/

• Systemd Service for Node Exporter: Go into /etc/systemd/system/ directory and create a node_exporter.service file.

• File Content: Following should be in this file:


[Unit]
Description=Node Exporter
After=network.target

[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter

[Install]
WantedBy=multi-user.target
• Create a User & Start the Service: You need to create a system user for node exporter by this command useradd -rs /bin/false node_exporter and then reload
daemon

10
Grafana Installation Documentation

• Add Server To Prometheus Targets: Go into this /etc/prometheus/prometheus.yml and add your server IP with port 9100 under static_configs and then
restart Prometheus server.

• Verify In Prometheus: Go into Prometheus web UI and You should see 192.168.0.223:9100 listed as UP.

11
Grafana Installation Documentation

Acknowledgement: Thanks to my company PlanetBeyond for allocating me resources to set up this monitoring tool on their infra for practice purpose. I also pay tribute
to Prometheus and Grafana Official Documentation, kifarunix, and Sir Ahsan for guidance on this topic. Here is the list of this documentation URL:
• Prometheus installation
• Grafana Installation
Here I also want to mention that I took ChatGPT help during its installation. It’s a really good tool for learning and implementing new things.

Regards:
Khurram Shahzad

12

You might also like