How To install and configure Prometheus on Linux

by Ismail.EL
0 comment

1. Introduction

Prometheus is an open source monitoring system and time series database which is very lightweight and has a good alerting mechanism.

2. Install and Configure Prometheus

This guide explains how to install and configure the latest Prometheus on a Linux server (debian,Ubuntu,Centos….).

2.1. Prerequisites

  1. Ensure that you have sudo access to the Linux server
  2. The server has access to the internet for downloading Prometheus.
  3. Prometheus port 9090 should be opened on the server.

2.2. Setup Prometheus Binaries

Step 1: Update the package repositories

Step 2: Go to official Prometheus downloads page and get the download link for Linux binary.

Step 3: Create a Prometheus user, required directory.

Step 4: Download the source using curl, untar it and rename the extracted folder to prometheus-files.

Step 4: make prometheus user as the owner of /etc/prometheus directory.

2.3. Setup Prometheus Configuration

All the prometheus configurations should be present in /etc/prometheus/prometheus.yml file.

Step 1: update the prometheus.yml file.

Step 2: Copy the following contents to the prometheus.yml file

Step 3: Change the ownership of the file to prometheus user.

2.4. Setup Prometheus Service File

Step 1: Create a prometheus service file in /etc/systemd/system/ directory

Step 3: Reload the systemd service to register the prometheus service and start the prometheus service.

Check the prometheus service status using the following command.

2.5. Access Prometheus Web UI

Now you will be able to access the prometheus UI on 9090 port of the prometheus server.

3. Install and Configure Node_exporter

Node exporter is the best way to collect all the Linux server related metrics of our current system (such as load average and free memory)

Step 1: Download node_exporter in this link downloads and download the latest version, like so:

Step 2: Create a node-exporter user, required directory.

Step 3: make node-exporter user as the owner of /etc/node-exporter directory.

Step 4: Setup Prometheus Service Filen

Create a node_exporter service file in /etc/systemd/system/ directory

Step 5: SReload the systemd service to register the node_exporter service and start the prometheus service.

Check the prometheus service status using the following command.

Step 6: we can set the service to always run at boot and start it:

Step 7: Add node exporter config in prometheus configuration to scrap the metrics

in scrape_configs: section add node exporter target

Step 7: Finally restart prometheus services to take in considiration our change.

In prometheus dashboard verify that node exporter is green in taget section as bellow

3700cookie-checkHow To install and configure Prometheus on Linux

Related Posts

Leave a Comment