To reduce Prometheus cardinality before remote write, find the metric family that grew, check who depends on it, and drop it on the way out only if every remote consumer can do without it. Your local Prometheus can keep scraping and storing the family for local queries.
The walkthrough below is an illustrative loopback example. It shows how to compare a sender with a local receiver, test a retained checkout alert, and catch a counter identity collision before you apply the filter.
When you send to Logit.io, the destination is VictoriaMetrics, not a Prometheus server. From Infrastructure Metrics → Remote Write, click Copy Remote Write URL. It points at a VictoriaMetrics endpoint on a host of the form your-stack-id-vm.logit.io. The local loopback receiver in this example only proves what the sender forwards. To inspect series on Logit.io, click Launch Metrics on the stack to open Grafana (Grafana OSS 13.0.2). See the Metrics storage overview and the Remote Write settings.
Contents
- Find which metric family grew
- Check which queries need the dimensions
- Choose where to reduce the series
- Prove the retained series still work
- FAQ
- Does a longer scrape interval reduce active series?
- Can I keep the metric locally and drop it for one destination?
- Why did the page clear when a series went missing?
- Can I drop some classic histogram buckets?
- Why is the dropped family still visible in a remote graph?
- Can I use Logit.io Metrics during the free trial?
- Next steps
Find which metric family grew
Begin with the family that prompted the review. Record its scrape job, the time the increase started and the destination that received it. Choose a representative baseline and a recent window of the same length. Compare them under similar traffic and rollout conditions. Write down whether you counted series in the sender or in the destination. The sender can have extra families or different labels, especially if existing write relabel rules or external labels change what the receiver sees.
New labels, new targets and buckets
Count distinct label sets, including the metric name. Run the same expression at the end of each comparison window. This example counts each series that has a sample in the preceding 30 minutes, grouped by metric name and job. Scope the selector to the job and candidate families so you can inspect the groups without scanning unrelated jobs.
count by (__name__, job) (
last_over_time({job="demo",__name__=~"demo_requests_total|demo_debug_events_total"}[30m])
)
Break the request counter down by route, outcome and instance next. A new route value across existing instances points to an instrumentation or routing change. More instances with the same route and outcome mix point to a change in target count. A rolling deploy can show both old and new instances in one window, so record target overlap when comparing the totals. Check the raw label sets from both windows when a grouped count hides which values were introduced.
With three routes, two outcomes and four instances, 3 × 2 × 4 = 24 is a calculated upper bound for that counter in one job if all combinations exist and those are the only varying labels. Rare errors might only appear on one route, or a route might only run on two instances. Those gaps change the measured count. Extra varying labels or instance churn across a longer window can also change the total. Keep the estimate and the measured count in separate fields in the review. The loopback exporter below emits four request series from two routes, two outcomes and one instance.
For a classic histogram, inspect the _bucket, _sum and _count series together. Each emitted bucket boundary, including +Inf, adds a bucket series for each combination of the other labels. An exporter publishing eight finite boundaries therefore emits nine bucket series plus a sum and a count for each combination. If only the bucket count rose while targets and application labels stayed stable, check whether a release added boundaries. Compare the boundaries with the thresholds used by latency panels and service-level objectives before proposing a change.
Check which queries need the dimensions
Dashboards, paging rules and ad hoc queries
On a Logit.io Metrics stack, click Launch Metrics to open Grafana (Grafana OSS 13.0.2), then search panel queries and dashboard variables, alert definitions and recording rules for the family and its dimensions. Follow recording rule names into the panels and alerts that read them. A Grafana panel might query only a recorded rate even though the underlying rule depends on a raw counter. For each consumer, capture the data source, expression, expected labels and behaviour when the input is missing. A sender-side Prometheus rule can still read a family after a write-time drop. A rule evaluated against the remote copy needs the series at that destination.
Include the questions people ask during an incident. Ask the on-call owner whether they need to compare checkout p95 by route, recognise a single slow instance, or count requests within a particular latency threshold. A fleet-wide percentile can look stable while checkout degrades. If the question is a percentile across instances, a classic histogram query needs the bucket distribution and must preserve le in the aggregation passed to histogram_quantile(). If the question is a threshold ratio, identify the bucket and the denominator the query uses.
Use a keep/drop register to capture the decision in the change review. Give each entry an owner and identify the actual panel or rule and where it runs. The example register uses invented owners, panels and expressions. Confirm incident-only usage with the owner before marking a remote dependency as absent.
| Metric and decision | Metric owner | Dependent panel | Paging expression | Rollback |
|---|---|---|---|---|
demo_requests_total · Keep on sender and receiver | Checkout team | Checkout error rate by route in remote Grafana | Checkout error-rate rule, below | Restore the previous sender config if the checkout series or expected alert labels disappear. |
demo_debug_events_total · Keep on sender, drop at remote write | Worker team | Worker debug activity in a local-only Grafana view | None in this example | Restore the unfiltered write config and verify a new debug sample at the receiver. |
Paging expression for the retained checkout rule, evaluated for 30s on the sender:
sum by (job, route) (rate(demo_requests_total{job="demo",route="/checkout",outcome="error"}[1m])) > 0.1
Ask the paging owner to confirm what should happen if the source goes missing. A comparison such as the one in the register returns an empty vector when there are no usable inputs. The page can clear even when nobody has established that the error rate recovered. If missing data should page, agree on a separate coverage condition and the expected routes or targets. A single absence check over a whole job can miss the loss of one route while another continues reporting.
Choose where to reduce the series
Where to cut the series
Fix the instrumentation when the schema itself creates unnecessary series. Use a literal route template such as /orders/{order_id} as the route value. Put individual request IDs in logs or traces, where someone can use them to investigate a specific request. Have the metric owner verify the new labels against the queries that need them, and compare old and new instruments over an overlap window before removing the old one.
Use write_relabel_configs when local users still need the whole family and the selected destination can do without it. Prometheus applies those rules on the sender after adding external labels and before sending samples to that destination. Each remote_write entry has its own rules. Review the other entries if the sender has multiple destinations. Use metric_relabel_configs only when the job can discard the family before local ingestion. Both rules run on your Prometheus sender.
Redesign the aggregation when remote consumers still need a narrower signal. For a route-level request rate, a local recording rule can compute rate() for each source counter and then use sum by (job, route) on the rates. Calculating rates first lets Prometheus account for each counter's resets independently. Give the recording rule its own metric name. Check that it is forwarded, migrate remote queries to it and compare results across resets and target changes before dropping the raw family from remote write. Decide whether losing remote per-instance drill-down is acceptable as part of that migration.
Example walkthrough. Use matching Prometheus and promtool 3.5.0 binaries. The sender scrapes a Python exporter on loopback and writes to a second, scrape-free Prometheus on loopback. All data is invented. Save the following as exporter.py.
from http.server import BaseHTTPRequestHandler, HTTPServer
from time import monotonic
started = monotonic()
class Metrics(BaseHTTPRequestHandler):
def do_GET(self):
if self.path != "/metrics":
self.send_error(404)
return
ticks = int(monotonic() - started) // 5
body = f"""# TYPE demo_requests_total counter
demo_requests_total{{route="/checkout",outcome="error"}} {ticks}
demo_requests_total{{route="/checkout",outcome="ok"}} {ticks * 8}
demo_requests_total{{route="/catalog",outcome="error"}} 0
demo_requests_total{{route="/catalog",outcome="ok"}} {ticks * 3}
# TYPE demo_debug_events_total counter
demo_debug_events_total{{component="worker"}} {ticks * 2}
""".encode()
self.send_response(200)
self.send_header("Content-Type", "text/plain; version=0.0.4")
self.end_headers()
self.wfile.write(body)
HTTPServer(("127.0.0.1", 38147), Metrics).serve_forever()
Save this scrape-free receiver config as receiver.yml. The receiver has no scrape targets; it only accepts remote write on loopback.
global:
scrape_interval: 1m
scrape_configs: []
Save this paging rule as paging.yml.
groups:
- name: demo
rules:
- alert: DemoCheckoutErrors
expr: sum by (job, route) (rate(demo_requests_total{job="demo",route="/checkout",outcome="error"}[1m])) > 0.1
for: 30s
labels:
severity: page
Save the complete baseline sender config as before.yml. It forwards both example families.
global:
scrape_interval: 5s
scrape_timeout: 2s
evaluation_interval: 10s
rule_files:
- paging.yml
scrape_configs:
- job_name: demo
static_configs:
- targets: ['127.0.0.1:38147']
remote_write:
- url: http://127.0.0.1:38149/api/v1/write
queue_config:
batch_send_deadline: 1s
Save the complete filtered sender config as after.yml. The drop matches the exact series name in __name__. Generated scrape series and locally evaluated rule series can also be forwarded. The walkthrough counts only the two named exporter families.
global:
scrape_interval: 5s
scrape_timeout: 2s
evaluation_interval: 10s
rule_files:
- paging.yml
scrape_configs:
- job_name: demo
static_configs:
- targets: ['127.0.0.1:38147']
remote_write:
- url: http://127.0.0.1:38149/api/v1/write
queue_config:
batch_send_deadline: 1s
write_relabel_configs:
- source_labels: [__name__]
regex: demo_debug_events_total
action: drop
For the separate scrape-time comparison, save this complete config as scrape-drop.yml. Run it with fresh sender and receiver storage so the comparison starts without samples from earlier phases.
global:
scrape_interval: 5s
scrape_timeout: 2s
evaluation_interval: 10s
rule_files:
- paging.yml
scrape_configs:
- job_name: demo
static_configs:
- targets: ['127.0.0.1:38147']
metric_relabel_configs:
- source_labels: [__name__]
regex: demo_debug_events_total
action: drop
remote_write:
- url: http://127.0.0.1:38149/api/v1/write
queue_config:
batch_send_deadline: 1s
Prove the retained series still work
Label sets and a retained alert
Check the complete configs and paging rule with promtool. Save the two unit test inputs below as paging-test.yml. Both have the same checkout error counter through 80 seconds, and only the first has the debug series. The page is pending at 50 seconds and fires by 80 seconds with job="demo", route="/checkout" and severity="page". The second test then makes the checkout input stale. At two minutes and 30 seconds, its one-minute window has no checkout samples. The page is absent and the separate absent_over_time() expression returns one. Those are different signals for the paging owner to review.
rule_files:
- paging.yml
evaluation_interval: 10s
tests:
# Before filtering: the checkout error counter and debug counter are present.
- interval: 10s
input_series:
- series: 'demo_requests_total{job="demo",route="/checkout",outcome="error",instance="127.0.0.1:38147"}'
values: '0+2x12'
- series: 'demo_debug_events_total{job="demo",component="worker",instance="127.0.0.1:38147"}'
values: '0+4x12'
alert_rule_test:
- eval_time: 50s
alertname: DemoCheckoutErrors
exp_alerts: []
- eval_time: 80s
alertname: DemoCheckoutErrors
exp_alerts:
- exp_labels:
job: demo
route: /checkout
severity: page
# After filtering: same checkout samples through 80s, then a missing series.
- interval: 10s
input_series:
- series: 'demo_requests_total{job="demo",route="/checkout",outcome="error",instance="127.0.0.1:38147"}'
values: '0+2x8 stale'
alert_rule_test:
- eval_time: 50s
alertname: DemoCheckoutErrors
exp_alerts: []
- eval_time: 80s
alertname: DemoCheckoutErrors
exp_alerts:
- exp_labels:
job: demo
route: /checkout
severity: page
- eval_time: 2m30s
alertname: DemoCheckoutErrors
exp_alerts: []
promql_expr_test:
- expr: 'ALERTS{alertname="DemoCheckoutErrors",alertstate="pending"}'
eval_time: 50s
exp_samples:
- labels: 'ALERTS{alertname="DemoCheckoutErrors",alertstate="pending",job="demo",route="/checkout",severity="page"}'
value: 1
- expr: 'absent_over_time(demo_requests_total{job="demo",route="/checkout",outcome="error"}[1m])'
eval_time: 2m30s
exp_samples:
- labels: '{job="demo",route="/checkout",outcome="error"}'
value: 1
promtool check config before.yml after.yml scrape-drop.yml receiver.yml
promtool check rules paging.yml
promtool test rules paging-test.yml
Start the example from a directory containing the files above, with free ports and fresh storage directories. Run each long-lived command in its own terminal from that directory. Use sender.yml as the active copy so the sender can reload the two variants while keeping its local samples. The receiver accepts writes on /api/v1/write.
python3 exporter.py
prometheus --config.file=receiver.yml --storage.tsdb.path=demo-receiver \
--web.listen-address=127.0.0.1:38149 --web.enable-remote-write-receiver
cp before.yml sender.yml
prometheus --config.file=sender.yml --storage.tsdb.path=demo-sender \
--web.listen-address=127.0.0.1:38148 --web.enable-lifecycle
Query the sender on port 38148 and receiver on 38149. Count each label set once if it had a sample in the preceding 20 seconds. Wait for four request series and one debug series on both sides to establish the baseline. Record the evaluation time before you reload, since you can use that same timestamp to see the old debug samples later. Each response's value contains the evaluation timestamp and the count.
for port in 38148 38149; do
for metric in demo_requests_total demo_debug_events_total; do
curl --noproxy '*' -fsSG "http://127.0.0.1:$port/api/v1/query" \
--data-urlencode "query=count(present_over_time($metric{job=\"demo\"}[20s])) or vector(0)"
printf '\n'
done
done
Load the write filter, let a full 20-second test window pass after the successful reload, then repeat the counts. Check that all four request series still have samples at the receiver during that window. Compare their full label sets with the baseline. A count of four alone can hide a label rewrite or a change in which routes are present. The local debug count should stay at one and the receiver debug count should fall to zero.
cp after.yml sender.yml
curl --noproxy '*' -fsS -X POST http://127.0.0.1:38148/-/reload
sleep 21
| Example phase | Local request series | Local debug series | Receiver request series | Receiver debug series |
|---|---|---|---|---|
| Baseline | 4 | 1 | 4 | 1 |
| Write-time drop, after a fresh window | 4 | 1 | 4 | 0 |
| Rollback, after a fresh debug sample arrives | 4 | 1 | 4 | 1 |
| Scrape-time drop, with fresh storage | 4 | 0 | 4 | 0 |
A historical query can still see samples the receiver stored before the filter. Re-run the receiver's baseline query with the original evaluation time supplied as the API time parameter and expect one debug series. In a moving window, that series remains visible until its last sample ages out of the window. For a dashboard with a one-hour range, use a range entirely after the cutover when checking the effect. When a remote graph suddenly looks empty or delayed after a filter, compare a fresh window for the excluded family with one for a retained family. A dropped family can look like lag because the graph ends at the last forwarded sample. If retained samples are also late or missing remotely, compare the sender's newest input with each destination's highest sent timestamp, and check pending samples, retries and send errors.
To roll back, copy before.yml over sender.yml, repeat the reload and record the time the reload completed. Query timestamp(demo_debug_events_total{job="demo"}) at the receiver until the value is newer than that time. That confirms resumed forwarding of a fresh sample. A graph with a wide time range may still show earlier debug data, including when forwarding has yet to resume. Use fresh timestamps as the rollback acceptance check and treat any interval during which forwarding was filtered as a potential gap.
After checking rollback, stop both Prometheus processes and start them with new storage paths such as demo-scrape-sender and demo-scrape-receiver. Copy scrape-drop.yml to sender.yml before starting the sender. Keep the exporter running. Once all four request series reach the receiver again, repeat the two debug queries. The sender dropped those debug samples before storage, so the debug count is now zero locally and at the receiver.
Check counter identities before deleting a label. Save these two invented counter samples as collision.prom. The metric name, instance, job and route already agree. The two workers have independent counter values and can reset independently.
demo_worker_requests_total{instance="127.0.0.1:38147",job="demo",route="/checkout",worker="a"} 41
demo_worker_requests_total{instance="127.0.0.1:38147",job="demo",route="/checkout",worker="b"} 73
Preview the effect of a write relabel action with action: labeldrop and regex: worker. Compare the sorted identities before and after, excluding the sample value. The second command is specific to the example's label order and formatting.
cut -d' ' -f1 collision.prom | sort
sed 's/,worker="[^"]*"//' collision.prom | cut -d' ' -f1 | sort | uniq -c
The first command lists two distinct identities. The second reports a multiplicity of two for one identity. This is a failed design even if the config parses. Both source counters would send samples under the same name and labels, so the receiver would lose the ability to distinguish their values and resets. A relabel action only changes the labels. If the remote question is about the combined rate, calculate that rate explicitly and test the recorded output against the original query.
Before approving the real change, compare the original and proposed data sources using the same query time, range and step. Check that the checkout panel still has the expected route and that the paging expression produces the expected label set. Inspect a busy period, a quiet period and an interval with missing data. A smaller total on its own leaves open whether you removed a dimension the on-call team needs. Record the queries, evaluation times and rollback result alongside the owner sign-off.
Unlock complete visibility with hosted ELK, Grafana, and Prometheus-backed Observability
FAQ
Does a longer scrape interval reduce active series?
A longer interval changes how often Prometheus samples each series. If the same metric names and label sets continue to appear, the longer interval by itself does not reduce active series. It can change the number of points available to a short rate window, so evaluate any proposed scrape change separately. Logit.io Metrics pricing uses active series. See Metrics pricing.
Can I keep the metric locally and drop it for one destination?
Yes. Put the write relabel rule under that destination's remote_write entry. Local Prometheus rules and queries retain access to ingested samples. Audit remote recording rules and panels first, since a query evaluated at the filtered destination only has the forwarded data.
Why did the page clear when a series went missing?
The rate expression needs usable counter samples. As the old samples leave its range, the threshold comparison can return an empty vector. Test missing input explicitly and consider a coverage rule scoped to the expected route. Distinguish an empty result from a present counter with an error rate of zero.
Can I drop some classic histogram buckets?
Check the queries first. Dropping a boundary can change percentile interpolation or remove an exact bucket used by a threshold query. Keep compatible boundaries across instances that are aggregated together, including the required +Inf bucket for classic histogram quantiles. Compare the latency answer using representative distributions before changing the design.
Why is the dropped family still visible in a remote graph?
A graph or range selector that reaches back before the filter can still read earlier samples. On Logit.io, those samples stay in VictoriaMetrics until they age out of your stack's retention. Start the evaluation window after the filter takes effect. Confirm that the retained family is still fresh in the same window so the missing debug family can be attributed to the filter.
Can I use Logit.io Metrics during the free trial?
The Logit.io free trial includes every feature. The trial lasts 14 days and requires no credit card. You can use a Metrics stack's Remote Write destination during the trial once you have checked the sender configuration locally. Get started with Logit.io.
Next steps
- After the metric owner signs off on what may leave the sender, go to Infrastructure Metrics → Remote Write and click Copy Remote Write URL. That URL is a VictoriaMetrics endpoint, not a Prometheus server. Set up the Metrics Remote Write destination.
- Compare current active metrics and historical counts in Infrastructure Metrics → Usage Statistics over equivalent windows. View metrics usage and counts.
- If samples you intend to send reach the remote graph late or fail to arrive, compare scrape freshness with each destination's sent timestamp and check the sender's queue.
