> For the complete documentation index, see [llms.txt](https://docs.pharos.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pharos.ai/configuration-guide/advanced/sensitive-data-masking.md).

# Sensitive Data Masking

Configure targeted regex-based masking rules that redact sensitive data from logs before it is stored—and test their performance impact before enabling them.

Logs can accidentally capture credit cards, SSNs, passwords, API tokens, and other sensitive data. **Sensitive Data Masking** redacts that information *as each log is created*, replacing matched text with a masked placeholder so the original value never reaches storage. Rules are managed from **Pharos Admin → Masking** and combine filter criteria (which logs to inspect) with regex patterns (what to redact).

{% hint style="warning" %}
**Use masking sparingly and deliberately.** Every masking rule runs its regex patterns against matching logs at creation time, which consumes CPU and heap. Masking is meant for a small number of **targeted** use cases—not blanket coverage. Keep filter criteria narrow and regexes tight, and validate cost with the [Performance Impact](#performance-impact) simulator before enabling a rule broadly.
{% endhint %}

{% hint style="info" %}
For masking concepts and compliance context, see [Data Masking](https://docs.pharos.ai/platform-overview/pharos-platform-architecture/logs/access-controls/data-masking.md).
{% endhint %}

***

## How Masking Works

A masking rule has two parts working together:

* **Filter criteria** decide *which* logs the rule evaluates (for example, only `Apex` logs). Narrow criteria keep the regex from firing on every log created.
* **Regex patterns** define *what* to redact within those logs. Each match is replaced with a redaction marker so the sensitive substring is never persisted.

Masking rules fire **during log creation**. Unlike notification rules, **all matching masking rules are applied** to a log, so multiple types of sensitive data can be caught in a single record. When more than one rule qualifies, rules are evaluated in order from top to bottom in the list.

***

## Accessing Data Masking

Navigate to **Pharos App → Pharos Admin → Masking**. The **Sensitive Data Masking Rules** page lists every rule with its filter criteria, pattern count, and active state, and provides **Add New Rule** and **Performance Impact** actions.

![Sensitive Data Masking Rules list page — Pharos Admin Masking nav item selected, with Performance Impact and Add New Rule actions and an empty rules table](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-332420e7967e4152f0ed1a5ea9337750534b2452%2Fmasking-rules-list.png?alt=media)

***

## Creating a Masking Rule

Click **Add New Rule** and complete the rule form.

![New Sensitive Data Masking Rule form — Rule Details with Rule Name and Description, and a Filter Criteria row set to Category Equal Apex](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-f60489f391f4cd8a27b1bfa420edf65b4115e413%2Fmasking-rule-form.png?alt=media)

### Rule Details

Give the rule a clear **Rule Name** and **Description** that state what it redacts and where—for example, *"Redact API tokens from Apex integration logs."* Both fields are required.

### Filter Criteria

Use filter criteria to focus the rule on a specific slice of logs, so its patterns run only where the sensitive data actually appears. Each row is a `Field` / `Operator` / `Value` condition (for example, `Category` **Equal** `Apex`), and criteria can reference any field on the Log record.

By default every criterion must be satisfied for a log to be evaluated; use the **Filter logic** option to combine conditions differently. Narrowing criteria is the single most effective way to limit masking's performance cost—see [Performance Impact](#performance-impact).

***

## Adding Regex Patterns

Within a rule, the **Regex Patterns** section defines the expressions that identify sensitive data to redact. Add one or more patterns with **Add Existing** (reuse a saved pattern) or **Add New**.

{% hint style="warning" %}
**Hard limits:** a masking rule can hold a maximum of **10 patterns**, and each regex pattern is capped at **500 characters**. Plan filter criteria and pattern scope accordingly—splitting redaction needs across multiple narrowly-scoped rules if you approach either ceiling.
{% endhint %}

![Regex Patterns section of a masking rule — Add Existing and Add New actions above a table of pattern type and expression](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-cf6cef15209f2176187f44da6ad19da634902526%2Fmasking-regex-patterns-section.png?alt=media)

Each pattern is entered in the **Regex Pattern** dialog. You can start from a predefined pattern via the **Pattern Reference** dropdown, or enter your own expression in **Pattern (Regex)**.

![Regex Pattern dialog — Pattern Reference dropdown, a required Pattern (Regex) field, a Test Sample Text field, and a Test Pattern button](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-95890b6d28d0c99ce0fddcfd80398c584121bd49%2Fmasking-regex-pattern-new.png?alt=media)

### Test Before You Save

Paste representative text into **Test Sample Text** and click **Test Pattern** to preview exactly what the rule will redact. The **Result** pane shows the sample with matches masked, so you can confirm the pattern catches the sensitive value without over-redacting useful context.

![Regex Pattern dialog with a Generic API Key pattern tested against sample text, and a Result pane showing the api\_key value replaced with asterisks](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-2e02572aa16881cda53069dc85b738ab98f98eca%2Fmasking-regex-pattern-tested.png?alt=media)

{% hint style="warning" %}
**Keep regexes tight.** Broad or backtracking-prone expressions raise CPU time on every matching log. Anchor patterns and bound quantifiers (for example, require a minimum token length) so they match only the intended data.
{% endhint %}

### Predefined Pattern Library

The **Pattern Reference** dropdown ships with ready-made expressions for the most common sensitive-data types, so you rarely need to write regex from scratch.

![Pattern Reference dropdown showing predefined patterns including Email Address, Credit Card Number, SSN (US), US Phone Number, IPv4 Address, and AWS Access Key](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-72322456085b36f7d155bf59357c91543bcdcd04%2Fmasking-pattern-library.png?alt=media)

| Category                  | Predefined patterns                                                                                                                         |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| **Personal (PII)**        | Email Address, SSN (US), US Phone Number                                                                                                    |
| **Financial**             | Credit Card Number, IBAN                                                                                                                    |
| **Credentials & secrets** | AWS Access Key, Bearer Token, Slack Token, GitHub Token, Generic API Key, Password in URL, JWT Token, Private Key Header, Basic Auth Header |
| **Network & identifiers** | IPv4 Address, MAC Address, UUID / GUID                                                                                                      |

Selecting a predefined pattern populates the regex for you; you can still edit it before saving.

***

## What a Masked Log Looks Like

Once a rule is active, matching values are redacted in the stored log. In the example below, the log's `Description` has had MAC address, connection-string password, tokens, IBAN, AWS key, SSN, and card number replaced with `********`, while the surrounding message stays readable for troubleshooting.

![Log record LOG-00020 detail view with sensitive values in the Description field replaced by asterisks](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-82f458152147b242861afb86631cfd0e1974793d%2Fmasking-redacted-log.png?alt=media)

Redaction applies wherever the log is presented, including the Flow visual debugger's element details.

![LOG-00020 in the Flow debugger view, with the Create Records element's Description value showing the same masked output](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-01c3c911d5b748b03e751fd5d71c83c99bf6b78c%2Fmasking-redacted-log-flow.png?alt=media)

***

## Performance Impact

Because masking runs regex against matching logs at creation time, it has a real CPU and heap cost that scales with how many logs match, how many fields are scanned, and how many patterns run. Manage that cost deliberately:

* **Narrow the filter criteria** so a rule fires only on the logs that can contain the sensitive data—never on every log created.
* **Keep regexes tight** to avoid high CPU time during pattern processing.
* **Use masking sparingly**, for a few targeted use cases rather than broad coverage.

Use the **Performance Impact** action on the Masking page to simulate the cost before rolling a rule out. It reports the number of active rules and patterns, simulates a batch of logs, and shows the projected **CPU Time** and **Heap Size** consumed specifically by masking, with a per-rule breakdown.

![Performance Impact dialog — Masking Enabled, active rule and pattern counts, a simulated regex-operation total, CPU Time and Heap Size gauges, and a per-rule breakdown](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-c7bf113abd7535c494bfbd2c0e1c5b3d65b37ac5%2Fmasking-performance-impact.png?alt=media)

***

## Best Practices

1. **Scope tightly** — use narrow filter criteria so masking evaluates only the logs that need it.
2. **Keep patterns lean** — anchor regexes and bound quantifiers to minimize CPU time.
3. **Test both dimensions before production** — verify correctness with **Test Pattern** and cost with **Performance Impact**.
4. **Preserve troubleshooting context** — mask only the sensitive substring, not the whole message.
5. **Use it sparingly** — reserve masking for specific, high-value sensitive-data cases.
6. **Document each rule** — record its purpose and compliance context in the description.

***

## Related

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>🎭 Data Masking</strong></td><td>Masking concepts and compliance context</td><td><a href="https://docs.pharos.ai/platform-overview/pharos-platform-architecture/logs/access-controls/data-masking.md">Data Masking</a></td></tr><tr><td><strong>📦 Core Metadata</strong></td><td>Custom metadata usage in Pharos</td><td><a href="https://docs.pharos.ai/configuration-guide/core-metadata.md">Core Metadata</a></td></tr></tbody></table>
