Metric naming conventions
- Use snake_case for metric names: lowercase words separated by underscores (for example
http_request_total). - Prefix metric names with the application or library name to indicate ownership (for example
postgres_for Postgres-related metrics). - Always include the unit in the metric name (use base units such as
seconds,bytes,meters) rather than prefixed units (milliseconds,kilobytes). - Rely on client libraries to produce type-specific suffixes. Counters should end with
_total; do not manually add_sum,_bucket, or_countfor histograms/summaries — client libraries export those.

postgres_, e.g. postgres_connection_errors. After the prefix, use descriptive words (e.g., queue_size) and append the unit where applicable (e.g., _seconds, _bytes).
Units avoid ambiguity about scale (is latency in seconds or milliseconds?). Prometheus client libraries and conventions prefer base units (seconds, bytes).

Counters must end with
_total. Do not manually add _sum, _bucket, or _count — those are created by client libraries for histogram/summary metric types.<library>_<metric_name>_<unit>_<optional_suffix>


Common suffixes and metric types
For more details on conventions, see the Prometheus best practices and instrumentation guides:
What to instrument
Decide which metrics to collect based on the nature of your application. The three common categories and recommended metrics are:1) Online serving systems
Online systems expect immediate responses (databases, web servers, APIs). Instrument the following:- Total number of requests/queries (
*_total) - Error counts (
*_errors_total) - Request latency (
*_seconds, often as histograms or summaries) - Number of in-progress requests (gauge)

2) Offline processing services
These are long-running background systems with multiple stages. Instrument per-stage and pipeline-level metrics:- Amount of work processed (counter)
- Queue/backlog size (gauge)
- Work in progress (gauge)
- Processing rate (derived from counters)
- Errors per stage

3) Batch jobs
Batch jobs run on a schedule and are often short-lived. Because Prometheus may not scrape short-lived processes, use a Pushgateway for job-level metrics that must be retained until scraped. Instrument the following for batch jobs:- Per-stage processing time (
_seconds) - Overall job runtime (
_seconds) - Success and failure counts (
myjob_success_total,myjob_failure_total) - Number of items processed (
*_processed_total) - Backlog/queued items before start

When using a Pushgateway, label pushed metrics clearly (e.g.,
job and instance identifier). Do not use the Pushgateway for ephemeral per-request metrics — it’s intended for short-lived batch jobs and service-level metrics.Practical tips
- Keep metric names consistent across services to simplify querying and alerting.
- Use labels for dimensions (e.g.,
method,status_code,region) instead of encoding dimensions into metric names. - Prefer histograms for latency distributions and counters for cumulative counts.
- Document your metrics (what they measure, units, and labels) so consumers and SREs can use them correctly.