Skip to main content

Overview

Log rewrites modify matching Connector and Endpoint logs before Formal stores or exports them. Use rewrites to remove, encrypt, truncate, or sanitize sensitive fields with field-level precision. Configure rewrites with the formal_log_rewrite Terraform resource. Each rewrite contains:
  • A CEL scope that selects logs.
  • One or more protobuf field paths.
  • One or more actions for each path.
  • An optional asymmetric encryption key.
When a log matches a rewrite, the rewrite overrides Log Configuration content settings for that log. Policy evaluation input retention settings still apply.

Configure a Rewrite

This example removes SQL literals from queries for one resource:
Run terraform apply, then query the resource through Formal. Verify: Open Logs and inspect the resulting request log. The query has values_stripped: true and does not contain its original literals.

Scope Fields

The scope_cel expression must return a boolean. It can use these fields: The scope cannot inspect payload fields, timestamps, or the complete log. Use paths to select payload fields after the scope matches.
Endpoint rewrites use log.source == "endpoint". Stored Endpoint logs use source:desktop when you search them.

Rewrite Actions

encrypt and encrypt_sql require encryption_key_id. The key must use an asymmetric algorithm. See Encryption Keys. You can combine compatible actions on one path. drop takes precedence over every other action. Truncation runs before encryption. SQL stripping runs before SQL encryption.

Supported Paths

Every path starts with log. The following path families support rewrites: encrypt and truncate only support singular string fields. drop can select a supported parent field, string, list, or map. Paths use protobuf field names, not search aliases. For example, use log.request.http.body.received, not request_body.

Path Restrictions

A rewrite cannot contain both a parent path and its child. For example, you cannot combine log.request.http.body with log.request.http.body.received. Do not configure overlapping paths across separate rewrites. When any rewrite matches, its path actions replace legacy log content settings for that log. Existing policy evaluation input retention settings still apply. If no rewrite matches, Formal applies the legacy log configuration.

Failure Behavior

Formal clears a selected sensitive field if its encryption action fails. It then continues applying actions to other paths. A failed SQL encryption clears the complete selected query object. A scope evaluation failure skips only that rewrite. Other matching rewrites continue to apply.

Next Steps

Configure Encryption Keys

Register an asymmetric key for encrypted fields

Log Configuration

Configure default logging and retention behavior