Prometheus Install

Docker Install

cat <<EOF > prometheus.yml
  scrape_interval:     10s
  evaluation_interval: 10s

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


This tells the Prometheus server to scrape itself on port 9090.

Now let’s create a Dockerfile that adds this on top of the prom/prometheus image:

cat <<EOF > Dockerfile
FROM prom/prometheus

# Add in the configuration file from the local directory.
ADD prometheus.yml /etc/prometheus/prometheus.yml

Next we can build and run it:

docker build -t prometheus_simple .
docker run -p 9090:9090 prometheus_simple

Control - C to stop this

Disabling SELinux

    Configure SELINUX=disabled in the /etc/selinux/config file:

    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #       enforcing - SELinux security policy is enforced.
    #       permissive - SELinux prints warnings instead of enforcing.
    #       disabled - No SELinux policy is loaded.
    # SELINUXTYPE= can take one of these two values:
    #       targeted - Targeted processes are protected,
    #       mls - Multi Level Security protection.

    Reboot your system. After reboot, confirm that the getenforce command returns Disabled:

    ~]~ getenforce

Manual Install

mkdir Downloads

cd Downloads


curl -LO ""

goto Root directory

mkdir Prometheus

cd Prometheus

tar -xvzf ~/Downloads/prometheus-2.2.1.linux-amd64.tar.gz

./prometheus --version

sudo vi /etc/systemd/system/node_exporter.service

This file should contain the path of the node_exporter executable, and also specify which user should run the executable. Accordingly, add the following code:

Description=Node Exporter



Reload systemd so that it reads the configuration file you just created.

sudo systemctl daemon-reload

At this point, Node Exporter is available as a service which can be managed using the systemctl command. Enable it so that it starts automatically at boot time.

sudo systemctl enable node_exporter.service
You can now either reboot your server, or use the following command to start the service manually:

sudo systemctl start node_exporter.service

Starting Prometheus Server

Enter the directory where you installed the Prometheus server:

cd ~/Prometheus/prometheus-0.16.0.linux-amd64
Before you start Prometheus, you must first create a configuration file for it called prometheus.yml.

vi ~/Prometheus/prometheus-0.16.0.linux-amd64/prometheus.yml
Copy the following code into the file.

  - job_name: "node"
    scrape_interval: "15s"
    - targets: ['localhost:9100']

This creates a scrape_configs section and defines a job called node. It includes the URL of your Node Exporter’s web interface in its array of targets. The scrape_interval is set to 15 seconds so that Prometheus scrapes the metrics once every fifteen seconds.

You could name your job anything you want, but calling it “node” allows you to use the default console templates of Node Exporter.

Save the file and exit.

Start the Prometheus server as a background process.

nohup ./prometheus > prometheus.log 2>&1 &

Note that you redirected the output of the Prometheus server to a file called prometheus.log. You can view the last few lines of the file using the tail command:

tail ~/Prometheus/prometheus-0.16.0.linux-amd64/prometheus.log

Once the server is ready, you will see the following messages in the file: Use a browser to visit Prometheus’s homepage available at http://your_server_ip:9090. You’ll see the following homepage.

These writings represent my own personal views alone.
Licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.