How To Install Prometheus On Centos 7

How To Articles

I recently had the opportunity to install Prometheus on CentOS 7, and I wanted to share my experience and walk you through the process. Prometheus is an open-source monitoring and alerting toolkit that is widely used in the industry. It provides a powerful set of features for gathering metrics and monitoring various aspects of your systems and applications.

Step 1: Install Docker

Before we proceed with Prometheus installation, we need to make sure that Docker is installed on our CentOS 7 machine. Docker allows us to run Prometheus in a containerized environment, which makes the installation process easier and more manageable.

To install Docker, open a terminal window and run the following commands:

sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo
sudo yum install -y docker-ce
sudo systemctl start docker
sudo systemctl enable docker

Once Docker is installed and running, we can proceed with the Prometheus installation.

Step 2: Create a Prometheus Configuration File

To configure Prometheus, we need to create a configuration file. Create a file named prometheus.yml in a directory of your choice. You can use the following command to create the file:

touch prometheus.yml

Open the file with a text editor and paste the following configuration:

scrape_interval: 15s
evaluation_interval: 15s

- job_name: prometheus
- targets: ['localhost:9090']

This configuration sets the scrape interval to 15 seconds and specifies that Prometheus should scrape metrics from itself (running on localhost:9090).

Step 3: Run Prometheus with Docker

With Docker and the Prometheus configuration file in place, we can now run Prometheus using the following command:

sudo docker run -d -p 9090:9090 -v /path/to/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus

Make sure to replace /path/to/prometheus.yml with the actual path to your Prometheus configuration file.

After running the command, Prometheus will start running in a Docker container and will be accessible on port 9090 of your CentOS 7 machine.

Step 4: Access the Prometheus Web Interface

To access the Prometheus web interface, open a web browser and navigate to http://localhost:9090. This will take you to the Prometheus dashboard, where you can explore and visualize the collected metrics.

From the web interface, you can configure and manage various aspects of Prometheus, such as adding new scrape targets and creating custom alert rules.


Installing Prometheus on CentOS 7 is a straightforward process, thanks to Docker. By following the steps outlined in this article, you should now have Prometheus up and running on your CentOS 7 machine. From here, you can start exploring its powerful monitoring and alerting capabilities, and leverage it to gain valuable insights into your systems and applications.