The redact operator in APL replaces sensitive or unwanted data in string fields using regular expressions. You can use it to sanitize log data, obfuscate personal information, or anonymize text for auditing or analysis. The operator allows you to define one or multiple regular expressions to identify and replace matching patterns. You can customize the replacement token, generate hashes of redacted values, or retain structural elements while obfuscating specific segments of data.

This operator is useful when you need to ensure data privacy or compliance with regulations such as GDPR or HIPAA. For example, you can redact credit card numbers, email addresses, or personally identifiable information from logs and datasets.

For users of other query languages

If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.

Usage

Syntax

| redact [replaceToken="*"] [replaceHash=false] [redactGroups=false] <regex>, (<regex>) [on Field]

Parameters

ParameterTypeDescription
replaceTokenstringThe string with which to replace matches. If you specify a single character, Axiom replaces each character in the matching text with replaceToken. If you specify more than one character, Axiom replaces the whole of the matching text with replaceToken. The default replaceToken is the * character.
replaceHashboolSpecifies whether to replace matches with a hash of the data. You cannot use both replaceToken and replaceHash in the same query.
redactGroupsboolSpecifies whether to look for capturing groups in the regex and only redact characters in the capturing groups. Use this option for partial replacements or replacements that maintain the structure of the data. The default is false.
regexregexA single regex or an array/map of regexes to match against field values.
on FieldLimits redaction to specific fields. If you omit this parameter, Axiom redacts all string fields in the dataset.

Returns

Returns the input dataset with sensitive data replaced or hashed.

Use case examples

Use the redact operator to sanitize HTTP logs by obfuscating geographical data.

Query

['sample-http-logs']
| redact replaceToken="x" @'.*' on ['geo.city'], ['geo.country']

Run in Playground

Output

_timegeo.citygeo.country
2025-01-01 12:00:00xxxxxxxxxxx
2025-01-01 12:05:00xxxxxxxxxxxxxxxx

The query replaces all characters matching the pattern .* with the character x in the geo.city and geo.country fields.

  • project: Select specific fields from the dataset. Useful for focused analysis.
  • summarize: Aggregate data. Helpful when combining redacted data with statistical analysis.
  • parse: Extract and parse structured data using regex patterns.

When you need custom replacement patterns, use the replace_regex function for precise control over string replacements. redact provides a simpler, security-focused interface. Use redact if you’re primarily focused on data privacy and compliance, and replace_regex if you need more control over the replacement text format.