Mr.PlanB Logo

    Newsletter

    Subscribe our newsletter

    Get new infrastructure guides, comparison reports, and migration notes in your inbox.

    Infrastructure notes, guides, and new tools. Unsubscribe anytime.

    Back to Blog
    Prometheus
    Monitoring
    Grafana
    Homelab

    Prometheus Best Practices: Naming, Labels and Alerts

    November 29, 2026
    8 min read

    Prometheus best practices start with consistent metric names, bounded labels, instrumentation that matches the service, correct rate and aggregation queries, actionable alerts, and planned storage. Every item below comes from the official Prometheus documentation. In a homelab or a small production team, work through them in that order, then make sure the monitoring system can tell you when it fails itself.

    What are Prometheus metric naming and label cardinality best practices?

    The Prometheus naming guide recommends an application or domain prefix, base units and suffixes that identify the unit. Accumulating counts should end in _total, while durations should use seconds and storage quantities should use bytes.

    The naming guide gives these examples:

    http_request_duration_seconds
    node_memory_usage_bytes
    http_requests_total
    process_cpu_seconds_total
    

    The naming guide says each metric must describe a single quantity and unit. Keep queue capacity separate from queue occupancy, even when both describe the same queue. Summing or averaging across a metric's dimensions should remain meaningful.

    The instrumentation guide gives this before-and-after example for response codes, replacing separate names with a shared metric and a label:

    Before:
    http_responses_500_total
    http_responses_403_total
    
    After:
    http_responses_total{code="500"}
    http_responses_total{code="403"}
    

    The naming guide warns that every unique label combination creates a separate time series. It specifically advises against user IDs, email addresses and other unbounded values.

    The instrumentation guide recommends starting without labels when uncertain, then adding dimensions for concrete uses. During review, identify labels whose possible values keep expanding and ask whether those dimensions belong in monitoring. For a real case of what runaway labels cost, read how one team cut Prometheus memory from 60 GB to 20 GB.

    How should applications be instrumented for Prometheus?

    The Prometheus instrumentation guide recommends making instrumentation part of application code, with metric definitions near their use. For online services, it identifies request counts, errors and latency as the key measurements, with in-progress requests also useful.

    The instrumentation guide distinguishes metric types by their behavior:

    TypeUseGuidance from the Prometheus documentation
    CounterRequests, failures or bytes accumulated over eventsUse rate() to measure increases over time
    GaugeIn-progress requests, memory or temperatureValues may rise or fall; do not apply rate()
    HistogramDistributions such as request durationsObservations can be aggregated
    SummaryObservations with optional precomputed quantilesQuantiles cannot be aggregated across workers

    The instrumentation guide says to be consistent about counting requests when they start or when they end, and suggests the end, so request counts align with errors and latency. It also recommends recording total attempts alongside failures so a failure ratio can be calculated.

    For offline processing, the instrumentation guide recommends tracking progress through each stage and considering a heartbeat that travels through the system. For batch jobs, it identifies the last successful completion as the key metric.

    The same guide recommends exporting event timestamps rather than continuously updating elapsed-time gauges:

    time() - my_timestamp_metric
    

    The instrumentation guide also recommends exporting default values for series known in advance, avoiding metrics that appear only after an event occurs.

    When should I use histograms or summaries?

    The Prometheus histograms guide recommends native histograms when available. It explains that histograms retain an aggregatable representation of observations, allowing quantiles to be calculated later over different windows.

    The histograms guide says summary quantiles are calculated in the application for configured windows. Those quantiles cannot later be recalculated for another window or aggregated into a service-wide quantile across replicated workers.

    The histograms guide advises checking instrumentation library support before choosing a representation. Existing instrumentation and library support may require working with classic histograms or summaries.

    For average latency, the histograms guide provides this native histogram expression using its five-minute window:

    histogram_avg(rate(http_request_duration_seconds[5m]))
    

    For a classic histogram or summary, the same guide calculates average latency using the rate of the observation sum divided by the rate of the count, again over five minutes:

    rate(http_request_duration_seconds_sum[5m])
    /
    rate(http_request_duration_seconds_count[5m])
    

    These expressions calculate averages. The histograms guide treats quantiles as a separate calculation with different aggregation constraints.

    How can I write correct PromQL queries and recording rules?

    The Prometheus recording rules guide demonstrates calculating rates before aggregation. Built directly from its request-rate examples, this query uses the guide's five-minute window and removes the instance dimension:

    sum without (instance) (
      rate(requests_total{job="myjob"}[5m])
    )
    

    The rules guide recommends explicitly naming the labels removed with without, preserving other labels such as job. Its examples calculate each series' rate before combining the results.

    For error ratios, the rules guide says to aggregate the numerator and denominator separately, then divide. Built from its failure-ratio examples, this expression uses the guide's five-minute window:

    sum without (instance, path) (
      rate(request_failures_total{job="myjob"}[5m])
    )
    /
    sum without (instance, path) (
      rate(requests_total{job="myjob"}[5m])
    )
    

    The rules guide warns never to take the average of a ratio or the average of an average, because the result is not statistically valid. If your dashboards treat counters like gauges, our Prometheus counters article shows where that goes wrong.

    The rules guide specifies the naming form level:metric:operations. Its request-rate recording rule uses a five-minute window:

    - record: instance_path:requests:rate5m
      expr: rate(requests_total{job="myjob"}[5m])
    

    The rules guide says the level describes the output's aggregation and labels, while operations describe the calculation, newest first. For review, it also recommends checking that labels removed by aggregation disappear from the output level. A mismatch can reveal a mistake.

    What are Prometheus alerting and Alertmanager best practices?

    The Prometheus alerting guide recommends keeping alerts simple, actionable and focused on symptoms associated with user pain. Alerts should link to relevant consoles and help identify the faulty component.

    For online services, the alerting guide recommends high-level latency and user-visible error alerts. It advises against separate pages for lower-level failures already represented by a user-visible failure.

    The alerting guide also recommends allowing slack for small blips, which in practice means a for duration on the rule so a single bad scrape does not page anyone. The guide sets no fixed duration or severity scheme; pick them per service and link the runbook or console from the alert.

    For monitoring itself, the alerting guide recommends checking Prometheus, Alertmanager and related infrastructure. It favors an external blackbox check of the notification path alongside internal monitoring, helping detect failures invisible from inside the system.

    Alerts are only as good as the metrics behind them; our piece on native Prometheus instrumentation covers that side.

    How should Prometheus storage and retention be planned?

    The Prometheus storage documentation gives this rough capacity formula:

    needed_disk_space =
      retention_time_seconds
      * ingested_samples_per_second
      * bytes_per_sample
    

    The storage documentation gives an average of one to two bytes per sample. Treat the formula as an estimate: the same documentation explains that active storage and compaction require additional disk space.

    The storage documentation recommends limiting size retention to at most 80 to 85 percent of allocated disk space, leaving room for compaction. When time and size retention are both configured, whichever triggers first applies.

    For collection volume, the storage documentation says increasing the scrape interval reduces ingestion, while reducing series is likely more effective because samples within a series compress.

    For reliability, the storage documentation says local storage is not clustered or replicated, so it is limited to a single node's scalability and durability. Use a POSIX filesystem (the documentation says non-POSIX filesystems are not supported), back up with snapshots, and if you add a remote write target for long-term storage, evaluate its durability and performance carefully, as the documentation advises.

    Security hardening, redundant servers, sharding and federation are deployment questions the best-practice guides do not cover; plan them separately. To compare Prometheus with other monitoring stacks, see our Infrastructure Monitoring Ledger and Prometheus vs Zabbix.

    Checked against the Prometheus documentation on 29 November 2026.

    Frequently Asked Questions

    What are Prometheus metric naming and label cardinality best practices?

    The Prometheus naming guide recommends application prefixes, base units and descriptive suffixes. Use labels for bounded characteristics, and avoid user IDs, email addresses and other unbounded values.

    Why should rate be applied before aggregating counters?

    The Prometheus recording rules guide calculates rates for individual counter series before aggregating them. Follow that order, and aggregate failure and request rates separately before dividing.

    What are Prometheus alerting and Alertmanager best practices?

    The Prometheus alerting guide recommends actionable alerts on user-visible symptoms, links to relevant consoles, tolerance for brief blips and checks that the monitoring infrastructure works.

    How should Prometheus scrape intervals be configured?

    The Prometheus storage guide says increasing the scrape interval reduces sample ingestion. It also says reducing the number of series is likely more effective because samples within a series compress.

    How can I estimate Prometheus disk requirements?

    The Prometheus storage guide estimates disk space by multiplying retention time in seconds, ingested samples per second and bytes per sample. Leave additional room for compaction and active storage.