Why one bad deployment can take down Prometheus and how scrape limits stop it
A scrape limit makes Prometheus reject an oversized scrape instead of ingesting it, so one team's bad release cannot degrade everyone else's dashboards and alerts. The situation is familiar: a shared Prometheus scrapes dozens of services, and one team ships a release that adds a label carrying user IDs or request paths, or an endpoint that suddenly returns a very large response. Each new label value creates a new time series, memory use climbs, queries slow down, and alert evaluation falls behind. Nobody notices until dashboards time out or a rule stops firing. A scrape limit sets an upper bound per scrape job on the number of samples, the number of labels, the size of the response body and the number of targets, so an overrun fails that scrape rather than flooding the server.
The failure is deliberately visible. When a limit is exceeded, Prometheus drops the whole scrape for that target and records the failure, so the team that owns the target can see the problem in the up series and in the scrape status for that job. This is the trade the Prometheus project makes: its overview documentation states that Prometheus values reliability over precision and is not a good choice where 100% accuracy is required. A failed scrape leaves a gap in one team's data, which is preferable to a server that stops answering queries for everyone. Before setting limits, confirm with your own environment which scrape job settings your Prometheus version supports and how your team's alerts treat a target that is failing.
Prometheus is open source under Apache-2.0, so the software itself carries no license fee. The costs that matter are the servers and storage that run it, and the people who set limits, own the alerts that fire when a scrape fails, and review new label usage. Those costs are mostly recurring, because every new team and service changes the series budget. Plan the limit owner before the first incident: one platform engineer who sets defaults for each scrape job, and a team contact who agrees to fix any target that breaks its budget.
What each scrape limit controls
The sample_limit setting caps how many samples a single scrape of one target may return. It is the closest control to a cardinality guard, because a target that suddenly exposes many new label combinations produces more samples on every scrape. When a scrape returns more samples than the limit, Prometheus does not keep the partial result. The whole scrape is treated as failed for that target, so the series from that target stop updating and the target's health shows as down. The limit is set per scrape job, which makes it useful when one service is known to be prone to label growth.
- What is counted: the samples returned by one scrape of one target, after metric relabeling has run.
- What happens when exceeded: the scrape fails as a whole and the target's series stop receiving new points.
- When it fits: services with a known upper bound on series, such as a fixed set of endpoints or queues.
- Trade-off: setting it too low causes a complete outage of metrics for that job, not a partial one.
- Setup note: a limit set after an incident can blind you to the same target, so pair it with a dashboard that tracks samples per target.
Before you set this value, confirm the key name, the behavior after an exceeded scrape, and any version-specific changes in the Prometheus configuration reference for the version you run.
The label_limit setting caps the number of labels a single sample may carry after relabeling. It protects the index from metrics that add labels dynamically, such as request paths, user identifiers or error messages copied into label values. The limit applies per series, so one unusual series can fail its scrape even when the total sample count is normal. Confirm in the configuration reference how a violation is reported and whether the whole scrape fails in your version.
- What is counted: the number of label names on each series after relabeling.
- What happens when exceeded: the scrape that produced the offending series is rejected, so the other series in that scrape are lost with it.
- When it fits: instrumentation that is well understood but may be changed by a new release of a library or application.
- Trade-off: it catches label mistakes but does not limit how many distinct label values a label can take.
- Setup note: pick a limit that leaves headroom above the highest label count you have measured for healthy series.
Check the exact key name and whether relabeling runs before or after the check in the Prometheus configuration reference for your version.
The label_value_length_limit setting caps the length in bytes of any label value on a sample. It targets a different failure than the label count limit. A single label that carries a stack trace, a full URL with query strings or an encoded payload can be very large even when the label count is small. Long values bloat the index, slow queries and increase memory use. As with the other limits, a violation affects the scrape that contains it, so the impact spreads to every series in that scrape.
- What is counted: the byte length of each label value after relabeling.
- What happens when exceeded: the scrape that produced the value is rejected, which can remove unrelated series from the same target.
- When it fits: services that expose free-text or user-supplied strings through labels by accident.
- Trade-off: a generous limit does little to stop cardinality, so combine it with sample and label checks.
- Setup note: most long values come from a handful of code paths, so fix those paths first and keep the limit as a backstop.
Confirm the key name, the unit, and the reporting behavior in the Prometheus configuration reference for your version before you write the value into a config file.
The body_size_limit setting caps the size of the HTTP response body Prometheus will accept from a scrape. It guards against a target that returns an unexpectedly large page, whether from a runaway exporter, a debug endpoint left enabled or a misrouted request that returns a file. The limit is checked on the raw response, before samples are parsed, so it protects memory during the parse step. It is a different control from the sample limit, which only applies after parsing.
- What is counted: the bytes of the response body from one scrape.
- What happens when exceeded: the scrape fails and the target is reported with an error, so its series stop updating.
- When it fits: exporters that wrap large internal state, or any target reached through a shared proxy.
- Trade-off: a limit that is too small fails healthy targets that grow over time, often without a code change.
- Setup note: measure the response size of each exporter during normal operation and review the value after exporter upgrades.
Confirm the key name, the unit and whether the setting is available at the scrape job level in the Prometheus configuration reference for the version you run.
The target_limit setting caps how many active targets a scrape job may hold after service discovery and relabeling. It is the control for a discovery mistake rather than a single bad target. A wrong label selector, a misconfigured Kubernetes namespace or a cloud tag change can match thousands of endpoints in one step. Without a cap, Prometheus tries to scrape all of them, which consumes memory, connections and disk. When the limit is exceeded, Prometheus drops targets beyond the cap, so the outcome depends on which ones are kept, and that choice should be verified in the configuration reference.
- What is counted: the number of targets in one scrape job after discovery and relabeling.
- What happens when exceeded: targets beyond the limit are dropped, and the job reports that it is over the limit.
- When it fits: jobs that use broad discovery, such as label-based or cloud-tag selection.
- Trade-off: dropped targets are silent unless you watch the job's status, so alerting on the limit matters.
- Setup note: set the cap from the expected count of targets for the job, not from the largest count the discovery ever produced.
Before relying on this control, confirm its name, what is dropped and how the drop is reported in the Prometheus configuration reference for your version.
Choosing limits by failure mode
This table matches each Prometheus scrape limit to the failure it contains and the cost it imposes on the target's data. Read each row as a question: which failure is hurting you, and which limit fits the team or cluster that owns the job.
| Limit type | Failure it prevents | Cost or trade-off | Best fit |
|---|---|---|---|
| sample_limit | One target exposing an unexpected number of series, often from a new label value such as a user ID or request path | If the target exceeds the limit in a scrape, the whole scrape is failed and none of that target's samples for the interval are stored | Any job where series counts per target are predictable and owned by one team |
| label_limit and label_name_length_limit | Labels with very many names or very long names from a bad instrumentation change, which inflate memory and index size | Targets with legitimately long label sets can fail until the limit is raised, so the value needs review | Shared clusters where teams instrument independently |
| label_value_length_limit | Oversized label values such as full URLs, stack traces or serialized payloads stored as label values | Failed scrapes can hide the offending label until someone checks the up metric and scrape logs | Shared clusters that accept third-party exporters |
| body_size_limit | A misbehaving exporter or endpoint returning a very large response that consumes memory and scrape time | A legitimate large exposition is refused, so the limit must be sized from the largest real response you measure | Jobs that expose bulk data or custom exporters with unknown output size |
| target_limit | A service discovery change or a relabeling mistake that adds far more targets to a job than the server was sized for | Targets above the limit are dropped, so coverage gaps appear unless the drop is alerted on | Single-team servers where the job's target count is stable and known |
| Shared cluster with several teams | Any one team's deployment affecting every other team's metrics on the same server | Needs per-job limits agreed with each team and a review path for raising them | Platform teams running one Prometheus for many services |
| Single-team server | Mostly self-inflicted changes that the owning team can see and fix quickly | Tighter limits add operational friction with less protection from other teams | Dedicated servers where one team owns every scrape job |
| Failed scrape losing a whole target for the interval | Partial data from a half-scraped target that would mislead dashboards and alerts | Dropping all samples for a target during a limit breach creates a gap, so alerts on the up metric and limit-hit counters are required | Every deployment that sets limits, regardless of team layout |
Every scrape passes the limit checks before storage
The diagram starts at the target's HTTP response and follows one scrape through the checks Prometheus applies before storing anything. The body size check runs first, then samples are parsed and label checks run, followed by the sample limit. The target limit caps how many targets a scrape job can hold before samples reach local storage. Any check that fails ends the scrape, and that failure is recorded as scrape health data that alerts can watch. Confirm each branch when you set limits, because a sample limit breach fails the whole scrape, so every sample from that target in that cycle is lost.
The limit checks a scrape passes through, and where failures are recorded.
How failed scrapes surface in monitoring
A scrape that breaks a limit is treated as a failed scrape for that target. Prometheus discards the samples from that scrape rather than keeping a partial set, so the target looks down or stale on dashboards even though the application itself may be running. The first place to look is the up metric, which is set to 0 for a target whose last scrape failed. Prometheus also emits scrape health series for each target, such as scrape_samples_scraped, scrape_samples_post_metric_relabeling and scrape_series_added, which help show how close a target is to its sample_limit or label limits before it fails. The exact set of series, their names and whether a given limit reports its own failure reason should be confirmed against the Prometheus version you run, using the scrape documentation in the Prometheus overview and the release notes for that version.
Because a limit hit looks like an outage of one target, it is easy to miss unless someone is alerting on it. Build an alert rule on up == 0 per job, and pair it with a rule that fires when a job's scraped sample count approaches its configured limit, so the team sees the pressure before the scrape drops. Route these alerts to the owning team of each scrape job, not only to the central platform on-call, because the fix is usually in that team's deployment, such as removing a label that carries user IDs. Test the rule once on purpose by setting a deliberately low limit in a non-production Prometheus, confirming the alert fires and reaches the right receiver. Alertmanager configuration is covered separately, but the rule itself belongs in this review.
Decide early what a failed scrape should mean for your estate. A dropped scrape means the target's metrics are missing for that interval, so alerts that depend on those metrics may stop evaluating or resolve incorrectly. Document which dashboards and alerts depend on each job, and confirm with the team that owns each job how they want a limit breach handled: keep the limit and fix the source, or raise it with a recorded reason. Ask your platform provider to show, during the scope agreement, which failure series your Prometheus version exposes and how the team will be notified.
How to set scrape limits per job and per team
This sequence moves scrape limits from an idea to an owned, tested and alerted control, so one team's bad deployment cannot exhaust the Prometheus server that every team depends on. Each step ends with a check you can record before moving on.
Inventory current series and samples per job
Start by measuring what each scrape job produces today. Use the Prometheus UI and the up metric to list every job, its number of targets, and its current series count, and identify which jobs have the largest footprints or the fastest growth over recent weeks. Platform engineers should run this with read access to the server, and each team lead should confirm which jobs they own. The step is done when every job has a recorded baseline, owner and target list, so later limits are set from measured data rather than guesses.
Agree headroom with each owning team
Share the baseline with each team and agree in writing how much growth their job may add before a limit applies. Teams should explain expected releases, new labels or instrumentation changes that could raise series counts, and the platform owner records the agreed headroom next to each job. Ask each team to name a contact for limit breaches. The check is a signed-off table with one row per job covering baseline, headroom, owner and escalation contact.
Set limits in scrape configs per job
Add the agreed limits to each job's scrape configuration, using the sample_limit, label limit, body_size_limit and target_limit settings that match the Prometheus version in use. Keep one job's limits in one place in version control so reviewers can see every change. Confirm each setting name and behavior against the Prometheus configuration reference for your version before committing. The check is a configuration review that shows every scrape job has an explicit limit or a documented reason for none.
Roll out limits in a staging Prometheus
Apply the new configuration to a staging Prometheus that scrapes the same kinds of targets as production, ideally with a copy of production target lists. Watch the staging server's logs, targets page and series counts after the reload, and confirm the reload succeeded using the configuration reload path your deployment allows. The check is that staging loads without configuration errors and that no legitimate job loses samples because a limit was set below its normal baseline.
Verify limits with a deliberate breach test
In staging, expose a test target that intentionally produces more samples, labels or body size than its job allows, and confirm the breach behaves as documented for your version. Check how the scrape is reported, whether the target is marked down, and whether the other jobs keep working. Record the exact metric and log messages produced so alert rules can match them later. The check is a short written result showing the limit fired, which signals were visible, and that unrelated jobs were unaffected.
Alert on failed and limited scrapes
Create alert rules for scrapes that fail or are rejected by a limit, and route them to the owning team rather than a shared inbox. Base the rules on the up metric and the scrape-related metrics your Prometheus version exposes, and test each rule by triggering it with the breach target from the previous step. Confirm the alert reaches the right receiver through Alertmanager. The check is a firing alert in staging with a routed notification to the owner, and a documented threshold for how long a failure must persist before paging.
Document owners and change paths for each limit
Write a short record for every limit that names the owning team, the agreed headroom, the reason for the value and the process for requesting an increase. Store this record next to the scrape configuration, and require a review by the platform owner for any change that raises a limit. Schedule a periodic review of the table against fresh series counts. The check is that every limit in production has a documented owner and change path, and that a team can explain how to request an increase without contacting the person who wrote the original setting.
Promote limits to production and review
Apply the reviewed configuration to production using the same change path used in staging, and repeat the inventory query afterward to confirm series counts stay within agreed headroom. Compare the first production alerts with the staging results and adjust the rules or documentation where they differ. The check is a production configuration that matches the reviewed change, a recorded post-change inventory, and an agreed date for the first limit review.
Security and operational risks of scrape limits
Limits protect Prometheus from runaway targets, but they also create their own failure modes. The cards below cover the risks that appear after limits are in place: data quietly dropped, settings that nobody revisits, and the endpoints and scrape paths that a limit change or a misconfigured target can expose.
Limits that drop data silently
When a scrape exceeds sample_limit or label_limit, Prometheus discards the whole scrape result rather than the excess series, so a target can look healthy in dashboards while its metrics vanish. Set the limit from observed series counts with headroom, and confirm that scrape_samples_post_metric_relabeling and the scrape failure metrics feed an alert. Treat a limit breach as an incident, not a tuning detail.
Limits set once and never reviewed
A limit chosen during rollout can become wrong after a release adds labels, a traffic pattern shifts or a team onboards a new service. Assign an owner for each scrape job's limits and review them on every release of the instrumented application. Record the reason for each value in the configuration repository so the next reviewer knows whether a breach is expected growth or a regression.
Limits that bypass security context
A limit protects the server's resources, not the trust boundary. A target that is reachable from an untrusted network, or a scrape job that accepts an unexpected response from a changed endpoint, can still push data into Prometheus within the limit. Review which networks can reach each target and whether the job's TLS and authentication settings match the target's sensitivity before relying on limits as a control.
Exporter targets set by URL parameters
The Prometheus security model warns that exporters such as SNMP and Blackbox take their target from a URL parameter, so anyone with HTTP access to the exporter can make it send requests to arbitrary endpoints. Restrict network access to exporters, avoid exposing them to users or other tenants, and list the permitted target ranges in your review. Scrape limits do not stop this behavior.
Security modelAdmin and lifecycle endpoints
The admin API is disabled by default, and --web.enable-admin-api enables destructive operations while --web.enable-lifecycle enables reload and shutdown. Changing limits usually means a reload, so enabling lifecycle endpoints on a reachable interface lets any caller reload or stop the server. Keep both flags off unless needed, bind the endpoints to a management network, and put an authenticating proxy in front of them.
TLS and authentication for scrape targets
Scrape jobs can use TLS, client certificates and basic authentication, with a minimum of TLS 1.2 supported by Prometheus. Basic authentication without TLS sends credentials in cleartext, so every job that uses it needs TLS on the target side. Confirm certificate rotation dates for each job, since an expired certificate makes the target go down rather than produce a visible limit warning.
Questions teams ask before setting Prometheus scrape limits
How much effort does it take to set scrape limits across all jobs?
The effort depends mostly on how many scrape jobs exist and how many of them have never been measured. Each job needs a known series count, a chosen ceiling for sample_limit, label_limit and body_size_limit, and a decision about what happens when a target exceeds it. Teams that already run the TSDB status API and know their top series producers can move quickly. Teams starting from no inventory spend most of their time on measurement, not on writing configuration. Ask any partner to split the work into inventory, configuration, alert changes and rollout so you can see where the time goes.
What drives the cost of setting Prometheus scrape limits?
Cost comes from people time, a staging environment and alert tuning. Engineering time covers measuring series per target, agreeing limits with service owners and writing scrape configuration. A staging Prometheus lets you test a limit against realistic exporter output before it reaches production, and that environment has its own infrastructure cost. Alert tuning is often the largest hidden item, because a limit that drops samples will change what dashboards and rules see. Prometheus is Apache-2.0 licensed, so there is no license fee for the project itself. Ask for a quote that lists each of these components separately, with one-time work marked apart from ongoing review.
What does the work need from our team?
The work needs three inputs from your side: a series inventory, a named owner for each team's scrape jobs, and a change process for limit updates. The inventory shows which jobs produce the most series and which targets are near a ceiling. Owners decide whether a limit is a fix, an instrumentation change or a true capacity need. A change process defines who approves raising a limit and how a new deployment is checked before it reaches production. Without owners, limits tend to be set once and then raised whenever an alert fires. Confirm early who in your organization can approve changes to scrape configuration.
Can our own team set Prometheus scrape limits without a partner?
Yes, a team with Prometheus experience can set scrape limits in-house, and the configuration keys themselves are simple to apply. The harder part is knowing what value to choose for each job and what breaks when a target is capped. Teams usually need time to build the series inventory, to test limits against realistic exporter output and to tune alerts that depend on the affected metrics. A partner is most useful when the estate is large, several teams share one Prometheus, or the team lacks spare capacity for a staged rollout. Compare the in-house effort against a written scope before deciding.
How long does setting limits take for a small or large estate?
Duration scales with the number of scrape jobs, the number of owning teams and how much measurement is still needed. A small estate with a few jobs and one owner can often be handled in a short cycle, while a large estate with many teams needs staged rollouts and review periods between them. This page does not give a fixed duration because no researched figure is available for it. Ask for a timeline that breaks the work into inventory, pilot jobs, team-by-team rollout and alert review, and ask what assumptions about job count and team count it depends on.
What happens to a failing scrape after a limit is hit?
When a target exceeds a limit, Prometheus fails that scrape and records the failure, so the target's up metric drops and the samples from that scrape are not stored. This keeps one bad deployment from exhausting memory and storage for every other job. The trade-off is that the affected metrics go missing, so alerts and dashboards for that service can go quiet. Your team should confirm how failed scrapes appear in its own alert rules before a limit goes live. The Prometheus overview explains the pull model and why Prometheus favors reliability over precision.
Who owns the limits after the initial rollout?
Ownership usually stays split between a platform team, which owns the Prometheus server and the global defaults, and service teams, which own limits for their own jobs. The platform team controls the review process and the change path for raising a limit. Service teams are responsible for keeping their instrumentation within the agreed ceiling. Without this split, limits drift as teams add labels or metrics. Ask whether ongoing review is part of the engagement or handled by your team, and how often limits are reviewed against the series inventory.
Does setting scrape limits change our compliance evidence?
Limits can change what monitoring evidence you hold, because a capped target produces fewer samples and may trigger failed-scrape alerts. Keep the limit values, change approvals and the alerts that cover failed scrapes in version control so an auditor can trace them. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports or certifications. Independent auditors and certification bodies make those determinations. Check with your assessor which monitoring records they expect to see.
How DeployOpen scopes limit work in your infrastructure
A limits engagement starts with a review of the scrape configuration that already runs in your environment, because the limits you can safely set depend on what each job currently exports. DeployOpen works inside your infrastructure, reads the scrape_configs for every job, and records which targets are scraped, how often, through which service discovery mechanism, and which teams own each job. The review also checks the current series counts, the up and scrape_samples_scraped behavior of each job, and whether any job already reports failed scrapes. The output of this phase is a written inventory that you can review before any change is made, and it is the input for the limit decisions. Confirm with your own team which jobs have owners who can answer questions about expected cardinality, because a limit set without that answer tends to be guessed.
From that inventory, DeployOpen drafts a written list of limits per scrape job and per team. The list names the setting for each job, such as sample_limit, label count and label length limits, body_size_limit and target_limit, along with the reasoning and the owner who accepts it. Teams that deploy frequently or run exporters with variable label sets are the ones to plan for first. The list also defines how a breach should surface: which alert fires when a scrape fails because of a limit, who receives it, and what the owner is expected to do. Because Prometheus marks a failed scrape as down and does not ingest partial data for that scrape, the written plan should state explicitly how the team will see that failure, so that a dropped job is never silent. Agree this list in writing before rollout, and confirm the exact field names and behavior against the Prometheus version you run.
The rollout is staged: limits are applied to one non-critical job first, observed, then extended to the rest of the estate. DeployOpen can run the staged rollout and the retest against the written plan as part of the fixed scope, and the scope document should say which environments, jobs and teams are included. Ongoing review is available as an optional retainer, which covers periodic review of new scrape jobs, limit adjustments as services change and checks after Prometheus upgrades. Ask any provider to state in the quote who makes the change in your configuration repository, who approves it, and how the limit file is reviewed after the engagement ends.

