Prometheus is an open-source monitoring system developed by SoundCloud. Development on Prometheus started back in 2012 when SoundCloud felt that the existing monitoring systems were proving insufficient for their needs. It uses a time-series database just like Druid, InfluxDB, Graphite.
However, Prometheus is able to work on a multi-dimensional data model, uses a powerful query to language to leverage this data model properly. Uses pull method over HTTP to record real-time metrics, this helps admins to easily fine-tune the capabilities to their needs which in turn produces more accurate reports.
Prometheus has a browser-based tool called PromDash to build and view dashboards that use SQL backend. The Data model stores all data as time series: streams of timestamped values belonging to the same metric and the same set of labeled dimensions.
Another main attraction of Prometheus is that it uses single server nodes that are autonomous. How many times have you just given up trying to configure a distributed system cluster? Well, that won’t be the case this time.
To follow this tutorial, you will need:
- sudo access to your system.
- Working internet connection as we will download the Prometheus Linux Binary.
Setup Prometheus Binaries
Step 1: Updating repos
As always, our first step will be to update the yum package repositories.
yum update -y
Step 2: Creating user and directories
Let’s create a Prometheus user, required directories, and make prometheus user as the owner of those directories.
useradd –no-create-home –shell /bin/false prometheus
chown prometheus:prometheus /etc/prometheus
chown prometheus:prometheus /var/lib/prometheus
Step 3: Getting Prometheus
Go to the official Prometheus downloads page and get the download link for Linux binary by right-clicking the binary and clicking on Copy Link next.
Step 4: Downloading and Installing Prometheus
Download the source using wget, untar it, and rename the extracted folder to prometheus-files.
tar -xvf prometheus-2.20.0-rc.1.linux-amd64.tar.gz
mv prometheus-2.20.0-rc.1.linux-amd64 prometheus-files
Step 5: Copying prometheus and promtool
You will have to copy prometheus and promtool binary from prometheus-files folder to /usr/local/bin.
cp prometheus-files/prometheus /usr/local/bin/
cp prometheus-files/promtool /usr/local/bin/
Step 6: Changing ownership
Change the ownership to prometheus user.
chown prometheus:prometheus /usr/local/bin/prometheus
chown prometheus:prometheus /usr/local/bin/promtool
Step 7: Moving consoles and libraries
Move the consoles and console_libraries directories from prometheus-files to /etc/prometheus folder and change the ownership to prometheus user.
cp -r prometheus-files/consoles /etc/prometheus
cp -r prometheus-files/console_libraries /etc/prometheus
chown -R prometheus:prometheus /etc/prometheus/consoles
chown -R prometheus:prometheus /etc/prometheus/console_libraries
Setup Prometheus Configuration
prometheus.yml holds all the prometheus configurations. The file be present in /etc/prometheus/prometheus.yml file.
Step 1: Create prometheus.yml file.
Create the prometheus.yml file.
Step 2: Edit prometheus.yml file.
Open the file using vim or any file editor of your liking and copy the following contents to the prometheus.yml file.
– job_name: ‘prometheus’
– targets: [‘localhost:9090’]
Step 3: Ownership change for prometheus.yml file.
Change the ownership of the file to prometheus user.
chown prometheus:prometheus /etc/prometheus/prometheus.yml
Setup Prometheus Service File
Step 1: Create a prometheus service file.
Step 2: Edit prometheus.service
Copy the following content to the file.
–config.file /etc/prometheus/prometheus.yml \
–storage.tsdb.path /var/lib/prometheus/ \
Step 3: Reload the systemd
Reload the systemd service to register the prometheus service and start the prometheus service.
systemctl start prometheus
Check the prometheus service status using the following command.
systemctl status prometheus
The status should show the active state as shown below.
Access Prometheus Web UI
Now you will be able to access the prometheus UI on 9090 port of the prometheus server.
You should be able to see the following UI as shown below.
Currently, we have only configured Prometheus. We need to register a target to actually some metrics from the system.
In order to do this please follow along to the next tutorial: Prometheus Node Exporter Guide