DEV Community

Cover image for Introduction to Prometheus Monitoring
Fife Oluwabunmi
Fife Oluwabunmi

Posted on • Updated on

Introduction to Prometheus Monitoring

A lot of newbies and "semi-newbies" in DevOps and SWE dodge and run from Monitoring and Prometheus because it seems really difficult to crack or they feel like skills that you'd only need at a senior level...

Guess what? I was once there but after psyching myself up for almost one week, I finally started working with Prometheus and I'm here to make learning about Monitoring and Prometheus a whooollee lot simpler. So relax as we dive into Prometheus' World! :D

Prometheus

In a nutshell, Prometheus is an open-source tool that allows you to keep tabs on different types of resources including applications running either locally or on some server, and even servers themselves.
With Prometheus, you keep track of various data (metrics) related to your app or server.

It's also pretty easy to install and set up- just enough to get you started with it, so let's get right into it!

Installing Prometheus

Prometheus is broken into different components and you can download the binary files of these components individually- this way, you only have to get what you need!

If you head over to Prometheus download page, you'll be able to find officially maintained components. This article won't cover them all, we'd only be looking at prometheus itself and node_exporter.

Choose your binary file according to your distribution and download it. I'm using a Mac, so I'll select the darwin distro.
prometheus binary files

The next thing to do is to unzip the file. If you're on a linux/mac machine, run the following command:

tar xvfz prometheus-2.54.0.darwin-amd64.tar.gz
cd prometheus-2.54.0.darwin-amd64
Enter fullscreen mode Exit fullscreen mode

Now you should be in the prometheus directory. You can run ls and you should see something like this:

prometheus directory

Now we're going to edit the prometheus.yml file. Get rid of the default configurations and make sure your file looks like this.

global:
  scrape_interval:     15s

scrape_configs:
  - job_name: 'prometheus'
    scrape_interval: 5s

    static_configs:
      - targets: ['localhost:9090']
Enter fullscreen mode Exit fullscreen mode

Here, we're asking Prometheus to monitor localhost:9090 which is the port prometheus runs on. We're doing this just so you can get a feel of how Prometheus works. We'll set up more exciting stuff soon.

Now we're going to see Prometheus in action! Run the following command:

./prometheus --config.file=prometheus.yml
Enter fullscreen mode Exit fullscreen mode

Ensure you're in the prometheus directory before running the command. We're calling Prometheus and asking it to use the file we just configured as the config file.

Once it starts running, we can go over to localhost:9090 to view the UI Prometheus provides for us. We'll go into a bit more detail later but for now, just know that this is where you can run different queries to get information about the service you're running!

Note: If you open localhost:9090/metrics, you'll see the raw format of our service's metrics.

Prometheus raw metrics

That's all for now. In the next one, we'll see how we can use Prometheus and Grafana to monitor a Django application!

I hope you found this guide helpful.

Top comments (0)