What is Prometheus?
Prometheus is one of the most powerful and most commonly used open-source monitoring and alerting tools. Originally built at SoundCloud in 2012, now this has been adopted by many organizations and monitoring specialists. It is a time-series database that collects data (metrics) from various exporters for different purposes and datatype. It uses PromQL as its query language to extract data which could be further used to create graphical visualizations using tools like Grafana.
Today's Agenda
In this post, we will learn how to install Prometheus databases on an Ubuntu system. We will run Prometheus as a service and enable it to run on every boot (system startup) to make it production-ready.
Prerequisite
This post has been prepared for the audience who :
- Have access to a Linux-based system although the steps are almost similar in other platforms like CentOS or MacOS.
- Have a very basic understanding of Linux based systems and their commands.
- And finally, are eager to learn and try such powerful tools.
Let's get started
Step 1: Download and Install Prometheus.
Firstly, we will configure a Linux user dedicated to Prometheus:
Then we shall create directories for Prometheus configuration and library files.
Give the ownership of these directories to the user "prometheus".
This command will update your system.
Now, go to the official downloads page https://prometheus.io/download/ and get the link of latest stable version available. Copy the link and download it.
This will create one directory with the name prometheus-2.19.0-rc.0.linux-amd64
Copy these two binary files to the location /usr/local/bin/ to run these binaries.
Provide the ownership of these files to Prometheus users.
Copy required directories configuration file to /etc/prometheus.
Provide the ownership of these files as well to Prometheus users.
Now we can remove all those files that we have already copied to their destination.
Step 2: Configure Prometheus to our requirements.
Note: Prometheus has its configuration file in .yml format and requires an indent of 2 spaces.
Its configuration file is present at /etc/prometheus/. Open this file and make the necessary changes.
We will look into the configuration in detail in our post Install Node Exporter and Run as Service.
Step 3: Run Prometheus as a Service.
Now, create a systemd service file for Prometheus.
Copy-paste this configuration to the above file created and save it.
After creating a new systemd file, we need to reload systemd daemon to read this service file.
Finally, we will start the Prometheus service, check its status if it is running.
Enable it to run Prometheus on every system startup (boot).
Step 4: Start using Prometheus.
Run this command to check Prometheus is running on which port.
Open your browser and open port 9090 of your system and you will see Prometheus running on your system.
Continue your reading with us to learn how to install various exporters of Prometheus to scrape metrics and syntax for PromQL to extract information from metrics.
Comments
Post a Comment