DEV Community

Cover image for Introduction to Prometheus Monitoring
Fife Oluwabunmi
Fife Oluwabunmi

Posted on • Edited on

3

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.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay