Pcornel
Browse topics
Options
Recent
Favorites
Observability · Technical reference

Log Levels and Retention

Direct answer

Log levels (DEBUG, INFO, WARN, ERROR, FATAL) mark severity; retention decides how long logs are kept, often by level, source and compliance requirements.

When to use this

Use it to control log volume and cost.

First 30 seconds

1. Volume by level, e.g. LogQL sum by (level)(count_over_time({app="api"}[1h])).

2. DEBUG enabled in production?

3. Retention per stream/index.

4. Compliance requirements.

5. Adjust.

Operational verification

event severity → level → retention policy → deletion

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
OpenTelemetry / Prometheus / Grafana / common metrics-log-trace pipelines
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformOpenTelemetry / Prometheus / Grafana / common metrics-log-trace pipelines
Scope / prerequisiteUse it to control log volume and cost.
What next?2 suggested next steps
Evidence0
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 How to verify Verify boundary

Search for a week-old event and confirm it is still available. Alert on sudden changes in error log volume.

Step 2 Common failures Narrow the fault

Logging every request at info on a busy service creates huge volume. Errors logged as info are never noticed. Short retention loses the evidence needed for slow-burning incidents.

Key points

Production at INFO; enable DEBUG temporarily. ERROR should mean someone may need to act. Retain security/audit logs longer than debug logs, and delete personal data per policy.

Key checks
  • sum by (level)(count_over_time({app="api"}[1h])) — first check for this topic
  • curl -s localhost:9090/-/ready — Prometheus ready
  • curl -s 'localhost:9090/api/v1/query?query=up' — scrape targets up/down
  • promtool check config prometheus.yml — config valid
ReferenceWhat it is1 section · depth on demand

How it works

Log platforms charge or scale by ingest volume and retention. Hot storage keeps recent logs fast; cold or archive tiers keep older logs cheaply.

ReferenceImportant terms & boundaries3 sections · depth on demand

Levels and retention

LevelUse
DEBUGDeveloper detail; off in production by default
INFONormal significant events
WARNUnexpected but handled
ERRORFailed operation needing attention
FATALProcess cannot continue

Retention example: 7–14 days hot (searchable), 90 days warm, 1 year+ archive for security logs (check legal requirements, NIS2/GDPR). Make log levels changeable at runtime to debug without redeploys.

In depth

Choosing levels by who acts on them

LevelSomeone should…Typical volume
ERRORLook at it — something failed for a user or a jobLow; alert on rate
WARNBe able to find it — degraded, retried, fell backLow–medium
INFOUnderstand the flow afterwards — one line per significant event, not per loop iterationMedium
DEBUG/TRACEDiagnose a specific problem, switched on temporarilyHigh

An error that is expected and handled (a user typing a wrong password) is INFO or WARN; logging it as ERROR teaches everyone to ignore errors.

Changing level without redeploying

Make the level configurable per logger or module at runtime (environment variable reread, admin endpoint, feature flag) so DEBUG can be enabled for one component for 15 minutes during an incident and switched off again.

Retention by purpose

DataTypical retentionStorage
Application debug/info7–30 daysHot, searchable
Errors and warnings30–90 daysHot or warm
Security and audit logs1 year or more (per policy and law)Cold/archive, immutable
Access logs with personal dataAs short as the purpose allows (GDPR)—

In Loki, retention is applied by the compactor (retention_enabled: true) with a global retention_period and per-stream overrides:

limits_config:
  retention_period: 744h            # 31 days default
  retention_stream:
  - selector: '{namespace="security"}'
    priority: 1
    period: 8760h                    # 1 year

Controlling volume

Sample or drop noisy lines in the collector (health-check access logs, repetitive debug), and track ingest volume per service so a logging bug in one release shows up as a cost spike the same day, not on the monthly bill.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Common mistakes

  • DEBUG level in production.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
log levels and retentionlog levelslog retention
Confirmation

Confirm action

Continue?