Goal:
This blog will help you with prometheus installation.
Installation Steps.
-
Create user without a home directory.
sudo useradd --no-create-home --shell /bin/false prometheus
Create directories to copy prometheus config and library files and give permission to user that you crated.
sudo mkdir /etc/prometheus sudo mkdir /var/lib/prometheus sudo chown prometheus:prometheus /etc/prometheus sudo chown prometheus:prometheus /var/lib/prometheus
Download and unzip prometheus from github.
curl -LO https://github.com/prometheus/prometheus/releases/download/v2.3.2/prometheus-2.3.2.linux-amd64.tar.gz
tar -xvf prometheus-2.3.2.linux-amd64.tar.gz mv prometheus-2.3.2.linux-amd64 prometheus-files
Copy prometheus binary files to bin directory and give permission.
sudo cp prometheus-files/prometheus /usr/local/bin/ sudo cp prometheus-files/promtool /usr/local/bin/ sudo chown prometheus:prometheus /usr/local/bin/prometheus sudo chown prometheus:prometheus /usr/local/bin/promtool
Copy prometheus config files to directory we have created and give permission.
sudo cp -r prometheus-files/consoles /etc/prometheus sudo cp -r prometheus-files/console_libraries /etc/prometheus sudo chown -R prometheus:prometheus /etc/prometheus/consoles sudo chown -R prometheus:prometheus /etc/prometheus/console_libraries
Open prometheus YAML file and change server details from where you want to scrap log that has to be monitor.
sudo vi /etc/prometheus/prometheus.yml
Copy below content in file.
global: scrape_interval: 10s scrape_configs: - job_name: 'prometheus' scrape_interval: 5s static_configs: - targets: ['localhost:9090']
Give permission to above file.
sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml
Create prometheus service file to start/stop/reload prometheus as daemon.
sudo vi /etc/systemd/system/prometheus.service
Copy below content and close file.
[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
Give permission to above file.
sudo systemctl daemon-reload sudo systemctl start prometheus sudo systemctl status prometheus
Hope You are able to install, Comment below if you have any doubt I will try to help ASAP.
Comments
Post a Comment