How To Install and Configure Prometheus On a Linux Server

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

Install and Configure Prometheus

This guide explains how to install and configure the latest Prometheus on a Linux VM.

If you would like to install Prometheus on a Kubernetes cluster, please see the Prometheus on kubernetes guide.

Before You Begin

  1. Ensure that you have sudo access to the Linux server because the commands used in this guide require elevated privileges.
  2. The server has access to the internet for downloading Prometheus binary.
  3. Most importantly, firewall rules opened for accessing Prometheus port 9090 on the server.

Setup Prometheus Binaries

Step 1: Update the yum package repositories.

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

prometheus linux download link

Step 3: Create a Prometheus user, required directories, and make prometheus user as the owner of those directories.

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

Step 5: Copy prometheus and promtool binary from prometheus-files folder to /usr/local/bin and change the ownership to prometheus user.

Step 6: Move the consoles and console_libraries directories from prometheus-files to /etc/prometheus folder and change the ownership to prometheus user.

READ  How To Setup Consul Cluster (Multi-Node) on Linux - Beginners Guide

Setup Prometheus Configuration

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

Step 1: Create 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.

Setup Prometheus Service File

Step 1: Create a prometheus service file.

Step 2: Copy the following content to the file.

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.

The status should show the active state as shown below.

prometheus status

Access Prometheus Web UI

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

READ  How to Setup and Configure Docker Swarm Cluster

You should be able to see the following UI as shown below.

prometheus web UI

Right now we have just configured prometheus. You need to register the target in the prometheus.yml file to get the metrics from the source systems.

Follow Prometheus Node Exporter Guide to setup node exporter and registering it to Prometheus server.


Install and configure prometheus on linux

ONLINE COURSE: Monitoring and Alerting with Prometheus

Monitoring and Alerting of your infra and apps using the leading open-source monitoring system. Visualize using Grafana

  • Learn to setup and configure prometheus
  • Learn to setup alerting on prometheus
  • Configure grafana for visualizing the monitoring data.
  • Learn to instrument application for prometheus monitoring.
  • Understand monitoring and alerting setup for your whole infrastructure.

 

Free DevOps Resources

Get DevOps news, tutorials and resources in your inbox. A perfect way If you want to get started with devops. Like you, we dont like spam.