Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This pages shows the different components that need to be installed so a monitoring server have all the necessary tools to:

  • Query language to check time-series data.

  • Scrap metrics from other servers.

  • Alerting system.

  • An app to monitor time-series data, alerts.

Table of Contents
stylenone

Prometheus

Prometheus is an open-source tool that provides a query language for time-series data. It collects and stores metrics in a time-series database. To install prometheus the user must follow this steps:

Download prometheus with the following command:

Code Block
sudo wget https://github.com/prometheus/prometheus/releases/download/v2.47.0/prometheus-2.47.0.linux-amd64.tar.gz

Extract the files with the following command:

Code Block
sudo tar vxf prometheus*.tar.gz

Create a System User for Prometheus:

Code Block
sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus

Create Directories for Prometheus:

Code Block
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus

Navigate to the Prometheus Directory:

Code Block
cd prometheus*/

Move Files:

Code Block
#Move the Binary Files
sudo mv prometheus /usr/local/bin
sudo mv promtool /usr/local/bin
#Move other Files
sudo mv console* /etc/prometheus
sudo mv prometheus.yml /etc/prometheus

Set Owner:

Code Block
sudo chown prometheus:prometheus /usr/local/bin/prometheus
sudo chown prometheus:prometheus /usr/local/bin/promtool
sudo chown prometheus:prometheus /etc/prometheus
sudo chown -R prometheus:prometheus /etc/prometheus/consoles
sudo chown -R prometheus:prometheus /etc/prometheus/console_libraries
sudo chown -R prometheus:prometheus /var/lib/prometheus

Change Prometheus configuration file:

Code Block
sudo nano /etc/prometheus/prometheus.yml

Add the following initial configuration so prometheus server can start:

Code Block
global:
  scrape_interval: 15s
  evaluation_interval: 15s

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

  - job_name: 'node'
    static_configs:
      - targets: ['localhost:9100']

Create prometheus service:

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

Add the following configuration to the service file:

Code Block
[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

Reload the daemon configuration:

Code Block
sudo systemctl daemon-reload

Enable Prometheus:

Code Block
sudo systemctl enable prometheus

Start Prometheus:

Code Block
sudo systemctl start prometheus

Check that prometheus is running without issues:

Code Block
sudo systemctl status prometheus