Installing Prometheus Using Binary Packages
Prometheus is an application used for event monitoring and alerting.
Installing Prometheus
You must install Prometheus before installing the Dashboard Data Collector.
To install Prometheus:
Verify the following:
That you have sudo access to your Linux server.
That your server has access to the internet (for downloading the Prometheus binary package).
That your firewall rules are opened for accessing Prometheus Port 9090.
Navigate to the Prometheus Download page and download the prometheus-2.32.0-rc.1.linux-amd64.tar.gz package.
Do the following:
Download the source using the
curl
command:$ curl -LO url -LO https://github.com/prometheus/prometheus/releases/download/v2.22.0/prometheus-2.22.0.linux-amd64.tar.gz
Extract the file contents:
$ tar -xvf prometheus-2.22.0.linux-amd64.tar.gz
Rename the extracted folder prometheus-files:
$ mv prometheus-2.22.0.linux-amd64 prometheus-files
Create a Prometheus user:
$ sudo useradd --no-create-home --shell /bin/false prometheus
Create your required directories:
$ sudo mkdir /etc/prometheus $ sudo mkdir /var/lib/prometheus
Set the Prometheus user as the owner of your required directories:
$ sudo chown prometheus:prometheus /etc/prometheus $ sudo chown prometheus:prometheus /var/lib/prometheus
Copy the Prometheus and Promtool binary packages from the prometheus-files folder to /usr/local/bin:
$ sudo cp prometheus-files/prometheus /usr/local/bin/ $ sudo cp prometheus-files/promtool /usr/local/bin/
Change the ownership to the prometheus user:
$ sudo chown prometheus:prometheus /usr/local/bin/prometheus $ sudo chown prometheus:prometheus /usr/local/bin/promtool
Move the consoles and consoles_libraries directories from prometheus-files folder to /etc/prometheus folder:
$ sudo cp -r prometheus-files/consoles /etc/prometheus $ sudo cp -r prometheus-files/console_libraries /etc/prometheus
Change the ownership to the prometheus user:
$ sudo chown -R prometheus:prometheus /etc/prometheus/consoles $ sudo chown -R prometheus:prometheus /etc/prometheus/console_libraries
For more information on installing the Dashboard Data Collector, see Installing the Dashboard Data Collector.
Configuring Your Prometheus Settings
After installing Prometheus you must configure your Prometheus settings. You must perform all Prometheus configurations in the /etc/prometheus/prometheus.yml file.
To configure your Prometheus settings:
Create your prometheus.yml file:
$ sudo vi /etc/prometheus/prometheus.yml
Copy the contents below into your prometheus.yml file:
$ #node_exporter port : 9100 $ #nvidia_exporter port: 9445 $ #process-exporter port: 9256 $ $ global: $ scrape_interval: 10s $ $ scrape_configs: $ - job_name: 'prometheus' $ scrape_interval: 5s $ static_configs: $ - targets: $ - <prometheus server IP>:9090 $ - job_name: 'processes' $ scrape_interval: 5s $ static_configs: $ - targets: $ - <process exporters iP>:9256 $ - <another process exporters iP>:9256 $ - job_name: 'nvidia' $ scrape_interval: 5s $ static_configs: $ - targets: $ - <nvidia exporter IP>:9445 $ - <another nvidia exporter IP>:9445 $ - job_name: 'nodes' $ scrape_interval: 5s $ static_configs: $ - targets: $ - <node exporter IP>:9100 $ - <another node exporter IP>:9100
Change the ownership of the file to the prometheus user:
$ sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml
Configuring Your Prometheus Service File
After configuring your Prometheus settings you must configure your Prometheus service file.
To configure your Prometheus service file:
Create your prometheus.yml file:
$ sudo vi /etc/systemd/system/prometheus.service
Copy the contents below into your prometheus 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
Register the prometheus service by reloading the systemd service:
$ sudo systemctl daemon-reload
Start the prometheus service:
$ sudo systemctl start prometheus
Check the status of the prometheus service:
$ sudo systemctl status prometheus
If the status is
active (running)
, you have configured your Prometheus service file correctly.
Accessing the Prometheus User Interface
After configuring your Prometheus service file, you can access the Prometheus user interface.
You can access the Prometheus user interface by running the following command:
$ http://<prometheus-ip>:9090/graph
Once the Prometheus user interface is displayed, go to the Query tab and query metrics.