OneStopList

Gods and goddesses

Prometheus Observability Best Practices

Updated November 25, 2026

Prometheus observability best practices center on designing metrics that are actionable, cardinality-aware, and aligned with service-level objectives, while keeping the monitoring system itself simple and reliable. The core principles are: measure what matters, keep label cardinality low, use the four golden signals, and treat Prometheus as a tool for alerting and debugging rather than a general-purpose log or tracing system.

Background: What Prometheus Actually Is

Prometheus is an open-source systems monitoring and alerting toolkit originally developed at SoundCloud in 2012 and released publicly in 2015. It became a graduated project of the Cloud Native Computing Foundation (CNCF) in 2018, second only to Kubernetes. Unlike many traditional monitoring tools that use a push model, Prometheus uses a pull-based model: it scrapes HTTP endpoints (usually /metrics) at regular intervals, stores the resulting time series in a local TSDB, and evaluates alerting rules against that data.

Its data model is built around metrics (like http_requests_total) and labels (key-value pairs like method="GET" or status="500"). Each unique combination of metric name and label values forms a time series. PromQL (Prometheus Query Language) lets you query, aggregate, and compute rates, averages, and percentiles across those series. The system is designed for reliability and simplicity: it is a single binary, has no external dependencies for storage, and can run on a single machine for moderate workloads.

Core Best Practices: The Four Golden Signals

Google’s SRE book popularized the “four golden signals” for monitoring distributed systems, and they map directly onto Prometheus metrics. Your dashboards and alerts should cover:

  • Latency – the time it takes to serve a request. Use histogram metrics like http_request_duration_seconds and alert on high percentiles (e.g., p99) rather than averages, which hide outliers.
  • Traffic – the volume of requests, usually counted with a counter like http_requests_total. Rate over time is more useful than raw counts.
  • Errors – the rate of failed requests. A common pattern is a counter http_requests_total with a status label, then alert on the ratio of 5xx responses.
  • Saturation – how “full” your service is. For a queue, this is queue length; for a CPU, this is utilization. Saturation metrics often come from process_cpu_seconds_total or custom gauges.

For each service, define a small set of alerts based on these signals. A classic mistake is alerting on every metric that goes above a threshold; instead, alert on user-visible impact. For example, alert when p99 latency exceeds 500ms for 5 minutes, not when CPU hits 80% for a minute.

Label Cardinality: The #1 Pitfall

The most common Prometheus anti-pattern is high cardinality: adding labels with too many unique values, which explodes the number of time series. Each unique label value combination creates a new series, and Prometheus stores each series separately. A label like user_id or ip_address can generate millions of series, exhausting memory and disk, and slowing down queries.

Best practice is to keep cardinality low, typically under a few thousand series per metric. Use labels for dimensions you actually need to aggregate or filter on, like endpoint, method, or status. Avoid labels that are unique per request or per client. If you need to track per-user behavior, use a separate system or aggregate in your application before exporting. Also, be careful with label values that change over time, like timestamps or random IDs.

A related rule: use counters for monotonically increasing values (requests, bytes, errors) and gauges for values that go up and down (temperature, queue depth, in-flight requests). Histograms and summaries are for latency distributions; prefer histograms because they allow aggregation across instances, while summaries do not.

Naming and Instrumentation Conventions

Prometheus has a naming convention that makes metrics self-describing. Metric names should have a namespace and a subsystem, separated by underscores, e.g., http_server_requests_total. The name should end with a unit (like _seconds, _bytes, _total for counters) and a suffix describing the type if needed. For example, api_request_duration_seconds is a histogram; db_query_errors_total is a counter.

Use the _total suffix for counters, as Prometheus automatically adds it in some client libraries. For histograms, name them with _duration_seconds or _size_bytes and include the bucket boundaries in the help string. Always provide a help string that explains what the metric measures, because that text appears in the /metrics output and in UI tooltips.

Instrument your code with one of the official client libraries (Go, Java, Python, Ruby, Rust, etc.). Use the library’s built-in collectors for runtime metrics (memory, GC, goroutines) and HTTP metrics. For custom business metrics, add them at the point where the event occurs, not in a batch job. For example, increment a counter immediately after a successful or failed request, rather than periodically recomputing totals.

Choosing What to Monitor: Service-Level Objectives

Before adding metrics, decide what your users actually care about. A common framework is to define Service-Level Objectives (SLOs) – a target percentage of good events over a rolling window, like “99.9% of requests return in under 300ms.” Then instrument metrics that let you compute the error budget: the rate of bad events (latency over threshold or errors) divided by total events.

A practical approach is to monitor the “RED method” for request-driven services: Rate (requests per second), Errors (percentage of failed requests), and Duration (latency distribution). For resource-based systems, use the “USE method”: Utilization, Saturation, and Errors for each resource (CPU, memory, disk, network). Both methods align with the golden signals and give you a small, focused set of metrics.

Avoid monitoring everything “just in case.” Each metric costs storage and attention. Start with a handful of core metrics per service, then add more only when you have a specific question. Also, use recording rules to precompute expensive queries (like a 5-minute rate of errors) so dashboards load fast and alerts evaluate quickly.

Alerting and Dashboards: Rules for Actionable Alerts

Alerting in Prometheus is done with alerting rules defined in YAML. The rule evaluates a PromQL expression periodically and fires an alert if the condition holds for a specified duration (the for clause). Best practice is to use the for clause to avoid flapping – for example, alert only if the condition persists for 5 minutes. Also, use labels and annotations to add context: severity, summary, and a link to a runbook.

Alert on symptoms, not causes. For example, alert on “p99 latency > 500ms” rather than “CPU > 80%”. The former is user-facing; the latter might be normal for a batch job. Also, avoid alerting on every instance down if you have replicas; instead, alert when the number of healthy instances drops below a threshold. Use absent() to detect when a metric disappears entirely, but be careful with absent on a high-cardinality metric.

For dashboards, use Grafana (the most common companion) to build panels from PromQL. Keep dashboards focused: one dashboard per service, with sections for traffic, errors, latency, and saturation. Use rate() and histogram_quantile() for meaningful numbers, and avoid raw counters in graphs. Label your panels clearly, and include a “last 1 hour” view for quick debugging.

Common Problems and How to Avoid Them

Even with best practices, several issues recur in Prometheus deployments:

  • Scrape failures – if a target is down, you’ll see gaps in data. Use the up metric to alert on down targets, but don’t alert on every scrape failure if the service is designed to be intermittent (e.g., batch jobs).
  • Storage growth – Prometheus stores data locally and can fill disk. Use retention settings (--storage.tsdb.retention.time) and consider downsampling or using remote storage like Thanos or Cortex if you need long-term retention.
  • Query performance – complex PromQL on high-cardinality metrics can be slow. Use recording rules for expensive queries, and avoid .* regex matchers on label values.
  • Clock skew – Prometheus relies on timestamps; if the scraped target’s clock is off, data points may be misaligned. Use NTP on all nodes.
  • Over-alerting – too many alerts cause alert fatigue. Review alerts regularly and tune thresholds based on historical data.

A common misconception is that Prometheus can replace your logging system (like ELK) or tracing (like Jaeger). It cannot. Prometheus is for metrics, which are numeric time series. Logs and traces have different data shapes and retention needs. Use Prometheus for alerting and trend analysis, and keep logs for detailed debugging and traces for request flow.

Comparison with Other Monitoring Tools

Prometheus is often compared to InfluxDB, Graphite, and Datadog. InfluxDB uses a push model and a SQL-like query language; Prometheus is pull-based and uses PromQL. Graphite is older and uses a simpler data model but lacks built-in alerting. Datadog is a SaaS platform with a richer feature set but is proprietary and costs money. Prometheus is open-source, self-hosted, and has a large ecosystem (Grafana, Alertmanager, Thanos, Cortex).

For Kubernetes monitoring, Prometheus is the de facto standard, with the Prometheus Operator and kube-prometheus providing ready-made configuration. For non-Kubernetes environments, Prometheus still works well, but you need to manage service discovery manually (e.g., via file_sd_configs or DNS). Compared to newer tools like VictoriaMetrics or Mimir, Prometheus is simpler but less scalable at massive scale; those tools are compatible with PromQL and can be drop-in replacements for larger setups.

Costs and Resource Considerations

Running Prometheus has a modest cost: a single instance can handle a few million time series with a few GB of RAM and disk. The main cost is storage: each sample takes about 1-2 bytes on disk after compression, but with high cardinality, memory usage grows. For long-term retention or multi-cluster aggregation, you’ll need additional components like Thanos (which adds object storage costs) or Cortex/Mimir (which add compute and storage costs).

Alertmanager is a separate binary that handles deduplication, grouping, and routing of alerts to Slack, PagerDuty, email, etc. It adds minimal overhead. If you run Prometheus in a Kubernetes cluster, you’ll also pay for the resources of the pods, but the default configuration is lightweight (a few hundred MB). For high-availability, run two identical Prometheus instances with the same rules and use Alertmanager to deduplicate; this doubles the cost but is a common practice.

Safety and Operational Practices

While Prometheus itself is not a safety-critical system, operational safety matters for the services you monitor. Never expose the /metrics endpoint without authentication if it contains sensitive information (e.g., internal IPs or request paths). Use network policies to restrict access to the scrape port. Also, be careful with recording rules that could cause high load; test them on a staging instance first.

For alerting, ensure that Alertmanager is configured with proper routing and that on-call engineers have runbooks. Use the for clause to avoid false positives. Also, set up a separate “dead man’s switch” alert that fires if Prometheus itself is down, using a watchdog metric that is always present. This is a common best practice to ensure you know when your monitoring is broken.

Frequently Asked Questions

What is the difference between a counter and a gauge in Prometheus?

A counter is a cumulative metric that only increases (or resets to zero on restart), used for things like total requests or bytes sent. A gauge is a snapshot value that can go up and down, like current temperature or number of in-flight requests. Use counters for rates and gauges for levels.

How do I reduce high cardinality in Prometheus?

Remove labels that have many unique values, such as user IDs or request IDs. Aggregate data in your application before exporting, or use a separate system for per-user analytics. Also, avoid using labels for values that change frequently, like timestamps. Use the sum() or topk() functions to reduce the number of series in queries.

Should I use histograms or summaries for latency?

Histograms are preferred because they allow aggregating across instances (e.g., sum(rate(http_request_duration_seconds_bucket[5m])) to compute global percentiles). Summaries compute percentiles client-side and cannot be aggregated. Histograms require you to choose bucket boundaries, but they are more flexible for alerting and dashboards.

How long should I keep Prometheus data?

The default retention is 15 days, which is often enough for alerting and short-term debugging. For longer-term trend analysis or compliance, use remote storage like Thanos or Cortex, which can store data in object storage for months or years. The retention period depends on your disk space and query needs.

Can Prometheus monitor logs or traces?

No, Prometheus is designed for numeric metrics only. For logs, use a tool like Loki or ELK; for traces, use Jaeger or Zipkin. You can, however, export metrics derived from logs (e.g., error counts) into Prometheus, but the logs themselves are not stored there.

What is the best way to alert on a service being down?

Use the up metric, which is 1 if the target is scraped successfully and 0 otherwise. Alert when up == 0 for a few minutes, but consider whether the service is expected to be always up. For a multi-instance service, alert when the number of down instances exceeds a threshold, e.g., sum(up{job="myservice"}) < 2.

Related

How pages are sourced and corrected: Sources and editorial policy.