Glossary · L

Log Parsing

Extracting structured fields such as timestamp, severity, status code or user ID from raw log lines, so logs can be searched, aggregated and analyzed reliably.

By Obseria TeamUpdated

Definition

Log parsing is the process of turning raw, often unstructured log lines into structured records with named fields. A parser recognizes the format of a line, for example JSON, key=value pairs or a fixed text pattern, and extracts values such as timestamp, severity, message and context attributes. Parsing can happen when logs are collected, in a telemetry pipeline before storage, or at query time, and it is the basis for filtering, aggregating and alerting on log data.

What is log parsing?

Many applications, proxies and operating system components still write logs as plain text. A typical NGINX access log line looks like this:

203.0.113.7 - - [05/Nov/2026:09:14:03 +0000] "GET /api/cart HTTP/1.1" 502 157 "-" "Mozilla/5.0"

For a human the meaning is clear, for a query engine it is just a string. Log parsing extracts the parts into fields such as client.address, http.request.method, url.path, http.response.status_code and a proper timestamp. Only then can you count 502 responses per path, build dashboards or alert on error rates. Applications that already emit structured logs need far less parsing, but third party components rarely give you that choice.

Common parsing methods

  • JSON parsing: the simplest and most robust case. Each line is a JSON object, and fields are taken over directly.
  • Key value parsing: lines like level=error user=42 duration_ms=870 are split on delimiters.
  • Regular expressions: named capture groups extract fields from fixed text formats. Flexible, but they can become hard to maintain and are relatively expensive at high volume.
  • Grok patterns: a library of named, reusable regex building blocks known from Logstash, for example %{IPORHOST:client} %{WORD:method}.
  • Dissect or delimiter parsing: splits a line by fixed separators without regex, which is faster for strictly positional formats.

As an illustration, a regex for the beginning of the access log line above could be:

^(?P<client>\S+) \S+ \S+ \[(?P<time>[^\]]+)\] "(?P<method>\S+) (?P<path>\S+)[^"]*" (?P<status>\d{3})

Timestamps, severity and multiline logs

Three details decide whether parsed logs are trustworthy:

  • Timestamps: the event time should be taken from the line itself, with the correct format and time zone. Otherwise the ingestion time is used, and events appear out of order.
  • Severity: text values such as WARN, warning or numeric syslog levels should be mapped to a consistent log level, in OpenTelemetry to SeverityText and SeverityNumber.
  • Multiline entries: a Java stack trace spans many lines that belong to one event. A multiline rule, typically a pattern that recognizes the start of a new entry, joins them before parsing.

Where parsing happens

There are three places to parse logs, each with trade-offs:

  • At collection: agents such as the OpenTelemetry Collector with its filelog receiver use operators like json_parser, regex_parser or key_value_parser and can parse container runtime formats directly.
  • In a pipeline before storage: a central telemetry pipeline parses, enriches and filters logs from many sources consistently. This is also the right place for PII masking, because extracted fields can be masked precisely.
  • At query time: schema-on-read systems store the raw line and extract fields when a query runs. This keeps you flexible for formats you did not anticipate, but costs compute on every query.

In practice teams combine them: well known formats are parsed early, rare or new ones at query time.

Pitfalls and best practices

  • Keep the raw line or at least the original message when parsing fails, so no information is lost. Count parse failures as a metric.
  • Expect format changes: a new log field or a library upgrade can break a regex silently. Test parsers against sample lines in CI.
  • Prefer cheap parsers: JSON, key value and dissect are faster than complex regexes. Anchor regexes and avoid catastrophic backtracking.
  • Use consistent field names, ideally OpenTelemetry semantic conventions, so parsed logs line up with traces and metrics.
  • Fix the source when possible: switching your own services to structured logging removes the need for fragile parsers.

Our article on structured logging best practices covers the source side, and reducing log costs shows how parsed fields help to filter and aggregate noise.

How Obseria helps

Obseria collects logs via OpenTelemetry, the Obseria Agent or existing shippers. The Obseria Pipeline parses, filters and masks personal data before storage, and log analytics stores logs in Obseria Lake with schema-on-read, so unstructured lines can still be parsed at query time when needed. Parsed fields are available for dashboards and alerts, logs carrying trace IDs are linked to their traces, and Obseria Intelligence can help draft parsing rules for unfamiliar log formats.

Frequently asked questions

Structured logging means the application writes logs as structured records, for example JSON, from the start. Log parsing extracts structure afterwards from logs that were written as plain text.

Grok is a pattern syntax known from Logstash that combines named, reusable regular expressions. A pattern like %{IP:client} matches an IP address and stores it in the field client.

Parsing at ingest makes queries fast and allows precise filtering and masking. Parsing at query time is more flexible for unexpected formats. Many teams parse known formats early and keep query time parsing for the rest.

Configure a multiline rule in your collector that recognizes the start of a new entry, for example a timestamp at the beginning of the line, and joins all following lines into one record before parsing.

Put these concepts into practice

Try Obseria free for 14 days, with OpenTelemetry and no proprietary agents.