How to reduce log costs: a practical guide to log volume reduction without losing visibility
Why log volume explodes, how to measure it per service, level and source, and which levers actually work: log level policy, sampling and deduplication, filtering in the pipeline, logs-to-metrics, structured logging, retention tiers and ownership.
Summary
- To reduce log costs you first need to know where the volume comes from: measure records and bytes per service, log level and source, because a few sources such as debug logs, health checks and access logs usually dominate.
- The most effective levers act before storage: a clear log level policy, dropping and filtering noise in the pipeline, deduplicating repetitive lines, turning counted events into metrics and shrinking payloads with structured logging.
- Retention tiers, PII masking and ownership with budgets or showback keep the savings from eroding, so log volume reduction becomes a habit instead of a one-off cleanup.
If you want to reduce log costs, the bill is the wrong place to start. Log management costs are the result of thousands of small decisions in code, frameworks and infrastructure: a debug level left on after an incident, a load balancer that logs every health check, an agent that ships the same file twice. Reducing logging costs therefore means finding those decisions, changing the ones that do not create value and putting guardrails in place so the volume does not grow back.
This guide focuses on logs only. If you want the broader view across traces, metrics and logs, read our article on reducing observability costs with a pipeline-first approach. Here we go deeper on log volume reduction: why volume explodes, how to measure it, which levers to pull in which order, an example OpenTelemetry Collector configuration, an illustrative before and after calculation and a checklist.
Why log volume explodes
Log volume rarely grows because of one big mistake. It grows because many sources each add a little, and nobody owns the total. These are the usual suspects:
- Debug logs in production. A level switched to DEBUG during an investigation and never switched back, or a library whose default level is more verbose than you expect.
- Verbose frameworks. ORMs that log every SQL statement, HTTP clients that log request and response bodies, dependency injection containers that log their wiring on every start.
- Health checks and access logs. Kubernetes probes, load balancer checks and uptime monitors hit endpoints every few seconds; each request can produce an access log line in the proxy, the ingress and the application.
- Duplicate shipping. The same container log collected by a node agent and a sidecar, or sent both to the platform and to a legacy system, or written to stdout and to a file that is also tailed.
- Stack traces. A recurring exception with a deep stack trace can be larger than all other logs of a service combined, especially in a retry loop.
- High-cardinality and bulky fields. Full request headers, serialized objects, tokens, large JSON payloads and unique IDs in every line increase bytes per record and make indexing and compression less effective.
- Multiline problems. If multiline messages are not joined at collection time, one stack trace becomes dozens of records, each with its own metadata overhead.
Most log management costs scale with ingested bytes, stored bytes, retention or a combination of these, depending on your platform. Every lever below reduces at least one of them.
Step 1: measure volume per service, level and source
You cannot reduce what you cannot see. Before you change anything, build a breakdown of log volume along three dimensions:
- Service: the
service.nameresource attribute, or namespace and workload in Kubernetes. - Level:
severity_textorseverity_numberin the OpenTelemetry log data model. - Source: application logs, access logs, proxy and ingress logs, system logs, audit logs.
Measure both record count and bytes. A service can emit few records but very large ones (stack traces, payload dumps), or many tiny ones (access logs). Then look at the top entries and, for each, at the most frequent message patterns. Grouping by a normalized message template, with numbers and IDs replaced by placeholders, typically reveals a handful of patterns that make up a large share of the volume. The goal is a short list of concrete candidates with a named owner, not a perfect model.
Tip: Ask one question for each top pattern: "Has anyone opened this log line during an incident or an investigation?" If the honest answer is no, it is a candidate for dropping, sampling or converting into a metric.
Step 2: agree on a log level policy
A written log level policy is the cheapest lever, because it prevents volume instead of filtering it later. Keep it short and specific. A starting point:
| Level | Use for | In production |
|---|---|---|
| ERROR | A request or job failed and someone may need to act | Always on, never sampled |
| WARN | Something unexpected that the system handled, such as a retry or fallback | On, deduplicate if repetitive |
| INFO | Business-relevant state changes: order placed, deployment started, job finished | On, but not per request for high-traffic paths |
| DEBUG | Details for developers while diagnosing | Off by default; enable temporarily per service with an expiry |
| TRACE | Very fine-grained flow | Off |
Two rules make the policy stick: debug logging in production needs an expiry date (for example via a feature flag or a dynamic log level that resets automatically), and "per request" logging on hot paths belongs in traces, not in INFO logs. Our glossary entry on log levels explains the levels in more detail.
Step 3: sample and deduplicate repetitive logs
Some logs are useful in principle but useless in their thousandth repetition. A connection warning that fires 500 times per minute carries the same information as one line with a count.
- Deduplication collapses identical records within a time window into one record with a counter. The OpenTelemetry Collector Contrib distribution includes a
logdedupprocessor for this; check its stability level and options for your collector version. - Sampling keeps a share of low-value, high-volume logs such as successful access logs. The
probabilistic_samplerprocessor supports logs. Never sample ERROR logs or audit and security logs. - Rate limiting at the source in the logging library (for example "log this warning at most once per minute") prevents the volume from being created at all.
When you sample, keep the information you need for rates. Either record the sampling rate on the record, or derive counts as metrics before sampling, as described in step 5.
Step 4: drop and filter noise in the pipeline
Changing code takes time. A telemetry pipeline gives you an immediate, central lever: drop records that have no consumer, remove bulky attributes and truncate oversized values before data is sent and stored. The following OpenTelemetry Collector configuration shows the idea. It is an example; adapt routes, attribute names and limits to your environment, and check the OTTL functions available in your collector version.
# example: reduce log volume in the OpenTelemetry Collector
processors:
filter/drop-log-noise:
error_mode: ignore
logs:
log_record:
# drop DEBUG and TRACE in production
- 'severity_number < SEVERITY_NUMBER_INFO'
# drop successful health and readiness checks
- 'IsMatch(attributes["url.path"], "^/(healthz|readyz|livez)$") and attributes["http.response.status_code"] < 400'
# drop a known noisy library logger
- 'instrumentation_scope.name == "org.hibernate.SQL"'
transform/shrink-logs:
error_mode: ignore
log_statements:
- context: log
statements:
# remove bulky or sensitive attributes
- delete_key(attributes, "http.request.header.cookie")
- delete_key(attributes, "http.request.body")
# cap the length of all string attributes (example value: 2048)
- truncate_all(attributes, 2048)
logdedup:
interval: 60s
log_count_attribute: log_count
batch: {}
service:
pipelines:
logs:
receivers: [otlp, filelog]
processors: [filter/drop-log-noise, transform/shrink-logs, logdedup, batch]
exporters: [otlphttp]
Order matters: filter first so later processors do less work, then shrink, then deduplicate. Roll out new drop rules gradually, for example per environment, and keep a short list of what was dropped and why, so nobody searches for logs that no longer exist. For production advice on running the collector itself, see our OpenTelemetry Collector best practices.
Step 5: turn counted events into metrics
Many log lines are only ever counted: "payment declined", "cache miss", "rate limit hit". If nobody reads the individual line, a metric is the better, much cheaper representation. A counter with a few low-cardinality attributes replaces thousands of records per minute, and it is faster to query and alert on.
In the OpenTelemetry Collector, the count connector derives such metrics from logs. The example counts declined payments per provider before the logs themselves are sampled or dropped:
# example: derive a metric from logs with the count connector
connectors:
count:
logs:
checkout.payments.declined:
description: Declined payments, counted from logs
conditions:
- 'attributes["event.name"] == "payment.declined"'
attributes:
- key: payment.provider
service:
pipelines:
logs/in:
receivers: [otlp]
exporters: [count]
metrics/from-logs:
receivers: [count]
exporters: [otlphttp]
Keep the attributes of such metrics low in cardinality; a user ID as a metric attribute just moves the cost problem. Our article on high-cardinality labels explains why.
Step 6: shrink payloads with structured logging
Structured logs are not only easier to query, they are usually smaller per useful bit of information. Instead of repeating long free-text sentences, you log a stable event name and a few typed fields. Practical rules:
- Use a stable
event.nameand short, consistent attribute keys instead of prose that varies per call site. - Put shared context (service, version, environment, Kubernetes metadata) into resource attributes once instead of into every message.
- Log identifiers, not whole objects. A
trace_idlinks to the full request; there is no need to dump the request into the log. - Log a stack trace once per error, not on every layer that catches and rethrows it, and join multiline messages at collection time.
Our guide to structured logging best practices covers schema and field naming in detail.
Step 7: use retention tiers
Not every log needs to be hot and fully queryable for months. Split logs by purpose and assign retention per tier:
| Tier | Typical content | Example retention (illustrative) |
|---|---|---|
| Hot | Application and error logs for debugging and incidents | Example: 7 to 30 days |
| Warm | Logs needed for trend analysis and occasional investigations | Example: 30 to 90 days |
| Archive | Audit and security logs with legal or contractual retention requirements | As required by your obligations |
| Not stored | Debug noise, successful health checks, duplicates | Dropped in the pipeline |
The right periods depend on your legal, contractual and operational requirements, not on defaults. Document them per data type, so retention is a deliberate decision rather than whatever the platform default happens to be. See our glossary entry on retention.
A side benefit: PII masking
When you go through your logs to reduce volume, you will find personal data and secrets that should not be there: email addresses, IP addresses, tokens, session cookies. Masking or removing them in the same pipeline step reduces bytes and lowers compliance risk under the GDPR at the same time. Treat it as part of the same project: one review, two benefits. More in our glossary entry on PII masking.
Step 8: ownership, budgets and showback
Without ownership, log volume grows back within months. Three mechanisms keep it under control:
- Ownership: every service has a team that owns its log volume, visible via
service.nameand a team attribute. - Budgets: each team gets a volume budget per day or month, with an alert when it is close to the limit. The budget is a conversation starter, not a hard wall that drops logs during an incident.
- Showback: a regular report of volume and cost per team and service. Visibility alone often changes behaviour, because most noisy logs exist simply because nobody noticed them.
Add a check to code review or CI for new log statements on hot paths, and review the top volume patterns monthly.
Illustrative before and after calculation
The following calculation shows how the levers add up. All numbers are illustrative example values for a fictitious environment, not a benchmark or a promise of savings. Your distribution will differ, which is why step 1 matters.
| Step | Assumption (example value) | Daily volume afterwards |
|---|---|---|
| Starting point | 100 GB of logs per day | 100 GB |
| Drop DEBUG and TRACE in production | 30 GB were debug logs | 70 GB |
| Drop successful health checks | 15 GB were health and readiness checks | 55 GB |
| Deduplicate repetitive warnings | 10 GB of repetitive warnings collapse to 1 GB | 46 GB |
| Shrink payloads, remove bulky attributes | 10 % of the remaining bytes | about 41 GB |
| Move audit logs to an archive tier | 3 GB per day kept in archive instead of hot | about 38 GB hot, 3 GB archive |
In this fictitious example, hot log volume drops from 100 GB to about 38 GB per day, while every error log, every audit log and every business event is still available. To estimate the effect on your bill, multiply the bytes before and after by the pricing dimensions of your platform (ingest, storage, retention).
Frequently asked questions
Why are logs so expensive?
Because volume grows with traffic, number of services and verbosity at the same time, and because costs typically depend on bytes ingested and stored over the retention period. Logs are also the signal with the least built-in aggregation: every event is kept individually.
Will I lose visibility if I drop logs?
Not if you drop by value. Errors, audit logs and business events stay; what goes is noise that nobody reads. Traces and metrics often cover what per-request logs used to do, with less volume.
Should I filter at the source or in the pipeline?
Both. The pipeline gives you a fast, central lever; the source (log levels, library settings) prevents volume from being generated and transferred at all. Use the pipeline for quick wins and as a safety net, and fix the biggest sources in code.
Checklist: reduce log costs
Copy this checklist into your next cost review
- Log volume measured in records and bytes per service, level and source
- Top message patterns identified, each with an owner
- Written log level policy; DEBUG in production only with an expiry
- Successful health checks, readiness probes and duplicate shipping removed
- Repetitive logs deduplicated or rate limited, ERROR and audit logs never sampled
- Counted events converted into metrics with low-cardinality attributes
- Bulky attributes removed, string lengths capped, multiline messages joined
- Structured logging with stable event names and resource attributes
- Retention tiers documented per data type
- PII and secrets masked in the pipeline
- Volume budgets and a monthly showback report per team
How Obseria helps
Obseria is an OpenTelemetry-native observability platform, so your existing collectors and SDKs keep working. Obseria Pipeline applies filtering, PII masking, sampling and routing before storage, which means you decide what to keep before it becomes cost. Obseria Lake stores the remaining logs index-free together with traces and metrics, and log analytics helps you find the services and patterns that drive volume.
- Usage-based pricing per signal: every gigabyte you drop in the pipeline is a gigabyte you do not pay to store.
- Unlimited users, so showback reports and dashboards can be shared with every team.
- EU data residency and PII masking for GDPR-aware logging.
Want to see where your log volume comes from? Start the 14-day free trial or book a demo.