Prometheus monitoring tutorial: Learn how to install, configure & use Prometheus like a pro!

Aakashdeep Sil
DevOps.dev
Published in
2 min readFeb 26, 2024

--

Welcome to the exciting world of monitoring with Prometheus! In this guide, we’ll walk you through the process of installing, configuring, and monitoring your first resource with this powerful platform. Our reference for this article is the official documentation.

Downloading and Unpacking Prometheus:

  1. Head over to the official Prometheus website and download the latest release for your platform.
  2. Extract the downloaded file to a suitable location on your system.

Understanding the Configuration:

Prometheus uses YAML files for configuration, and the download comes with a sample file prometheus.yml to get you started. We've simplified it for clarity:

global:
scrape_interval: 15s # How often to scrape targets (every 15 seconds)
evaluation_interval: 15s # How often to evaluate rules

rule_files:
# Add rule files here later

scrape_configs:
- job_name: prometheus # Job name for monitoring Prometheus itself
static_configs:
- targets: ['localhost:9090'] # Target your local Prometheus instance

This configuration defines three key sections:

  • global: Sets overall scraping and evaluation intervals.
  • rule_files: Specifies rule files for creating new metrics and alerts (not used yet).
  • scrape_configs: Defines what resources to monitor. Here, we have a single job named prometheus that scrapes our local Prometheus server on port 9090.

Starting Prometheus:

  1. Navigate to the directory containing the extracted Prometheus binary.
  2. Run the following command, specifying the configuration file:
./prometheus --config.file=prometheus.yml

Prometheus will start and expose a status page at http://localhost:9090. Give it some time to collect data.

Exploring Data with the Expression Browser:

  • Visit http://localhost:9090/graph and choose the "Table" view.
  • Enter promhttp_metric_handler_requests_total to see the total requests served.
  • Use queries like promhttp_metric_handler_requests_total{code="200"} to filter by status code.
  • Try count(promhttp_metric_handler_requests_total) to count returned time series.

For more advanced queries, refer to the expression language documentation.

Visualizing Data with the Graphing Interface:

  • Go to http://localhost:9090/graph and switch to the "Graph" tab.
  • Enter rate(promhttp_metric_handler_requests_total{code="200"}[1m]) to graph HTTP request rate with status code 200 per second.
  • Experiment with graph range and other settings.

Summary:

This guide equipped you with the basics of installing, configuring, and exploring data in Prometheus. Dive deeper by checking out the “Overview” section on the Prometheus website for further learning and exploration!

Share your thoughts in the comments below, and if you enjoyed this, consider liking this article and following me for more insights on cloud technologies.

--

--

0 Followers

Interested in microservice architecture and distributed systems