how to Install Prometheus on Ubuntu
Posted By : Rajat Kukrety | 08-Feb-2021
It is an open-source monitoring application which orchestrates the statistical data from the service and displays the same over the graphs for analytics. It can be integrated with Grafana for good data modelling and to query flexibly.
It can also be integrated with multiple exporters to generate the required metrics. The contributors maintain the exporter with an end to end solutions.
Prerequisites
Ubuntu Machine
Nginx
Creating Service Users
We will create two new user accounts, node_exporter and prometheus.
> sudo useradd --no-create-home --shell /bin/false prometheus
> sudo useradd --no-create-home --shell /bin/false node_exportercreate the directory
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus
Change the ownership with the user.
> sudo chown prometheus:prometheus /etc/prometheus
> sudo chown prometheus:prometheus /var/lib/prometheus
Downloading Prometheus
> cd ~
> curl -LO https://github.com/prometheus/prometheus/releases/download/v2.0.0/prometheus-2.0.0.linux-amd64.tar.gz
generate checksum of the file.
> sha256sum prometheus-2.0.0.linux-amd64.tar.gz
o/p e12917b25b32980daee0e9cf879d9ec197e2893924bd1574604eb0f550034d46 prometheus-2.0.0.linux-amd64.tar.gz
untar the archive
> tar xvf prometheus-2.0.0.linux-amd64.tar.gz
Copy the directory
> sudo cp prometheus-2.0.0.linux-amd64/prometheus /usr/local/bin/
> sudo cp prometheus-2.0.0.linux-amd64/promtool /usr/local/bin/
Change the ownership
> sudo chown prometheus:prometheus /usr/local/bin/prometheus
> sudo chown prometheus:prometheus /usr/local/bin/promtool
Copy the directory
> sudo cp -r prometheus-2.0.0.linux-amd64/consoles /etc/prometheus
> sudo cp -r prometheus-2.0.0.linux-amd64/console_libraries /etc/prometheus
> sudo chown -R prometheus:prometheus /etc/prometheus/consoles
> sudo chown -R prometheus:prometheus /etc/prometheus/console_libraries
> rm -rf prometheus-2.0.0.linux-amd64.tar.gz prometheus-2.0.0.linux-amd64
Configuring Prometheus
Add the properties to promethus
> sudo nano /etc/prometheus/prometheus.yml
global:
scrape_interval: 15s
scrape_interval = collects the stats from exporter with the given time interval
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
> sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml
Running Prometheus
> sudo -u prometheus /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
To use the newly created service, reload systemd.
sudo systemctl daemon-reload
Start the promethus
> sudo systemctl start prometheus
To verify status
> sudo systemctl status prometheus
output:
prometheus.service - Prometheus
Loaded: yes
Active: active (running) since Thu 2017-07-29 11:40:40 UTC; 4s ago
Main PID: 2104 (prometheus)
Tasks: 8
Memory: 13.8M
CPU: 450ms
CGroup: /system.slice/prometheus.service
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Rajat Kukrety
Rajat is a bright Lead Java developer with sound knowledge in JAVA, Spring Other than programming his area of interest are listening music and reading novels.