Author Archives: admin

How To Install Prometheus on Raspberry PI or Orange PI

Prometheus is a leading open-source monitoring solution with alerting functional. By default, Prometetheus export only itself metrics and need aditioanl module for accept more information. You can finde more information on: https://prometheus.io/

Safety First

We need one new user for prometeus service without home directory and shell access.

sudo useradd --no-create-home --shell /bin/false prometheus 

according linux best practise create two directorise, one for configuration and other for data.

sudo mkdir /etc/prometheus 
sudo mkdir /var/lib/prometheus

and set new user and group ownership

sudo chown prometheus:prometheus /etc/prometheus 
sudo chown prometheus:prometheus /var/lib/prometheus

Download and Unpack prometheus

Before download, find the latest stable verion on Prometeus download page. At this time it’s: prometheus-2.12.0.linux-armv7.tar.gz

download file and compere checksum:

cd ~
wget https://github.com/prometheus/prometheus/releases/download/v2.12.0/prometheus-2.12.0.linux-armv7.tar.gz
sha256sum prometheus-2.12.0.linux-armv7.tar.gz

if checksume match than unpack archive:

tar xvf  prometheus-2.12.0.linux-armv7.tar.gz 

copy files and directories

sudo cp  prometheus-2.12.0.linux-armv7.tar.gz/prometheus /usr/local/bin/ 
sudo cp prometheus-2.12.0.linux-armv7.tar.gz/promtool /usr/local/bin/
sudo cp -r prometheus-2.12.0.linux-armv7.tar.gz/consoles /etc/prometheus
sudo cp -r prometheus-2.12.0.linux-armv7.tar.gz/console_libraries /etc/prometheus

and set the user and group ownership

sudo chown prometheus:prometheus /usr/local/bin/prometheus 
sudo chown prometheus:prometheus /usr/local/bin/promtool
sudo chown -R prometheus:prometheus /etc/prometheus/consoles
sudo chown -R prometheus:prometheus /etc/prometheus/console_libraries

finally, delete files and directory from your home

rm -rf prometheus-2.12.0.linux-armv7.tar.gz prometheus-2.12.0.linux-armv7

Configuring prometeus to monitor itself

Create configuration in a file with named prometheus.yml:

sudo nano /etc/prometheus/prometheus.yml 

Prometheus config file /etc/prometheus/prometheus.yml

Important: Prometheus configuration file uses the YAML format, don’t user tabs!

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['localhost:9090']

set the user and group ownership

sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml

Let’s running Prometheus

create a new systemd service file.

sudo nano /etc/systemd/system/prometheus.service 

add following data into the file: /etc/systemd/system/prometheus.service

[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
    --config.file /etc/prometheus/prometheus.yml \
    --storage.tsdb.path /var/lib/prometheus/ \
    --web.console.templates=/etc/prometheus/consoles \
    --web.console.libraries=/etc/prometheus/console_libraries

[Install]
WantedBy=multi-user.target

then reload systemd,

sudo systemctl daemon-reload 

start service,

sudo systemctl start prometheus 

check status,

sudo systemctl status prometheus 

and after successful running enable the service to start on boot

sudo systemctl enable prometheus