What to instrument in services, offline processing and batch jobs

A checklist for deciding which metrics each system type should expose to Prometheus, so alerts and dashboards answer real operational questions.

On this page

What to instrument in Prometheus before you write any code

A team that has Prometheus running but finds its dashboards and alerts do not answer operational questions usually skipped the first step. The fix starts by classifying each system as an online-serving system, an offline processing system or a batch job, and only then choosing the key metrics for that class. The instrumentation best practices split services this way because each category fails differently and needs different signals. Online serving systems are judged on request rate, errors and latency. Offline processing systems are judged on how much work is queued and how long items wait before they are processed. Batch jobs are judged on whether they ran, how long they took and when they last succeeded.

Prometheus is an open-source monitoring and alerting toolkit licensed under Apache-2.0. It pulls metrics over HTTP from targets found through service discovery or static configuration, and it is queried with PromQL. Teams need this checklist before they add client libraries to code, because the metric names, types and labels they choose at that point are hard to change later without breaking dashboards and alert rules. Ask the team to write down, for each service, which category it belongs to and the three or four questions an on-call engineer must answer during an incident. Those questions determine the metrics to expose.

Prometheus values reliability over precision, as its overview documentation states, and it is not the right tool where every event must be counted exactly, such as per-request billing. Treat the metrics in this checklist as operational signals for monitoring and alerting. If the business needs exact counts for invoicing or audit, record those events in a system built for that purpose and confirm with the owners of that data how it will be reconciled with Prometheus figures.

Which metrics online-serving systems need: request rate, errors and latency

Online-serving systems answer requests from users or other services, so their instrumentation starts with how much work arrives, how much of it fails and how long it takes. The cards below cover those three signals and the label choices that keep them affordable to store and query.

Request rate as a counter

Count every request the service handles with a _total counter, then let PromQL derive the rate over a window. A counter survives scrape gaps and restarts better than a gauge of current throughput, and it gives you the traffic baseline that every error and latency ratio depends on. Check that the counter increments once per request, not once per retry or per downstream call, so the rate reflects user demand.

Instrumentation best practices

Errors as a labeled ratio

Record failed requests in the same metric family as all requests, separated by a status or outcome label, so errors can be divided by total traffic. Decide up front which responses count as errors, for example server-side 5xx responses but not client mistakes such as 404. Confirm this definition with the service owners, because an alert built on the wrong definition pages on the wrong problems.

Latency as a histogram

Measure request duration in a histogram so you can compute percentiles across all instances with histogram_quantile. A histogram of durations also shows whether a slow tail is growing even when the average looks healthy. Choose bucket boundaries around your latency objective before the service ships, since buckets cannot be added retroactively without new data. The histogram versus summary trade-offs are covered in the sibling topic on histograms and summaries.

Bounded route and status labels

Label requests by a route template such as /orders/{id}, never by the raw URL, because every distinct user ID or product ID creates a new time series. Keep the set of status codes and routes small and known in advance. Ask each team for the full list of label values their service can emit, and review any label whose values come from user input, since unbounded labels are the usual cause of memory and storage growth.

Concurrency and in-flight requests

A gauge of requests currently in progress shows saturation that rate and latency can miss, such as a thread pool that is full while the request rate stays flat. Keep this gauge at the service level rather than per endpoint so its cardinality stays constant. Pair it with the latency histogram when you investigate slowdowns, because rising in-flight counts with stable throughput usually points to queuing downstream.

Naming and label standards first

Apply one naming standard across all services before the first dashboard is built, so request, error and latency metrics share names, units and label keys. Teams that pick their own names make cross-service queries and shared alert rules harder to write. The sibling topic on metric and label naming conventions sets out the prefixes, base units and suffixes to follow, and reviewing new metrics before they ship keeps the standard in place.

How offline processing and batch jobs differ from request-serving systems

Online-serving systems answer requests from users or other services, so their health shows up in traffic. Prometheus guidance for these systems centers on request rate, errors and latency, measured where requests arrive. When a service stops, slows or starts failing, the request counters and latency histograms move, and alert rules can page on that change. The same signals also let you compare one instance or version against another.

  • Request rate: a counter of requests handled, which shows load and reveals sudden drops in traffic.
  • Error rate: a counter of failed requests, split by a bounded set of outcome labels.
  • Latency: a distribution of request durations, usually recorded as a histogram so percentiles can be aggregated.
  • In-progress requests: a gauge that shows concurrency and saturation at the moment of a scrape.
  • Dependency calls: the same rate, error and latency signals for calls the service makes to databases and other services.

Before you rely on these signals, confirm with your engineering leads which endpoints and dependencies each service exposes, and whether the metrics are recorded at the point where users feel the delay.

How to build an instrumentation inventory for your estate

This sequence turns a vague wish to monitor everything into a reviewed list of systems, each with a type, key metrics, agreed names and labels, and checks that prove the series reach Prometheus and feed alert rules.

  1. List every system and job in scope

    Compile one register of online services, queues and pipelines, offline processors, cron and batch jobs, and infrastructure components, with an owner named for each. Include systems that do not yet expose metrics, because the gaps are the point of the exercise. Done means every entry has an owner and a current state, such as already instrumented, partly instrumented, or not instrumented. Confirm the list with the teams that operate each system rather than relying on a CMDB export alone.

  2. Classify each system by type

    Assign each entry to one of the categories the Prometheus instrumentation guidance uses: online-serving systems, offline processing, or batch jobs. A system that both serves requests and processes a queue may belong to two categories, and that is fine if you record both. Done means every row has one or more types and any mixed cases are noted for the reviewer. The type decides which key metrics you will ask the owner to expose in the next step.

  3. Choose the key metrics for each type

    For online-serving systems, record request rate, errors and latency. For offline processing, record queue depth or backlog, processing delay, and throughput. For batch jobs, record last successful completion time and the outcome of the most recent run. Write these as a short table per type with the metric purpose beside each name. Done means a reviewer from the platform team can read the table and understand what each metric answers without asking the owner.

  4. Agree names and labels with owners

    Walk each owner through the proposed metric names and label sets before any code changes. Check that names follow your naming standard, that counters carry the expected suffix, and that every label value comes from a small, known set such as route template, status class or queue name, not user IDs, raw URLs or request identifiers. Record the agreed list in the register. Done means each owner signs off the names and labels, and no label is marked as unbounded.

  5. Add instrumentation and expose it

    Owners add metrics with the client library chosen for their language, and expose them on an HTTP endpoint that Prometheus can scrape. For batch jobs, confirm the chosen pattern for reporting results, since short-lived jobs need a different approach from long-running processes. Check each target by requesting its metrics endpoint directly and confirming the agreed names appear with plausible values. Done means the raw endpoint output matches the register for every system in scope.

  6. Verify series appear in Prometheus

    Once a scrape job is configured, query each agreed metric in the Prometheus expression browser or through the HTTP API and confirm it returns series for every expected target. Compare the series count per metric with the number of label combinations you planned, and investigate any metric whose series count grows faster than expected. Check that the target status page shows the endpoint as up. Done means every planned metric returns data and the label counts match the agreed design.

  7. Confirm alert rules reference the metrics

    Write or update alert rules so each key metric drives at least one rule that reflects a real problem for its system type, such as error ratio, backlog growth, or a batch job that has not succeeded within its expected window. Load the rules, then test that each one evaluates without errors and that the metrics it names exist in the store. Done means every key metric is referenced by a loaded rule, and the register records the rule name next to each metric.

How each system type maps to its key metrics

The diagram starts with the system you are instrumenting and asks one question first: does it serve requests online, process queued work offline, or run as a scheduled batch job. Online serving systems get request rate, errors and latency. Offline processing systems get queue depth and processing delay, measured from when work arrives to when it finishes. Batch jobs get the same kind of duration and error signals, plus a last success timestamp, because a job that never starts produces no failure metric at all. Check that every branch ends in a metric your alert rules can use.

Each system type leads to its own key metric set, with batch jobs adding a last-success check.

Questions teams ask before instrumenting services and jobs

How many metrics should one service expose?

There is no fixed number. The right count follows from the questions you need to answer about the service, not from a target you set in advance. Start with the key metrics for its system type: request rate, errors and latency for an online service, queue and processing delay for an offline system, and last success time for a batch job. Add metrics only when a specific alert, dashboard or investigation needs them. Each extra metric and label combination adds series that Prometheus must store and query, so review the set before release. Ask your team to name the alert or question each metric supports. If a metric serves neither, leave it out.

Should we instrument third-party systems we do not own?

Instrument what you can observe from your side first, and use an exporter or a probe for systems you cannot change. You can rarely add client code to a vendor SaaS product, so measure its behavior from your own services: call latency, error responses and timeouts at the point where your code calls it. For self-hosted open-source systems you run, an exporter is usually the cleaner path, and the Prometheus instrumentation guidance covers how to decide between direct instrumentation and an exporter. Confirm with the vendor what metrics they already expose and what access their documentation permits before you build anything. Also confirm the scrape endpoints are reachable from your Prometheus servers and protected by your network rules.

What should monitoring do when a batch job fails and never reports?

A job that never runs produces no metric at all, so alerting on the job's own error counter will miss it. Monitor the last successful completion time as a timestamp and alert when that time is older than the job's expected interval plus a tolerance you set. This catches jobs that crash, hang, are never scheduled or fail before their error handling runs. Pair it with a duration metric and an error count for jobs that do run. Decide how the job reports before you write the alert: a direct push, a textfile collector on the host, or an exporter that reads job state. Test the alert by stopping a job on purpose in a non-production environment and confirming it fires.

How do we handle high-cardinality labels without losing useful detail?

Keep labels to bounded sets of values, such as HTTP method, route template, status class or queue name, and never use unbounded values like user IDs, email addresses, request IDs or full URLs with query strings. Each unique combination of label values creates a separate time series, so unbounded labels grow memory and storage use quickly. When you need per-customer or per-request detail, use logs or traces, which are built for that data, and keep metrics aggregated. The Prometheus storage and operations guidance describes how series count affects the server. Before release, check the label values each metric can produce and set a review step for new labels. Ask your team which labels are bounded by design and which depend on user input.

Should we use histograms for latency?

For latency that you need to aggregate across instances or compare against an SLO, histograms are usually the right starting point, but the choice depends on the query and cost you need. Classic histograms let you calculate quantiles across many instances with PromQL, at the cost of one series per bucket. Summaries compute quantiles inside the application and cannot be combined across instances in the same way. Choose bucket boundaries around the latency targets you care about, and review them with the team that owns the SLO. The detailed trade-offs are covered in the sibling topic on histograms and summaries, so use this question as the starting point, then confirm the design with a sample query against real traffic.

Who owns the metric contract once services are in production?

The owning service team should own its metric names, labels and meaning, and a shared review should own the standards they follow. Renaming a metric or changing a label breaks dashboards, recording rules and alerts that other teams depend on, so treat metric names as an interface. Record each exposed metric with its owner, purpose and linked alerts or dashboards. Assign a platform or observability owner to approve new conventions and to retire metrics that nobody uses. If you engage a partner, agree in writing who maintains the metric catalog after handover and how changes go through review. Ask whether your organization already has a naming standard before writing new one.

How do we test metrics before they reach production?

Test metrics in three places: the code that records them, the endpoint that exposes them, and the queries and alerts that use them. Unit tests can confirm a counter increments on the right path and that labels take only the expected values. Run the service locally or in a staging environment and scrape its endpoint with your Prometheus configuration to confirm names, types and units appear as intended. The Prometheus tooling includes promtool, which you can use to check metric files and rules before deployment. Then run each alert against a deliberately failing test case, such as a stopped job or a forced error rate, and confirm it fires and resolves. Ask your team to add these checks to the release pipeline so they run on every change.

Which instrumentation approach fits each system type

This table compares request-serving services, queue and pipeline workers, and batch or cron jobs across the metrics to expose, how Prometheus collects them, the main risk, and what to confirm. Read each row as the starting point for your own review, then check the cells against how your jobs actually run.

System typeKey metrics to exposeCollection methodMain riskWhat to confirm
Request-serving servicesRequest rate, error count and latency distribution per endpointScrape endpoint on the running serviceUnbounded label values such as user IDs inflate series countWhich endpoints and routes are exposed and how labels are normalized
Queue and pipeline workersItems received, items processed, errors, queue depth and time from enqueue to completionScrape endpoint on each worker, plus queue metrics from the broker or exporterDelay is invisible if only worker throughput is countedWhere enqueue timestamps come from and whether the queue exposes depth
Batch and cron jobsLast successful completion timestamp, duration and failure countTextfile collector for machine-level jobs, or a Pushgateway for short-lived jobsStale values keep looking healthy after a job stops runningWhether the job host runs a textfile collector and who cleans up stale series
Scheduled data pipelinesRun status, rows or records processed, and lag behind the expected scheduleScrape endpoint on the orchestrator or a custom exporterMissed runs produce no sample at all, so absence goes unnoticedWhich alert fires when a scheduled run does not report by its expected time
Long-running background daemonsHeartbeat, loop iterations, backlog size and failure countersScrape endpoint on the daemon processA hung process can still answer scrapes while doing no workWhether the heartbeat reflects real progress rather than just process uptime
Third-party or closed systemsAvailability and response checks, plus any native exporter metricsExporter or blackbox-style probe scraped by PrometheusExporter access can be abused if targets come from URL parametersWhether a vendor exporter exists and who maintains it

Security and exposure risks in instrumented endpoints

Every instrumented service adds an HTTP endpoint that someone can reach. The risks below are what that endpoint can reveal, how Prometheus authenticates and encrypts access, which admin functions stay off by default, and how exporters can be turned into request relays. Check each one before the metrics endpoint goes into production.

Metrics that reveal internal detail

A metrics page often lists request paths, route names, tenant or customer identifiers when they appear as label values, and hostnames or service names that show how the estate is wired. Anyone who can read that page learns the internal topology without touching the application. Review every label value before it ships, and treat the metrics endpoint as a disclosure surface, not a harmless diagnostic. Confirm which labels carry customer or tenant identifiers and remove or hash them where they are not needed for alerting.

Authentication on scrape endpoints

Prometheus can authenticate to targets with TLS and client certificates, or with HTTP basic authentication. The security model sets TLS 1.2 as the minimum for TLS. Basic authentication without TLS sends credentials in cleartext, so it should only run over an encrypted connection. Decide per target type who may scrape it, which credential Prometheus holds, and where that credential is stored.

Prometheus security model

Admin APIs disabled by default

Prometheus keeps its admin HTTP APIs off unless an operator enables them. The --web.enable-admin-api flag unlocks destructive operations such as deleting series, and --web.enable-lifecycle enables reload and shutdown endpoints. Keep both flags off in production unless a specific runbook needs them, and confirm that the web listener is reachable only from the networks that need it. Any change to these flags belongs in version control and review.

Exporters that take URL targets

Exporters such as SNMP and Blackbox take the target to query from URL parameters. The security model warns that anyone with HTTP access to such an exporter can make it send requests to arbitrary endpoints, which turns the exporter into a relay inside your network. Restrict who can reach these exporters, limit the destinations they may query where the exporter supports it, and review the scrape configuration that passes those parameters.

No built-in single sign-on or CSRF protection

Prometheus has no built-in single sign-on, and its security model notes there is no built-in CSRF protection on mutating endpoints. Teams that expose the web UI or API to people, rather than only to scrapers, usually place an authenticating reverse proxy in front of it. Confirm that the proxy enforces the identity policy, that the Prometheus port is not reachable around it, and that write-capable endpoints sit behind the proxy.

Retention and local storage exposure

Prometheus stores samples in a local time series database with a default retention of 15 days, and local storage is not clustered or replicated. Captured metrics can therefore contain sensitive label values for that whole window, and the data directory needs the same access control as any single-node database. Ask who can read the data volume, how it is backed up, and whether long-term storage receives the same labels.

Prometheus storage docs

What instrumentation work costs and what it needs from your team

What parts of instrumentation work are actually paid for?

Most of the cost is labor, not software, because Prometheus and its client libraries are open source under Apache-2.0 with no paid enterprise edition of the project itself. The work usually breaks into five components: inventorying which services, jobs and hosts exist and who owns them, changing code to expose metrics, reviewing metric names and labels, testing that the series appear and stay low in cardinality, and ongoing maintenance as services change. Infrastructure for the Prometheus servers and storage is a separate recurring cost. Ask any provider to price each component separately so you can see which ones your team already covers.

What makes instrumentation effort grow quickly?

Effort grows with the number of languages and frameworks in use, because each one needs its own client library, conventions and sometimes a different way to expose metrics. Legacy systems with no existing metrics, or with code nobody still maintains, add effort because someone must read the code before changing it. Unclear ownership is often the largest hidden driver: when no team agrees which metrics a service should expose or who answers for its alerts, reviews stall and rework follows. Count these factors before you request a quote, since they determine the scope more than the number of servers.

Can an internal team instrument services without outside help?

Yes, many internal teams do this themselves, especially when they already run Prometheus and have engineers who know the client libraries for their languages. The main risks for a team working alone are inconsistent naming, unbounded label values that inflate storage, and metrics that are added but never used in dashboards or alerts. A useful test is whether one team can apply a written naming standard across all services and review new metrics before they ship. If that standard does not exist yet, an outside partner can help write it and then support the rollout, which is a different scope from doing all the code changes.

How long does instrumentation take for a typical estate?

Duration depends on the scope you set, so no fixed figure applies across estates. The main variables are the number of services and batch jobs, how many languages are involved, how much code needs changing, and how quickly reviews and testing happen in your change process. A small, well-owned set of services usually moves faster than a broad estate with many unknown owners. Ask for a schedule that breaks the work into phases by system type, with a defined end for each phase, rather than one open-ended date.

What should a fixed-scope quote for instrumentation include?

A fixed-scope quote should name the systems in scope, the languages and frameworks, the metric types each system will expose, and the naming and label standard the work follows. It should list deliverables such as code changes, a review of metric names and labels, test evidence that the metrics are scraped, and documentation for the team that runs them. It should also state what is excluded, including dashboards, alert rules and Alertmanager setup, and who approves changes. Ask how the quote handles unknown systems discovered during the inventory, since that is the most common source of change requests.

Does instrumentation add security exposure I should review?

Exposing a metrics endpoint is low risk in itself, but it reveals internal names, versions and behavior, so the endpoint should not be open to untrusted networks. Prometheus scrapes these endpoints over HTTP, so access should be limited by network policy, and TLS or authentication should be added where the network path crosses trust boundaries. Labels also deserve review, because user identifiers or personal data placed in label values can end up in long-term storage. Include these checks in the quote so they are tested, not assumed.

What do we need to prepare before asking for a quote?

Prepare an inventory of services, batch jobs and queues, with the language, owner and current monitoring for each. Note which systems already expose metrics, which use a different monitoring tool and which have no monitoring at all. Gather your current metric naming rules, if any, and the alerting paths your on-call team uses. Access to a non-production environment where Prometheus can scrape the new endpoints makes the quote more accurate. Confirm which of these items you can provide yourself, since missing inventory is the most common reason estimates change.

What costs recur after the initial instrumentation work?

Recurring costs include running the Prometheus servers and their storage, which depends on how many series you collect and how long you retain them. Retention defaults to 15 days in the Prometheus storage documentation and is configurable by time or size, so retention choices directly change storage needs. Ongoing effort covers upgrades to new Prometheus releases, review of new metrics as services change, and cleanup of metrics that nobody uses. Ask whether a support or maintenance arrangement covers these tasks and how changes are approved.

How the instrumentation rollout is set up and verified

This sequence turns the system-type checklist into a tested rollout: an agreed inventory, shared names, one pilot service, and alerts and label limits checked against real data before the pattern spreads to the rest of the estate.

  1. Agree the service inventory by system type

    Platform owners and service leads list every service, offline processing pipeline and batch job, and tag each with its type: online-serving, offline processing or batch. Each tagged item gets its key metrics from the checklist: request rate, errors and latency for online services, queue depth and processing delay for offline systems, and last successful run for batch jobs. Done means every item has a type, an owner and a named set of metrics, and the owners have signed off the list. Ask each owner to confirm which jobs run in short-lived processes, because those affect how their metrics are collected.

  2. Adopt a shared naming and label standard

    Before any code changes, the team agrees on metric prefixes, base units, the _total suffix for counters, and a short list of allowed labels such as route, method and status class. Labels that carry user IDs, request IDs or other unbounded values are excluded in writing. The standard is stored in version control next to the inventory so reviewers can cite it. Done means a reviewer can check a proposed metric name and label set against a written document, and the standard lists the exceptions that were approved.

  3. Instrument one pilot service end to end

    Choose one online-serving service and one batch job with different failure modes, then add the agreed metrics using the client library for its language. Expose the metrics endpoint, configure a scrape target through the chosen discovery method, and deploy the change to a non-production environment first. Done means both targets show as up in Prometheus, and the team has a short record of which code paths and deploy steps were needed, which becomes the template for the remaining services.

  4. Confirm series in the expression browser

    Open the Prometheus expression browser and run queries that return each metric the pilot exposes, including the labels it carries. Check that counters increase under test traffic, that histogram buckets are present where latency is recorded, and that the batch job's last success timestamp updates after a real run. Done means each expected series returns a value, and the query results match what the service's own logs show for the same period. Record the working queries, since they become the basis for dashboards and alerts.

  5. Write one alert for each key metric

    For each pilot metric, write one alert rule that pages on a real symptom: an error ratio over a window for the online service, a growing queue or processing delay for the offline system, and a last success time that is too old for the batch job. Run the rules with promtool, check their expressions in the expression browser against known good and known bad periods, and route them to Alertmanager in a test receiver. Done means each rule has been seen to fire in a controlled test and to stay quiet during normal operation, and the owner has accepted it.

  6. Review cardinality after a week of data

    After the pilot has collected about a week of data, the platform team checks the number of active series per metric and the label values each one holds. They compare the result with the allowed labels in the standard, look for labels that grow with users, requests or job runs, and check how much memory and disk the server now uses. Done means the review produces a short written result listing any metric to change, label to drop or metric to remove, and the owner has agreed to the changes before the rollout extends to other services.

  7. Extend the pattern and confirm ownership

    Apply the agreed pattern to the remaining services in the inventory in batches, reusing the pilot's template and the reviewed naming standard. Each batch repeats the series check and cardinality check on a small scale before the next batch starts. The rollout closes when every inventory item has its metrics scraped, its alert rules in place, and a named owner who can answer questions about them. Done means the inventory shows every item as instrumented and verified, and the owners know where the naming standard and alert rules are kept.

How DeployOpen scopes and delivers Prometheus instrumentation

Instrumentation work only holds up when the scope is written down before anyone touches code. The cards below follow one engagement from inventory through handover, and each step narrows what the next one has to build and verify.

Written scope and deliverables

Before work starts, the scope names the services, batch jobs and queues to instrument, the metric families each one must expose, and the deliverables the client receives. Ask for the list of systems in writing and for each system to be tagged as online serving, offline processing or batch job. A scope that says only "instrument the platform" leaves cost and acceptance criteria open, so push for named systems and named outputs.

Instrumentation best practices

Inventory and classification

The first phase lists every service, worker, consumer and scheduled job, then classifies each one by how it works. Online-serving systems need request rate, errors and latency. Offline processing needs queue depth and processing delay. Batch jobs need a last-success timestamp. Misclassifying a job is the most common reason dashboards show the wrong signal, so the classification is reviewed with the owning team before code changes begin.

Instrumentation of agreed services

Each agreed system gets metrics added through the chosen client library, following the naming and label rules agreed for the estate. Labels are limited to values with bounded sets, such as route templates rather than raw URLs, because unbounded labels multiply series and slow the server. Changes go through the client's normal code review and build pipeline so the metrics survive future releases.

Verification and handover

Verification checks that each metric appears on the endpoint, that its type and labels match the agreed list, and that the expected queries return values under test load. Batch jobs are checked by forcing a failure and confirming the last-success metric stops advancing. Handover includes a runbook, the metric catalog and the alert rules the client chooses to keep, so the client's team can operate the work without DeployOpen present.

Ongoing support as a retainer

Instrumentation drifts as services change, so ongoing support covers new services, renamed metrics, client library upgrades and periodic reviews of label growth. This is offered as a retainer separate from the fixed-scope build. Ask in any quote which Prometheus release line the work targets, since the current long-term support line is 3.13 and minor releases stop receiving bug fixes after six weeks.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.