Logging
Kubernetes
OpenTelemetry

Kubernetes Logging Cost: Log Levels, Retention and the Bill

Log bills grow quietly: one chatty sidecar, one debug flag left on, one retention period nobody chose. Here is how to find where the volume comes from, which levels to run in production, how to drop and deduplicate in the collector before anything is billed, and how long each kind of log is worth keeping.

13 min read
Dmytro Vavreniuk

Dmytro Vavreniuk

Product Engineer

Short version: Kubernetes logging cost is driven by volume × retention × price per GB, and the first factor is the one you control. Measure bytes per namespace and container, run INFO in production with time-limited DEBUG, and drop probe and debug lines and deduplicate repeats in your own collector before data reaches a paid backend. Then give each log type its own retention: days for debug and dev, two weeks for info, a month for errors, a year only for audit logs. Teams that do this often cut the bill by half or more without losing anything they actually read.

Our original guide on what to collect and what to ignore in Kubernetes logging answers which logs matter. This one is about the money: how much those logs cost, which levers move the number, and the configs to pull them. It builds on our structured logging best practices, because every cost technique below is easier when logs are JSON with a real severity field.

Why this is a 2026 problem

Feb 2026
Grafana Cloud splits log pricing into three stages: $0.05/GB processed, $0.40/GB written and $0.10/GB retained (beyond the included 30 days), replacing a flat $0.50/GB ingest price. What you drop before the write stage is now visibly cheaper than what you store.
2 Mar 2026
Promtail reaches end of life. Grafana Alloy (or the OpenTelemetry Collector) is the supported way to ship Kubernetes logs to Loki, so many clusters are rebuilding their log pipeline this year anyway, which is the cheapest moment to add filtering.
24 Mar 2026
Fluent Bit 5.0 ships with OTLP ingest up to 4x faster than 4.2, a counter for lines skipped by the tail input and better record accounting for S3 output. The 5.x line has had regular releases since.
22 Apr 2026
Kubernetes 1.36 makes Node Log Query stable: with enableSystemLogQuery in the kubelet config you can read kubelet and other node service logs through the API server instead of shipping all of them to a backend just in case.
May 2026
The OpenTelemetry Collector gets a drain processor (alpha, otelcol-contrib v0.151.0+) that tags each log with a template, so repeated messages with different IDs can be counted and deduplicated. The OpenTelemetry blog walks through the log deduplication processor for the same reason.
9 - 12 Nov 2026
At KubeCon NA in Salt Lake City, sessions on filtering and routing with OTTL and on sampling “to reduce overhead and telemetry costs” filled the observability track. Log cost has become a pipeline design problem, not a vendor negotiation.

The common thread: pricing now separates processing from storage, and the open-source pipeline (Fluent Bit, the OpenTelemetry Collector, Alloy) has the processors to reduce volume at the edge. If you are migrating off Promtail this year, you are already touching the one place where reduction is cheapest.

Step 1: measure where the bytes come from

In almost every cluster we have looked at, a handful of containers produce most of the volume: an ingress controller logging every request, a service mesh sidecar at debug, a job that prints a progress line per record, or an application logging full request bodies. You cannot set a sensible budget until you know who they are.

# 1. Which pods write the most to node disk right now? (any node, no agent needed)
kubectl debug node/<node-name> -it --image=busybox -- \
  sh -c 'du -sm /host/var/log/pods/* | sort -n | tail -15'

# 2. Bytes per namespace and container over 24h, in Loki (LogQL).
#    Label names depend on how you ship: OTLP into Loki uses k8s_namespace_name etc.
topk(15,
  sum by (k8s_namespace_name, k8s_container_name) (
    bytes_over_time({k8s_cluster_name="prod"}[24h])
  )
)

# 3. Same question, by level, to see how much is debug and info
sum by (detected_level) (bytes_over_time({k8s_cluster_name="prod"} [24h]))

The first command works on any node without a log backend: kubectl debug node/… mounts the host file system under /host, and /var/log/pods holds one directory per pod. The LogQL queries give the same answer across the cluster. Put the top 15 on a dashboard, give every line an owning team, and add an alert when a namespace’s daily bytes exceed 120% of its seven-day average. Most cost surprises are a deploy that turned on debug logging, and this catches them on day one instead of on the invoice.

Step 2: log levels that survive production

Log levels are the cheapest cost control there is, as long as they mean something. If every message is INFO, the level tells the pipeline nothing and you are left filtering by regex. Agree on a contract like this one and enforce it in code review:

LevelIn productionWhat belongs thereTypical retention
ERRORAlways onA request or job failed and someone may need to act. Include the error, the operation and IDs (trace_id, user or tenant).30 - 90 days
WARNAlways onSomething degraded but recovered: retries, fallbacks, slow dependencies, rejected input.30 days
INFOOn, but budgetedOne line per meaningful state change: request done (with status and duration), job started and finished, config loaded. Not one line per loop iteration.7 - 14 days
DEBUGOff; on demand per pod for minutesPayloads, branch decisions, cache hits. Useful while you are looking, expensive the rest of the time.1 - 3 days, if shipped at all
TRACENever in productionByte-level and per-iteration detail. Use spans and profiles instead.Not shipped

The expensive mistake is debug logging that is turned on for an incident and never turned off. Make the level changeable at runtime and give the change an expiry, so a redeploy is not needed to turn it on and forgetting cannot keep it on:

// Go: change the level at runtime without a redeploy
var level = new(slog.LevelVar) // defaults to INFO

func main() {
    if os.Getenv("LOG_LEVEL") == "debug" { level.Set(slog.LevelDebug) }
    logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: level}))
    slog.SetDefault(logger)

    // Internal-only endpoint: POST /admin/loglevel?level=debug&ttl=15m
    http.HandleFunc("/admin/loglevel", func(w http.ResponseWriter, r *http.Request) {
        var l slog.Level
        if err := l.UnmarshalText([]byte(r.URL.Query().Get("level"))); err != nil {
            http.Error(w, "bad level", 400); return
        }
        level.Set(l)
        ttl, _ := time.ParseDuration(r.URL.Query().Get("ttl"))
        if ttl == 0 { ttl = 15 * time.Minute }
        time.AfterFunc(ttl, func() { level.Set(slog.LevelInfo) }) // debug never stays on by accident
    })
    // ...
}

The same idea works in Node with pino (logger.level = 'debug') and in Python with logging.getLogger().setLevel(). In Kubernetes, expose the endpoint only on an internal port and call it through kubectl port-forward on the one pod you are investigating, so debug output comes from one replica, not fifty.

Step 3: drop, deduplicate and trim in the collector

The cheapest log is the one that never leaves the node. Whatever your backend, its pricing starts at the moment data arrives: Grafana Cloud bills processed bytes before its own Adaptive Logs optimisation, Datadog bills ingestion before indexing, and CloudWatch bills every byte a pod writes to it. Reduction in your own DaemonSet costs only a little CPU. This is the OpenTelemetry Collector configuration we start from:

# OpenTelemetry Collector (DaemonSet) - drop, dedupe and trim before anything is billed
receivers:
  filelog:
    include: [/var/log/pods/*/*/*.log]
    exclude: [/var/log/pods/*/otel-collector*/*.log]   # do not ship your own logs in a loop
    include_file_path: true
    operators:
      - type: container            # parses CRI format and k8s metadata from the path

processors:
  memory_limiter:
    check_interval: 1s
    limit_percentage: 80
    spike_limit_percentage: 20

  k8sattributes:
    extract:
      metadata: [k8s.namespace.name, k8s.deployment.name, k8s.pod.name, k8s.container.name]

  # 1. Drop what nobody reads. Logs with no parsed severity are kept on purpose.
  filter/noise:
    error_mode: ignore
    logs:
      log_record:
        - severity_number > SEVERITY_NUMBER_UNSPECIFIED and severity_number < SEVERITY_NUMBER_INFO
        - IsMatch(body, "\\s/(healthz|readyz|livez|metrics)\\s") and severity_number < SEVERITY_NUMBER_WARN
        - resource.attributes["k8s.namespace.name"] == "kube-system" and severity_number < SEVERITY_NUMBER_WARN

  # 2. Collapse identical lines into one record with a count
  logdedup:
    interval: 10s
    log_count_attribute: log_count
    exclude_fields:
      - attributes.request_id
      - attributes.timestamp

  # 3. Cap pathological lines (stack dumps of request bodies, base64 blobs)
  transform/trim:
    error_mode: ignore
    log_statements:
      - context: log
        statements:
          - set(body, Substring(body, 0, 8192)) where IsString(body) and Len(body) > 8192

exporters:
  otlphttp/logs:
    endpoint: https://logs.example.com/otlp
    sending_queue:
      enabled: true

service:
  pipelines:
    logs:
      receivers: [filelog]
      processors: [memory_limiter, k8sattributes, filter/noise, logdedup, transform/trim]
      exporters: [otlphttp/logs]
  • filter/noise drops debug and trace lines, successful probe and metrics-scrape lines, and anything below WARN from kube-system. Logs with no parsed severity are kept, so a service that prints plain text is not silently lost.
  • logdedup collapses identical records within a 10-second window into one record with a log_count attribute, ignoring fields such as request IDs that make otherwise identical lines unique. A connection-refused error repeated 3,000 times during an outage becomes a few hundred records that still show the rate.
  • transform/trim caps the body at 8 KB. One service dumping full request payloads can cost more than the rest of the namespace together.
  • For messages that differ only in variable parts (user 1234 logged in), the new drain processor can derive a template attribute first, and logdedup can then deduplicate on that template. It is alpha, so try it on one pipeline before rolling it out.

With Fluent Bit the same steps are a grep filter on the level field, a throttle filter for floods and a modify or Lua filter for truncation. Keep an eye on the counter Fluent Bit 5.0 added for lines skipped by the tail input: if a pod rotates its log file faster than the agent reads it, you are losing data, and cutting volume fixes that as well.

What not to drop: errors, anything with a trace_id that belongs to a failed request, authentication and authorisation events, and logs from jobs that run rarely. If you want to keep a sample of successful requests, do it deliberately (for example one in 100 INFO request lines per route) and record the rate in an attribute so dashboards can multiply it back.

Step 4: retention per log type, not one number for everything

Most clusters keep every log for the backend’s default, usually 30 days, because nobody decided otherwise. Retention should follow how long each kind of log is actually used:

Log typeHot (searchable)ArchiveWhy
Application debug / dev and preview namespaces1 - 3 daysNoneOnly useful while someone is actively debugging
Application info7 - 14 daysOptional, 30 - 90 days compressedMost incidents are investigated within a week
Application warn and error30 days90 days - 1 yearTrend analysis and slow-burning bugs
Ingress and access logs7 days90 days (security)Turn into metrics (rate, latency, status) and keep the raw lines short
Kubernetes audit logs30 - 90 days1 year or what your framework requiresSecurity investigations; PCI DSS, for example, asks for 12 months with 3 immediately available
Control plane and node (kubelet, containerd)3 - 7 days, or query on the nodeNoneNode Log Query covers most ad-hoc needs

In Loki, per-stream retention does this with label selectors; the compactor applies it. Retention is per stream, so it works on labels such as namespace, not on fields inside the line; that is one more reason to route by namespace and keep levels meaningful.

# Loki: one default, shorter or longer periods per stream selector
limits_config:
  retention_period: 720h            # 30 days for everything not matched below
  retention_stream:
    - selector: '{k8s_namespace_name=~"dev-.*|preview-.*"}'
      priority: 1
      period: 72h                   # 3 days for dev and preview environments
    - selector: '{k8s_namespace_name="ingress-nginx"}'
      priority: 2
      period: 168h                  # 7 days for access logs (metrics cover the rest)
    - selector: '{k8s_namespace_name="payments"}'
      priority: 3
      period: 8760h                 # 1 year where an auditor will ask

compactor:
  retention_enabled: true
  delete_request_store: s3          # required when retention is enabled

On Google Cloud the equivalent is separate log buckets with their own retention plus sinks that route by namespace; on CloudWatch it is one log group per namespace or tier with its own retention setting, and the Infrequent Access class at half the ingest price for logs you rarely query. For long archives, object storage is the cheapest tier everywhere: write compressed files to S3 or GCS with a lifecycle rule and query them only when an investigation needs it.

Step 5: the node side (kubelet rotation and node logs)

The kubelet rotates container logs when a file reaches containerLogMaxSize and keeps containerLogMaxFiles of them. With the defaults (10 MiB and 5 files) a very chatty container keeps only 50 MiB on the node, which can be a few minutes of output. That is fine as long as the agent keeps up; it is a problem when the backend is slow and the agent falls behind. Size rotation for your busiest workloads rather than treating it as retention:

# KubeletConfiguration - node-local buffer, not a retention policy
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
containerLogMaxSize: 50Mi          # default 10Mi per file
containerLogMaxFiles: 3            # default 5 files per container
containerLogMaxWorkers: 2          # default 1; parallel rotation on busy nodes
containerLogMonitorInterval: 10s   # default 10s
enableSystemLogQuery: true         # Node Log Query (stable in 1.36) for kubelet/journal logs

The last line is the 2026 addition. With Node Log Query stable in Kubernetes 1.36, you can read kubelet and container runtime logs on demand with kubectl get --raw "/api/v1/nodes/<node>/proxy/logs/?query=kubelet". For many teams that is enough reason to stop shipping all node service logs to a paid backend and keep only warnings and errors from them.

Step 6: audit logs without the flood

Kubernetes audit logs are the one category where long retention is usually required, and with a permissive policy they are also one of the largest. Most of the volume is controllers and nodes reading state through get, list and watch calls, which no investigation needs. A policy like this keeps every change made by a person or a pipeline and drops the read-only system traffic:

# Kubernetes audit policy - keep who changed what, drop the read-only flood
apiVersion: audit.k8s.io/v1
kind: Policy
omitStages: ["RequestReceived"]
rules:
  # Health checks and the API server's own noise
  - level: None
    nonResourceURLs: ["/healthz*", "/readyz*", "/livez*", "/version", "/metrics"]
  # Controllers and nodes reading state all day long
  - level: None
    users: ["system:kube-proxy", "system:kube-scheduler", "system:kube-controller-manager"]
    verbs: ["get", "list", "watch"]
  - level: None
    userGroups: ["system:nodes"]
    verbs: ["get", "list", "watch"]
  # Never log secret or token payloads, only who touched them
  - level: Metadata
    resources:
      - group: ""
        resources: ["secrets", "configmaps", "serviceaccounts/token"]
  # Changes by people and CI: full request body
  - level: Request
    verbs: ["create", "update", "patch", "delete"]
  # Everything else
  - level: Metadata

Rules are evaluated in order and the first match wins, so put the None rules first. Logging secrets at Metadata keeps their content out of the audit log while still recording who read or changed them. On managed clusters (EKS, GKE, AKS) the provider sets the policy; there the lever is which audit log types you enable and how long you keep them.

What it costs: a worked example

Take a production cluster that writes 600 GB of logs a month (about 20 GB a day, or roughly 1.2 billion events at 500 bytes each). Assume the steps above remove 60% of that volume, leaving 240 GB. Using list prices on vendor pages as of 2 December 2026, US regions, 30-day retention and no committed-use discounts:

BackendPricing model600 GB/month240 GB/month
Google Cloud Logging$0.50/GiB ingested after 50 GiB free per project; 30 days included; $0.01/GiB-month beyond≈ $275≈ $95
AWS CloudWatch Logs (Standard)$0.50/GB ingested ($0.25 for Infrequent Access); storage billed separately per GB-month≈ $300 + storage≈ $120 + storage
Grafana Cloud Logs (Pro)$19/month platform, $0.05/GB processed, $0.40/GB written after 50 GB, 30 days retention included≈ $269≈ $107 (filtered in your collector) / ≈ $125 (filtered inside Grafana)
Datadog Log Management$0.10/GB ingested, plus $1.70 per million events indexed for 15 days (annual billing)≈ $2,100 if everything is indexed≈ $840

Sources: Google Cloud Observability pricing, Amazon CloudWatch pricing, Grafana Cloud pricing and Datadog log management pricing. Three things stand out. First, at the same volume the three per-GB backends land within about 10% of each other, so reducing volume beats switching vendors. Second, where you drop matters on stage-priced backends: in the Grafana row, filtering in your collector saves the processing fee on the dropped 360 GB too. Third, on Datadog the per-event indexing fee is the bill; ingesting everything (cheap) but indexing only warnings, errors and a sample of info lines is the standard way to keep it in check, with the rest available from archive if needed.

Self-hosted Loki or OpenSearch replaces the per-GB fee with compute, object storage and the time of whoever runs it. The volume levers are exactly the same: fewer bytes mean smaller ingesters, smaller indexes and cheaper storage.

Spend the savings on context, not on more lines

Cutting log volume is not the goal in itself; finding problems faster is. The best logs are the ones you can connect to everything else: a trace_id that links a backend error to its trace, and a session.id that links it to what the user was doing. Our guide on connecting frontend sessions to backend logs with the OpenTelemetry session.id shows the wiring. With that in place, a single ERROR line plus the session replay of the user who hit it tells you more than a thousand INFO lines around it, and an AI agent debugging production reads fewer, better logs faster and for fewer tokens.

Kubernetes logging cost checklist

ItemDone when
MeasureTop 15 containers by bytes per day are known, and each one has an owner
LevelsINFO by default in production, DEBUG only per pod with an automatic time limit, no TRACE
FormatJSON logs with severity, trace_id and k8s metadata so the collector can filter by field, not by regex
CollectorDebug, probe and metrics-scrape lines dropped; identical lines deduplicated; body length capped
RetentionDifferent periods per namespace or log type; dev and preview at 3 days or less
AuditAudit policy drops read-only system traffic and logs secrets at Metadata only
NodeKubelet rotation sized for the busiest pods; skipped-line counters from the agent alert
BudgetDaily ingest per namespace on a dashboard with an alert at 120% of the 7-day average

Frequently asked questions

How much does logging cost in Kubernetes?

It scales with volume, not cluster size. As a rule of thumb, managed backends charge around $0.40 to $0.50 per GB ingested or written in late 2026 (Google Cloud Logging and CloudWatch at $0.50, Grafana Cloud at $0.05 processed plus $0.40 written), while Datadog charges $0.10 per GB ingested plus a per-event indexing fee that usually dominates. A cluster producing 600 GB of logs a month typically pays roughly $270 to $300 a month on the first three and over $2,000 on Datadog if everything is indexed for 15 days.

What log level should production Kubernetes workloads use?

INFO for most services, with WARN and ERROR always on. Turn DEBUG on per pod or per deployment for a limited time when you investigate something, and make sure it switches itself back off. TRACE does not belong in production logs; use traces and profiles for that level of detail.

How long should Kubernetes logs be retained?

Keep debug and development logs for 1 to 3 days, application info logs for 7 to 14 days, warnings and errors for about 30 days hot, and audit logs for as long as your security or compliance framework requires, often a year. Use per-stream or per-bucket retention rather than one period for everything.

Does the kubelet delete container logs?

Yes. The kubelet rotates container log files on the node when they reach containerLogMaxSize (10 MiB by default) and keeps containerLogMaxFiles of them (5 by default). That is a buffer for your log agent, not retention. Anything you need after a pod is gone or the file rotates must be shipped off the node.

What is the cheapest way to reduce Kubernetes log volume?

Drop and deduplicate in your own collector before data reaches a paid backend. Filtering debug lines, health and readiness probe logs and repeated messages commonly removes half or more of the volume. Vendor-side tools such as Grafana Adaptive Logs help too, but data dropped there may still count as processed.

Should I use Fluent Bit, Grafana Alloy or the OpenTelemetry Collector?

All three can tail container logs, add Kubernetes metadata and filter before export. Fluent Bit is the lightest and very mature; Alloy is the replacement for Promtail if you send to Loki; the OpenTelemetry Collector is the most neutral choice and has processors such as filter, logdedup and drain for cost control. Pick the one your team already runs for metrics or traces.

Further reading

Fewer logs, more context. Try LogNroll for free and see the user session behind every error your cluster logs.