Skip to content

Commit 674e636

Browse files
Merge pull request #245853 from jeanbisutti/telemetry-processor-update
Attribute masking for telemetry processor
2 parents a6337fd + 875a300 commit 674e636

File tree

2 files changed

+72
-24
lines changed

2 files changed

+72
-24
lines changed

articles/azure-monitor/app/java-standalone-telemetry-processors-examples.md

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,12 @@ For example, given `http.url = http://example.com/path?queryParam1=value1,queryP
355355
}
356356
```
357357

358-
The following sample shows how to process spans that have a span name that matches regex patterns.
359-
This processor removes the `token` attribute. It obfuscates the `password` attribute in spans where the span name matches `auth.*`
360-
and where the span name doesn't match `login.*`.
358+
### Mask
359+
360+
For example, given `http.url = https://example.com/user/12345622` is updated to `http.url = https://example.com/user/****` using either of the below configurations.
361+
362+
363+
First configuration example:
361364

362365
```json
363366
{
@@ -366,27 +369,12 @@ and where the span name doesn't match `login.*`.
366369
"processors": [
367370
{
368371
"type": "attribute",
369-
"include": {
370-
"matchType": "regexp",
371-
"spanNames": [
372-
"auth.*"
373-
]
374-
},
375-
"exclude": {
376-
"matchType": "regexp",
377-
"spanNames": [
378-
"login.*"
379-
]
380-
},
381372
"actions": [
382373
{
383-
"key": "password",
384-
"value": "obfuscated",
385-
"action": "update"
386-
},
387-
{
388-
"key": "token",
389-
"action": "delete"
374+
"key": "http.url",
375+
"pattern": "user\\/\\d+",
376+
"replace": "user\\/****",
377+
"action": "mask"
390378
}
391379
]
392380
}
@@ -396,6 +384,29 @@ and where the span name doesn't match `login.*`.
396384
```
397385

398386

387+
Second configuration example with regular expression group name:
388+
389+
```json
390+
{
391+
"connectionString": "InstrumentationKey=00000000-0000-0000-0000-000000000000",
392+
"preview": {
393+
"processors": [
394+
{
395+
"type": "attribute",
396+
"actions": [
397+
{
398+
"key": "http.url",
399+
"pattern": "^(?<userGroupName>[a-zA-Z.:\/]+)\d+",
400+
"replace": "${userGroupName}**",
401+
"action": "mask"
402+
}
403+
]
404+
}
405+
]
406+
}
407+
}
408+
```
409+
399410
## Span processor samples
400411

401412
### Name a span

articles/azure-monitor/app/java-standalone-telemetry-processors.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ms.reviewer: mmcc
1515
1616
Application Insights Java 3.x can process telemetry data before the data is exported.
1717

18-
Here are some use cases for telemetry processors:
18+
Some use cases:
1919
* Mask sensitive data.
2020
* Conditionally add custom dimensions.
2121
* Update the span name, which is used to aggregate similar telemetry in the Azure portal.
@@ -52,7 +52,11 @@ The trace message or body is the primary display for logs in the Azure portal. L
5252

5353
## Telemetry processor types
5454

55-
Currently, the four types of telemetry processors are attribute processors, span processors, log processors, and metric filters.
55+
Currently, the four types of telemetry processors are
56+
* Attribute processors
57+
* Span processors
58+
* Log processors
59+
* Metric filters
5660

5761
An attribute processor can insert, update, delete, or hash attributes of a telemetry item (`span` or `log`).
5862
It can also use a regular expression to extract one or more new attributes from an existing attribute.
@@ -111,6 +115,7 @@ The attribute processor modifies attributes of a `span` or a `log`. It can suppo
111115
- `delete`
112116
- `hash`
113117
- `extract`
118+
- `mask`
114119

115120
### `insert`
116121

@@ -227,6 +232,38 @@ The `extract` action requires the following settings:
227232
* `pattern`
228233
* `action`: `extract`
229234

235+
### `mask`
236+
237+
> [!NOTE]
238+
> The `mask` feature is available only in version 3.2.5 and later.
239+
240+
The `mask` action masks attribute values by using a regular expression rule specified in the `pattern` and `replace`.
241+
242+
```json
243+
"processors": [
244+
{
245+
"type": "attribute",
246+
"actions": [
247+
{
248+
"key": "attributeName",
249+
"pattern": "<regular expression pattern>",
250+
"replace": "<replacement value>",
251+
"action": "mask"
252+
}
253+
]
254+
}
255+
]
256+
```
257+
The `mask` action requires the following settings:
258+
* `key`
259+
* `pattern`
260+
* `replace`
261+
* `action`: `mask`
262+
263+
`pattern` can contain a named group placed betwen `?<` and `>:`. Example: `(?<userGroupName>[a-zA-Z.:\/]+)\d+`? The gorup is `(?<userGroupName>[a-zA-Z.:\/]+)` and `userGroupName` is the name of the group. `pattern` can then contain the same named group placed between `${` and `}` followed by the masK. Example where the mask is **: `${userGroupName}**`.
264+
265+
See [Telemetry processor examples](./java-standalone-telemetry-processors-examples.md) for masking examples.
266+
230267
### Include criteria and exclude criteria
231268

232269
Attribute processors support optional `include` and `exclude` criteria.

0 commit comments

Comments
 (0)