Pcornel
Browse topics
Options
Recent
Favorites
Observability · Technical reference

Log Parsing and Enrichment

Direct answer

Log parsing extracts fields from raw lines (JSON, logfmt, regex, grok) and enrichment adds context (Kubernetes metadata, host, environment, GeoIP) in agents or pipelines.

When to use this

Use it when logs need structure for search and correlation.

First 30 seconds

1. Test a parser on a sample, e.g. Fluent Bit fluent-bit -c fluent-bit.conf --dry-run / Vector vector test.

2. Fields present in the backend.

3. Parse failures counted?

4. Enrichment labels (namespace, pod).

5. Original message kept.

Operational verification

raw line → parser → fields → enrichment → indexed

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 when logs need structure for search and correlation.
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 field from a parsed line in the backend. Watch parse failure rates after application releases.

Step 2 Common failures Narrow the fault

A format change in the application breaks regex parsers silently. Using ingestion time instead of event time misorders logs. Enrichment that calls the Kubernetes API for every line overloads it without caching.

Key points

Parse as early as practical but keep the original message. Test parsers against real samples. Add Kubernetes metadata via the agent.

Key checks
  • fluent-bit -c fluent-bit.conf --dry-run — 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

Agents such as Fluent Bit, Vector, Promtail or the OpenTelemetry collector read files or streams, apply parsers and filters, and forward records. Kubernetes filters query the API for Pod metadata.

ReferenceImportant terms & boundaries3 sections · depth on demand

Parsing example (Fluent Bit)

[PARSER]
    Name   nginx
    Format regex
    Regex  ^(?<remote>[^ ]*) - (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+) (?<path>[^"]*?) HTTP/[^"]*" (?<code>\d{3}) (?<size>\d+)
    Time_Key time
    Time_Format %d/%b/%Y:%H:%M:%S %z

[FILTER]
    Name kubernetes
    Match kube.*

Documented example, not captured output. Parse as early as possible, add environment/host/Kubernetes metadata, redact secrets and personal data, and keep the original message for evidence when needed.

In depth

Parse once, at ingest

Turning 10.0.4.17 - - [27/Nov/2026:09:14:03 +0100] "GET /cart HTTP/1.1" 502 157 0.812 into fields at ingest means every later query can filter status = 502 cheaply; parsing at query time repeats the work on every search.

Prefer structured sources over regex

SourceApproach
Your own servicesLog JSON (no parsing needed)
Nginx/ApacheConfigure a JSON log_format, or use the agent's built-in parser
Kubernetes container logsCRI/docker parser first (strips the runtime prefix), then the app format
Legacy text formatsRegex or pattern parser, with tests

Multi-line events

Java and Python stack traces span many lines. Join them at the agent with a multi-line parser (start pattern = line beginning with a timestamp; continuation = lines starting with whitespace, at , Caused by:), or better, emit them as a single JSON field.

Enrichment that is worth it

EnrichmentSource
Kubernetes namespace, pod, container, labelsKubernetes filter / k8sattributes
Host, region, environmentAgent configuration
GeoIP for client IPGeoIP database (check privacy requirements)
Service owner/teamLookup table keyed by service name

Event time

Map the parsed timestamp to the record's time (Time_Key / Time_Format in Fluent Bit, timestamp in OpenTelemetry). If parsing the time fails, many agents fall back to ingestion time silently and logs appear out of order after a backlog.

Watching for breakage

Application releases change log formats. Count parse failures and alert on a sudden rise:

rate(fluentbit_filter_drop_records_total[5m]) > 0

Route unparseable lines to a separate stream (or keep the raw line in a field) instead of dropping them, so a format change loses structure but not data.

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

Common mistakes

  • Parsing at query time for every query instead of at ingest.
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 parsing and enrichmentlog parsing pipelinefluent bit vector enrichment
Confirmation

Confirm action

Continue?