Skip to content
Blog

How Prometheus Monitoring Works: Scrape Config, PromQL and Alert Rules

How Prometheus Monitoring Works: Scrape Config, PromQL and Alert Rules

Prometheus collects metrics from servers, applications and containers by scraping them. It is the de facto standard for monitoring cloud-native environments and integrates natively with Kubernetes. This page shows four things that were tested rather than described: the scrape file, three PromQL queries, an alert rule and the version criteria.

Every block shows real output: everything ran in a lab with Prometheus 3.13.2, the LTS line, on August 28, 2026. On that date the project repository had 65,867 stars. Major release 3 shipped in November 2024 and the current line is already 3.14.

 

What Is Prometheus?

Prometheus is an open source monitoring and alerting system created at SoundCloud in 2012 and donated to the CNCF (Cloud Native Computing Foundation) in 2016. It collects metrics through pull (scraping), stores them in a time series database (TSDB) and exposes a query language called PromQL for analysis and alerting.

Unlike push-based tools (such as StatsD and InfluxDB with Telegraf), Prometheus actively fetches metrics from the endpoints that applications and exporters expose. This simplifies service discovery and keeps control of collection on the server.

Prometheus integrates natively with the observability ecosystem: metrics (Prometheus), logs (Loki) and traces (OpenTelemetry or Jaeger) form the complete triad when combined with Grafana.

 

Prometheus Architecture

Prometheus architecture is deliberately simple and made of modular components.

Prometheus Server

The core of the system. It scrapes targets, stores metrics in the local TSDB and serves the HTTP API for PromQL queries. In high availability setups, multiple Prometheus servers run in parallel with the same configuration. There is no native replication: Thanos or Cortex cover that as a distributed long-term storage layer.

Exporters

Exporters are agents that expose metrics from systems with no native Prometheus support. Each exporter answers a different question about the environment, so coverage drives the choice.

 

Exporter What it collects When to use it
node_exporter CPU, memory, disk, network and host load On every server in the fleet: it is the infrastructure baseline
blackbox_exporter HTTP, HTTPS, TCP, ICMP and DNS probes from the outside When the question is whether the service answers outside callers, beyond whether the process is alive
mysqld_exporter
postgres_exporter
Active connections, locks, replication lag, cache hit ratio and slow queries Databases where saturation hits the connection pool before the CPU
cAdvisor CPU, memory and I/O per container Hosts running Docker or Kubernetes, where host metrics cannot show who consumed what
Client library Queue depth, per-route latency, error rate and business metrics When the metric that matters does not exist outside the application code

 

In this page's lab, node_exporter alone published 776 series from a single host. Across a fleet of 100 servers that comes to roughly 77,000 series for infrastructure only, before any application metric. That is why TSDB capacity planning starts with the host exporter and the instrumented code comes second.

For your own applications, client libraries are available in Go, Java, Python and other languages.

Pushgateway

A component that lets batch or short-lived jobs push metrics before they exit. The Pushgateway acts as an intermediary: jobs push their metrics and Prometheus scrapes the Pushgateway as usual.

Alertmanager

The Alertmanager receives alerts fired by Prometheus and handles routing, deduplication, grouping and silencing. It sends notifications to Slack, PagerDuty, OpsGenie, email and other configurable channels. Separating alert generation (Prometheus) from notification (Alertmanager) puts the decision of who gets woken up in one place. You can manage alert fatigue without touching a single rule.

 

Prometheus 3: What Changed and Which Version to Run in Production

The Prometheus 3 line brought changes that matter for production environments. Two of them are often misunderstood when planning the upgrade.

Native histograms represent the distribution without fixed buckets. This reduces the number of series per histogram and improves percentile accuracy. They are not automatic, though. The official specification marks the feature as stable only from v3.8.0. Even there, collection stays off until the scrape config includes scrape_native_histograms: true.




terminal
# The effective server configuration, read from the status API.
curl -s localhost:9090/api/v1/status/config \
  | grep -o 'scrape_native_histograms: [a-z]*' | uniq -c

      4 scrape_native_histograms: false
#     the global default and the three jobs, all off

Upgrading to the 3 line without touching that field therefore changes nothing. The server keeps storing the classic histogram, with the same buckets and the same series count as before.

OpenTelemetry compatibility got deeper. Prometheus 3.x accepts metrics in OTLP format through the OTLP receiver, which consolidates it as a metrics backend for OpenTelemetry pipelines.

To decide which version to run, read the project's support policy. A new minor release ships every six weeks and stops receiving fixes when the next one arrives. LTS versions, on the other hand, receive bug and security fixes for one year.

Version 3.5 ended support on July 31, 2026 and 3.13, released on July 1, 2026, is supported until July 31, 2027. Anyone running 3.5 in production today is outside the fix window.

 

PromQL: The Prometheus Query Language

PromQL (Prometheus Query Language) is the language used to query and aggregate collected metrics. It works on time series and supports math functions, aggregations and label selection.

The Three Questions to Answer First

Three questions cover most day-to-day diagnosis. Is the target up? How much work is it receiving? How is latency distributed? Below are the queries that answer each one, run against the lab, with the output the server returned.




query.promql
# 1. Are the targets answering the scrape?
up
#    -> 4 series, all at 1: prometheus (localhost:9090),
#       node (node-exporter:9100), aplicacao (app-pedidos:8000)
#       and aplicacao (app-checkout:8000)

# 2. How many requests per second does each service handle?
sum by (service) (rate(http_requests_total[5m]))
#    -> {service="pedidos"}   4.7545527913
#    -> {service="checkout"}  2.3755136127

# 3. What are the median and tail latencies?
histogram_quantile(0.50,
  sum by (le, service) (rate(http_request_duration_seconds_bucket[5m])))
#    -> {service="pedidos"}   0.0474571734     47 ms
#    -> {service="checkout"}  0.0704954954     70 ms

histogram_quantile(0.99,
  sum by (le, service) (rate(http_request_duration_seconds_bucket[5m])))
#    -> {service="pedidos"}   0.7177083333    718 ms
#    -> {service="checkout"}  0.8429166666    843 ms

The third question is the one that changes decisions. The median for the orders service was 47 ms while p99 was 718 ms, fifteen times higher. A latency average would hide this behavior completely. That is why latency alert thresholds should be defined on percentiles and never on averages.

Labels and Selectors

Labels are the dimension that gives the data model its granularity. Each metric can have multiple labels (job, instance, environment, region) that enable fine-grained filtering and aggregation. The cost shows up in the multiplication: every distinct value of every label creates a new series. A label holding a user ID or the full request URL leads to a cardinality explosion within a few hours.

 

Prometheus Configuration and Scrape Config

Prometheus is configured through a YAML file (prometheus.yml). The file below is the one running in this page's lab. It has three jobs, one for each kind of target, with the service label set in the scrape config.




prometheus.yml
global:
  scrape_interval: 15s
  evaluation_interval: 15s
  external_labels:
    ambiente: laboratorio

rule_files:
  - /etc/prometheus/regras-de-alerta.yml

alerting:
  alertmanagers:
    - static_configs:
        - targets: ["alertmanager:9093"]

scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ["localhost:9090"]

  - job_name: node
    static_configs:
      - targets: ["node-exporter:9100"]
        labels:
          ambiente: laboratorio

  - job_name: aplicacao
    metrics_path: /metrics
    static_configs:
      - targets: ["app-pedidos:8000"]
        labels:
          service: pedidos
      - targets: ["app-checkout:8000"]
        labels:
          service: checkout

Setting the label in static_configs has a practical reason. The same binary can start up as pedidos or as checkout with no recompiling. The person operating collection decides the service name and the code author never has to touch it.

On Kubernetes, Prometheus uses native service discovery to find pods and services automatically through annotations. The kube-prometheus-stack (a community-maintained Helm chart) is the recommended way to install it on K8s. It installs Prometheus, Alertmanager, Grafana and a set of dashboards and alerts preconfigured for Kubernetes.

 

Prometheus Alerting Rules

Alerts are defined in separate rule files loaded by the Prometheus server. The rule below is the one running in the lab. It compares each service's 5xx error rate against a 1% error budget.




regras-de-alerta.yml
groups:
  - name: nivel-de-servico
    rules:
      - alert: TaxaDeErroAcimaDoOrcamento
        expr: |
          sum by (service) (rate(http_requests_total{status=~"5.."}[5m]))
            / sum by (service) (rate(http_requests_total[5m])) > 0.01
        for: 5m
        labels:
          severidade: alta
        annotations:
          summary: "Erro 5xx em {{ $labels.service }} acima de 1% há 5 minutos"

The for: 5m parameter is what separates an alert from noise. In the August 28, 2026 test the condition became true at 05:11:53 UTC. The alert only switched to firing at 05:16:53, exactly five minutes later. In between it sits in pending: it shows up in the console but notifies nobody.

The screen below shows the rule already firing, with the rate measured at the moment of the trigger.

 
Prometheus 3.13.2 alerts page with the TaxaDeErroAcimaDoOrcamento rule in the Firing state, showing the PromQL expression, the 5-minute for parameter and the measured rate of 11.57% against the 1% threshold

 

The curve that produced this alert appears in Prometheus's own graph. The checkout service went from 0.4% to 12.5% errors while the orders service stayed below 0.5% throughout the episode.

 
Prometheus graph of the 5xx error rate query split by service: the checkout curve climbs to 12.5% while the orders curve stays below 0.5%

 

Fired alerts go to Alertmanager, which decides routing and suppression according to the configured rules. This structure is the foundation for reducing alert fatigue in large-scale operations.

 

Prometheus and the SRE Four Golden Signals

Prometheus is the reference tool for implementing the SRE four golden signals (latency, traffic, errors and saturation) in cloud-native environments. Each signal maps to a set of metrics and PromQL queries that can be standardized in Grafana dashboards and used as the basis for defining SLOs and calculating error budgets.

For teams that adopt SRE, Prometheus is the measuring instrument that turns SLOs into concrete, actionable data.

 

Long-Term Storage: Thanos and Cortex

Prometheus stores data locally (15 days by default, configurable). For long retention and high availability, the most widely adopted projects are Thanos and Cortex/Mimir.

Thanos adds an object storage layer (S3, GCS, Azure Blob) on top of an existing Prometheus, with compaction and deduplication. Grafana Mimir (the successor to Cortex) is a fully horizontally scalable solution for environments that need high ingestion and multi-tenancy. Both are recommended for production environments that need more than 30 days of history.

 

Monitoring & Observability

Already running Prometheus? Take it further.

KeepMonitor works with the metrics you already collect, and our team can operate the whole stack for you.

Explore KeepMonitor →

 

Conclusion

Prometheus is the central pillar of cloud-native monitoring in 2026. Its pull architecture, label model, PromQL and native integration with Kubernetes and OpenTelemetry make it the natural choice for teams that adopt SRE, DevOps and observability as operating practices.

With the 3 line consolidated, native histograms stable since 3.8 and OTLP support, the ecosystem has reached a level that needs no custom workarounds. If you want to implement a monitoring strategy based on Prometheus with Grafana, calibrated alerts and long-term storage, talk to our experts.

 

Frequently Asked Questions

What is Prometheus and what is it used for?
Prometheus is an open source monitoring and alerting system that collects metrics through scraping (pull), stores them in a time series database and exposes PromQL for queries and alerts. It is the market standard for monitoring Kubernetes and cloud-native environments.
What is the difference between Prometheus and Grafana?
Prometheus collects and stores metrics and fires alerts. Grafana is a visualization platform that connects to Prometheus as a data source to build dashboards. They are complementary: Prometheus is the metrics backend and Grafana is the visualization layer.
What is PromQL?
PromQL (Prometheus Query Language) is the Prometheus query language for time series. It lets you calculate rates (rate()), percentiles (histogram_quantile()), aggregations (sum by()) and comparisons between metrics. It is used in Grafana dashboards and in alert definitions.
Which Prometheus version should I use in production?
LTS versions receive bug and security fixes for one year, while a regular minor release stops receiving fixes as soon as the next one ships, every six weeks. As of August 2026 the supported LTS is 3.13, released on July 1, 2026 and maintained until July 31, 2027. The previous LTS, 3.5, ended support on July 31, 2026.
How do I set up long-term storage for Prometheus?
Prometheus stores data locally by default (15 days). For long retention, the main options are Thanos (S3/GCS storage on top of an existing Prometheus) and Grafana Mimir (a horizontally scalable solution for high ingestion and multi-tenancy).
Pedro Tebaldi

I have been at OpServices since 2011, where I am Marketing Manager and Product Manager of KeepGreen, an IT incident management platform that cleans up alerts, points to the root cause with AI, writes the post-mortem and analyzes cloud costs. I also lead the company's artificial intelligence governance projects. I have written on this blog since 2013, with more than 550 articles published on monitoring, observability, SRE and ITSM. LinkedIn

plugins premium WordPress