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.
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:
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:
sudo tar vxf prometheus*.tar.gz
Create a System User for Prometheus:
sudo groupadd --system prometheus sudo useradd -s /sbin/nologin --system -g prometheus prometheus
Create Directories for Prometheus:
sudo mkdir /etc/prometheus sudo mkdir /var/lib/prometheus
Navigate to the Prometheus Directory:
cd prometheus*/
Move Files:
#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:
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:
sudo nano /etc/prometheus/prometheus.yml
Add the following initial configuration so prometheus server can start:
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:
sudo nano /etc/systemd/system/prometheus.service
Add the following configuration to the service 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
Reload the daemon configuration:
sudo systemctl daemon-reload
Enable Prometheus:
sudo systemctl enable prometheus
Start Prometheus:
sudo systemctl start prometheus
Check that prometheus is running without issues:
sudo systemctl status prometheus
Node Exporter
Node exporter is an agent that extracts system metrics and expose that information so prometheus can read those metrics.
Download node_exporter compressed pack:
wget https://github.com/prometheus/node_exporter/releases/download/v*/node_exporter-*.*-amd64.tar.gz
Extract the binary:
tar xvfz node_exporter-*.*-amd64.tar.gz
Access the directory of the extracted file:
cd node_exporter-*.*-amd64
Change folder execution permissions:
chmod +x node_exporter
Run node_exporter binary
./node_exporter