PII Selectors
Selectors allow you to restrict rules to certain parts of the event. This is useful to unconditionally remove certain data by variable/field name from the event, but can also be used to conservatively test rules on real data.
Data scrubbing always works on the raw event payload. Keep in mind that some fields in the UI may be called differently in the JSON schema. When looking at an event there should always be a link called "JSON" present that allows you to see what the data scrubber sees.
For example, what is called "Additional Data" in the UI is called extra in the event payload. To remove a specific key called foo, you would write:
[Remove] [Anything] from [extra.foo]
Another example. Sentry knows about two kinds of error messages: The exception message, and the top-level log message. Here is an example of how such an event payload as sent by the SDK (and downloadable from the UI) would look like:
{
"logentry": {
"formatted": "Failed to roll out the dinglebop"
},
"exceptions": {
"values": [
{
"type": "ZeroDivisionError",
"value": "integer division or modulo by zero"
}
]
}
}
Since the "error message" is taken from the exception's value, and the "message" is taken from logentry, we would have to write the following to remove both from the event:
[Remove] [Anything] from [exception.value]
[Remove] [Anything] from [logentry.formatted]
You can combine selectors using boolean logic.
- Prefix with
!to invert the selector.foomatches the JSON keyfoo, while!foomatches everything butfoo. - Build the conjunction (AND) using
&&, such as:foo && !extra.footo match the keyfooexcept when inside ofextra. - Build the disjunction (OR) using
||, such as:foo || barto matchfooorbar.
**matches all subpaths, so thatfoo.**matches all JSON keys withinfoo.*matches a single path item, so thatfoo.*matches all JSON keys one level belowfoo.
Select subsections by JSON-type using the following:
$stringmatches any string value$numbermatches any integer or float value$datetimematches any field in the event that represents a timestamp$arraymatches any JSON array value$objectmatches any JSON object
Select known parts of the schema using the following:
$exceptionmatches a single exception instance in{"exception": {"values": [...]}}$stacktracematches a stack trace instance$framematches a frame$requestmatches the HTTP request context of an event$usermatches the user context of an event$logentry(also applies to themessageattribute)$threadmatches a single thread instance in{"threads": {"values": [...]}}$breadcrumbmatches a single breadcrumb in{"breadcrumbs": [...]}$spanmatches a trace span$sdkmatches the SDK context in{"sdk": ...}
Delete
event.user:Copied[Remove] [Anything] from [$user]Delete all frame-local variables:
Copied[Remove] [Anything] from [$frame.vars]
If the object key you want to match contains whitespace or special characters, you can use quotes to escape it:
[Remove] [Anything] from [extra.'my special value']
This matches the key my special value in Additional Data.
To escape ' (single quote) within the quotes, replace it with '' (two quotes):
[Remove] [Anything] from [extra.'my special '' value']
This matches the key my special ' value in Additional Data.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").