Keep
Synopsis
Keeps only specified fields and removes all others.
Schema
- keep:
field: <string|string[]>
schema: <string>
schema_type: <string>
requirement_filter: <string>
root_field: <ident>
description: <text>
disabled: <boolean>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
Configuration
The following fields are used to define the processor:
| Field | Required | Default | Description |
|---|---|---|---|
field | Y | Field name(s) to keep. Accepts a single string, an array of strings, or glob patterns (*, ?, []) | |
schema | N | Schema reference path. When set, the field list is loaded from the schema and field is ignored | |
schema_type | N | parquet | Schema file format. Accepted values: avro, parquet |
requirement_filter | N | all | Filters which schema requirement levels are loaded from the schema |
root_field | N | When set, the keep operation runs inside this nested map instead of at the top level of the log entry | |
description | N | Explanatory note | |
disabled | N | false | Disable the processor without removing it from the pipeline |
if | N | Condition to run | |
ignore_failure | N | false | Continue processing if field operations fail |
ignore_missing | N | false | Continue processing if the source field does not exist |
on_failure | N | Error handling processors | |
on_success | N | Success handling processors | |
tag | N | Identifier |
Details
Removes all fields from the log entry except those explicitly specified. This processor performs the inverse operation of remove, allowing you to specify which fields to retain while discarding all others.
By default, the keep processor operates at the top level of the log entry. When specifying nested fields like user.id, the processor keeps the entire parent object (user) and not just the specific nested field. When root_field is set, the keep operation runs inside the specified nested map instead — only the keys within that map are filtered, and fields outside it are not affected.
The processor is useful for creating a minimal document with only essential fields, reducing the size of log entries, or ensuring consistent field presence for downstream systems.
When schema is set, the list of fields to keep is loaded from the referenced schema file and the field value is ignored. The schema_type field selects the schema format (avro or parquet, defaulting to parquet); requirement_filter controls which requirement levels from the schema are included, defaulting to all.
Field values support glob patterns: * matches any sequence of characters, ? matches any single character, and [...] matches a character set. Patterns are evaluated using filepath.Match semantics and apply to immediate key names within the target scope (top level or root_field map).
Using the keep processor is a destructive operation that removes all non-specified fields. This can lead to loss of potentially useful data. Consider creating a copy of important data before applying keep operations or ensure that your field list is comprehensive.
Examples
Single Field
Keeping only essential identifier field... | |
removes all fields except id: | |
Multiple Fields
Preserving selected fields from a nested structure... | |
creates a minimal document with specific fields: | |
Templates
Dynamically selecting fields to keep... | |
keeps event-specific fields based on event type: | |
Conditional
Applying different keep rules based on conditions... | |
keeps different sets of fields based on log level |