Kubesense

Extract

The Extract rule pulls a specific value from a log field using a named regex group and promotes it to a top-level JSON key — without parsing the entire log.

When to Use

  • You only need one or two specific values from a log line (e.g., a request ID or user ID).
  • Writing a full Parse regex for the entire log line would be overkill.
  • The log is partially structured and you just need to pull out an additional field.

Extract vs. Parse

ParseExtract
ScopeParses the entire log line into multiple fieldsExtracts one value from a specific field
ComplexityRequires a regex covering the full log structureOnly needs a regex for the target value
Best forFully unstructured logsPulling a single field from semi-structured logs

Fields

FieldRequiredDescription
NameYesRule identifier
Source FieldYesThe log field to run the regex against
Regular ExpressionYesRegex with a named capture group (e.g., (?P<field_name>...))

How It Works

The Extract rule applies the regex to the specified Source Field. The value captured by the named group is added as a new top-level JSON key on the log. The original field remains unchanged.

Extract Rule Configuration

Examples

Extract Order ID

Source Field: message

Input value:

[INFO] Processing order order_id=ORD-78421 user=john@example.com

Regular Expression:

order_id=(?P<order_id>\S+)

Result: A new field order_id is added with value ORD-78421.

Extract Trace ID from Header

Source Field: headers

Input value:

X-Trace-Id: 4bf92f3577b34da6a3ce929d0e0e4736, X-Request-Id: req-9981

Regular Expression:

X-Trace-Id: (?P<trace_id>[a-f0-9]+)

Result: A new field trace_id is added with value 4bf92f3577b34da6a3ce929d0e0e4736.

Tips

  • The named group name becomes the new field name — choose descriptive names.
  • If the regex doesn't match, the log passes through without the new field.
  • You can add multiple Extract rules in a pipeline to pull out several fields independently.