Skip to content

Commit cbde334

Browse files
committed
Sensitive data formatting
1 parent 38c0185 commit cbde334

File tree

5 files changed

+131
-108
lines changed

5 files changed

+131
-108
lines changed

content/en/ninja-workshops/10-advanced-otel/5-dropping-spans/5-1-configuration.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,32 @@ weight: 1
88

99
Switch to your **Gateway** terminal window. Navigate to the `[WORKSHOP]/5-dropping-spans` directory and open the `gateway.yaml` and add the following configuration to the `processors` section:
1010

11-
- **Add a `filter` processor**: Configure the OpenTelemetry Collector to drop spans with the name `"/_healthz"`:
11+
**Add a `filter` processor**: Configure the OpenTelemetry Collector to drop spans with the name `"/_healthz"`:
1212

13-
```yaml
14-
15-
filter/health: # Defines a filter processor
16-
error_mode: ignore # Ignore errors
17-
traces: # Filtering rules for traces
18-
span: # Exclude spans named "/_healthz"
19-
- 'name == "/_healthz"'
20-
```
13+
```yaml
14+
15+
filter/health: # Defines a filter processor
16+
error_mode: ignore # Ignore errors
17+
traces: # Filtering rules for traces
18+
span: # Exclude spans named "/_healthz"
19+
- 'name == "/_healthz"'
20+
```
2121
22-
- **Add the `filter` processor**: Make sure you add the filter to the `traces` pipeline. Filtering should be applied as early as possible, ideally *right after the* memory_limiter and *before* the batch processor.
22+
**Add the `filter` processor**: Make sure you add the filter to the `traces` pipeline. Filtering should be applied as early as possible, ideally *right after the* memory_limiter and *before* the batch processor:
2323

24-
```yaml
25-
traces:
26-
receivers:
27-
- otlp # OTLP Receiver
28-
processors:
29-
- memory_limiter # Manage memory usage
30-
- resource/add_mode # Add metadata about collector mode
31-
- filter/health # Filter Processor. Filter's out Data based on rules
32-
- batch # Groups Data before send
33-
exporters:
34-
- debug # Debug Exporter
35-
- file/traces # File Exporter for Trace
36-
```
24+
```yaml
25+
traces:
26+
receivers:
27+
- otlp # OTLP Receiver
28+
processors:
29+
- memory_limiter # Manage memory usage
30+
- resource/add_mode # Add metadata about collector mode
31+
- filter/health # Filter Processor. Filter's out Data based on rules
32+
- batch # Groups Data before send
33+
exporters:
34+
- debug # Debug Exporter
35+
- file/traces # File Exporter for Trace
36+
```
3737

3838
{{% /notice %}}
3939

content/en/ninja-workshops/10-advanced-otel/5-dropping-spans/5-2-test-filter.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ To test your configuration, you'll need to generate some trace data that include
88

99
{{% notice title="Exercise" style="green" icon="running" %}}
1010

11-
- **Create "noisy" 'Healthz' Span**
12-
1. Create a new file called `health.json` in the `5-dropping-spans` directory.
13-
2. Copy and paste the following JSON into the `health.json` file.
14-
3. Note the span name is set to `{"name":"healthz"}` in the json.
11+
**Create "noisy" 'healthz' span**:
12+
13+
1. Create a new file called `health.json` in the `5-dropping-spans` directory.
14+
2. Copy and paste the following JSON into the `health.json` file.
15+
3. Note the span name is set to `{"name":"healthz"}` in the json.
1516

1617
{{% tabs %}}
1718
{{% tab title="health.json" %}}
@@ -44,35 +45,34 @@ WORKSHOP
4445
{{% /tabs %}}
4546
{{% /tab %}}
4647

47-
- **Start the Gateway and the Agent**
48-
1. Make sure you are in the `[WORKSHOP]/5-dropping-spans` folder for both the **Gateway** and **Agent** terminal windows and start the collectors.
49-
2. **Send** the new `health.json` payload with the **cULR** command below. (**Windows use `curl.exe`**).
48+
**Start the Gateway and the Agent**:
49+
50+
1. Make sure you are in the `[WORKSHOP]/5-dropping-spans` folder for both the **Gateway** and **Agent** terminal windows and start the collectors.
51+
2. **Send** the new `health.json` payload with the **cULR** command below. (**Windows use `curl.exe`**).
5052

51-
```sh
52-
curl -X POST -i http://localhost:4318/v1/traces -H "Content-Type: application/json" -d "@health.json"
53-
```
54-
55-
- **Verify Agent Debug output shows the `healthz` span**
56-
1. Confirm that the span `span` payload is sent, Check the agent’s debug output to see the span data like the snippet below:
57-
58-
```text
59-
<snip>
60-
Span #0
61-
Trace ID : 5b8efff798038103d269b633813fc60c
62-
Parent ID : eee19b7ec3c1b173
63-
ID : eee19b7ec3c1b174
64-
Name : /_healthz
65-
Kind : Server
66-
<snip>
67-
```
68-
69-
The **Agent** has forward the span to the **Gateway**.
53+
```sh
54+
curl -X POST -i http://localhost:4318/v1/traces -H "Content-Type: application/json" -d "@health.json"
55+
```
56+
57+
**Verify Agent Debug output shows the `healthz` span**: Confirm that the span `span` payload is sent, Check the agent’s debug output to see the span data like the snippet below:
58+
59+
```text
60+
<snip>
61+
Span #0
62+
Trace ID : 5b8efff798038103d269b633813fc60c
63+
Parent ID : eee19b7ec3c1b173
64+
ID : eee19b7ec3c1b174
65+
Name : /_healthz
66+
Kind : Server
67+
<snip>
68+
```
69+
70+
The **Agent** has forward the span to the **Gateway**.
7071

71-
- **Check the Gateway Debug output**
72-
1. The Gateway should **NOT** show any span data received.
73-
This is because the **Gateway** is configured with a filter to drop spans named `"/_healthz"`, so the span will be discarded/dropped and not processed further.
74-
2. Confirm normal span are processed by using the cURL command with the `trace.json` file again.
75-
This time, you should see both the agent and gateway process the spans successfully.
72+
**Check the Gateway Debug output**:
73+
74+
1. The Gateway should **NOT** show any span data received. This is because the **Gateway** is configured with a filter to drop spans named `"/_healthz"`, so the span will be discarded/dropped and not processed further.
75+
2. Confirm normal span are processed by using the cURL command with the `trace.json` file again. This time, you should see both the agent and gateway process the spans successfully.
7676
{{% /notice %}}
7777

7878
{{% notice title="Tip" style="primary" icon="lightbulb" %}}
@@ -83,7 +83,7 @@ When using the `Filter` processor make sure you understand the look of your inco
8383
---
8484
The following excises can be done in your own time after the workshop.
8585

86-
### (Optional) Modify the Filter Condition
86+
**(Optional) Modify the Filter Condition**:
8787

8888
If you’d like, you can customize the filter condition to drop spans based on different criteria. This step is optional and can be explored later. For example, you might configure the filter to drop spans that include a specific tag or attribute.
8989

@@ -99,7 +99,7 @@ filter:
9999
100100
This filter would drop spans where the `service.name` attribute is set to `frontend`.
101101

102-
### (Optional) Filter Multiple Spans
102+
**(Optional) Filter Multiple Spans**:
103103

104104
You can filter out multiple span names by extending the span list:
105105

content/en/ninja-workshops/10-advanced-otel/6-sensitive-data/6-1-configuration.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,48 +25,48 @@ Attributes:
2525

2626
Switch to your **Agent** terminal window. Navigate to the `[WORKSHOP]/6-sensitive-data` directory and open the `agent.yaml` file in your editor.
2727

28-
* **Add an `attributes` Processor**: This processor allows you to update, delete, or hash specific attributes (tags) within spans. We'll update `user.phone_number`, hash `user.email`, and remove `user.account_password`:
28+
**Add an `attributes` Processor**: This processor allows you to update, delete, or hash specific attributes (tags) within spans. We'll update `user.phone_number`, hash `user.email`, and remove `user.account_password`:
2929

30-
```yaml
31-
attributes/update: # Processor Type/Name
32-
actions: # List of actions
33-
- key: user.phone_number # Target key
34-
action: update # Replace value with:
35-
value: "UNKNOWN NUMBER"
36-
- key: user.email # Hash the email value
37-
action: hash
38-
- key: user.account_password # Remove the password
39-
action: delete
40-
```
30+
```yaml
31+
attributes/update: # Processor Type/Name
32+
actions: # List of actions
33+
- key: user.phone_number # Target key
34+
action: update # Replace value with:
35+
value: "UNKNOWN NUMBER"
36+
- key: user.email # Hash the email value
37+
action: hash
38+
- key: user.account_password # Remove the password
39+
action: delete
40+
```
4141
42-
* **Add a `redaction` Processor**: This processor will detect and redact sensitive values based on predefined patterns. We'll block credit card numbers using regular expressions.
42+
**Add a `redaction` Processor**: This processor will detect and redact sensitive values based on predefined patterns. We'll block credit card numbers using regular expressions.
4343

44-
```yaml
45-
redaction/redact: # Processor Type/Name
46-
allow_all_keys: true # If false, only allowed keys will be retained
47-
blocked_values: # List of regex patterns to hash
48-
- '\b4[0-9]{3}[\s-]?[0-9]{4}[\s-]?[0-9]{4}[\s-]?[0-9]{4}\b' # Visa card
49-
- '\b5[1-5][0-9]{2}[\s-]?[0-9]{4}[\s-]?[0-9]{4}[\s-]?[0-9]{4}\b' # MasterCard
50-
summary: debug # Show debug details about redaction
51-
```
44+
```yaml
45+
redaction/redact: # Processor Type/Name
46+
allow_all_keys: true # If false, only allowed keys will be retained
47+
blocked_values: # List of regex patterns to hash
48+
- '\b4[0-9]{3}[\s-]?[0-9]{4}[\s-]?[0-9]{4}[\s-]?[0-9]{4}\b' # Visa card
49+
- '\b5[1-5][0-9]{2}[\s-]?[0-9]{4}[\s-]?[0-9]{4}[\s-]?[0-9]{4}\b' # MasterCard
50+
summary: debug # Show debug details about redaction
51+
```
5252

53-
* **Update the `traces` Pipeline**: Integrate both processors into the `traces` pipeline to ensure the redactions and modifications take effect:
53+
**Update the `traces` Pipeline**: Integrate both processors into the `traces` pipeline to ensure the redactions and modifications take effect:
5454

55-
```yaml
56-
traces:
57-
receivers: # Data input sources
58-
- otlp
59-
processors: # Processing steps in the pipeline
60-
- memory_limiter # Manage memory usage
61-
- attributes/update # Update, hash, and remove attributes
62-
- redaction/redact # Redact sensitive fields using regex
63-
- resourcedetection # Add system attributes
64-
- resource/add_mode # Add metadata about collector mode
65-
- batch
66-
exporters: # Output destinations
67-
- debug
68-
- otlphttp
69-
```
55+
```yaml
56+
traces:
57+
receivers: # Data input sources
58+
- otlp
59+
processors: # Processing steps in the pipeline
60+
- memory_limiter # Manage memory usage
61+
- attributes/update # Update, hash, and remove attributes
62+
- redaction/redact # Redact sensitive fields using regex
63+
- resourcedetection # Add system attributes
64+
- resource/add_mode # Add metadata about collector mode
65+
- batch
66+
exporters: # Output destinations
67+
- debug
68+
- otlphttp
69+
```
7070

7171
{{% /notice %}}
7272

content/en/ninja-workshops/10-advanced-otel/6-sensitive-data/6-2-test-delete-tag.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,34 @@ linkTitle: 6.2 Test Attribute Processor
44
weight: 2
55
---
66

7-
### Test the Attribute Processor tag updates
7+
In this exercise, we will **delete** the `user.account_password`, **update** the `user.phone_number` **attribute** and **hash** the `user.email` in the span data before it is exported by the **Agent**.
88

9-
Start your gateway agent from the `[WORKSHOP]/6-sensitive-data` directory in the **Gateway** terminal window, and wait until it is ready to receive data.
9+
{{% notice title="Exercise" style="green" icon="running" %}}
1010

11-
In this exercise, we will **delete** the `user.account_password`, **update** the `user.phone_number` **attribute** & **hash** the `user.email` in the span data before it is exported by the **Agent**.
11+
**Start the Gateway**: In the **Gateway** terminal change into the `6-sensitive-data` directory:
1212

13-
{{% notice title="Exercise" style="green" icon="running" %}}
13+
```sh
14+
../otelcol --config=gateway.yaml
15+
```
16+
17+
**Update `agent.yaml`**:
18+
19+
1. In the **Agent** terminal change into the `6-sensitive-data` directory and edit the `agent.yaml`.
20+
2. Disable the `redaction/redact` processor in the `traces` pipeline by adding the comment character `#` in front.
21+
22+
**Start the Agent**: Remaining in the **Agent** terminal window:
23+
24+
```sh
25+
../otel --config=agent.yaml
26+
```
27+
28+
**Send a span**:
29+
30+
1. In the **Test** terminal window change into the `6-sensitive-data` directory.
31+
2. Send the span containing **sensitive data** by running the `curl` command to send `trace.json`.
32+
33+
**Check the debug output**: For both the **Agent** and **Gateway** debug output, confirm that `user.account_password` has been removed, and both `user.phone_number` & `user.email` have been updated.
1434

15-
- **Disable the `redaction/redact` processor** in the `traces` pipeline by adding the comment character `#` in front of it and save the `agent.yaml`.
16-
- **Start the **Agent** Collector** from the `[WORKSHOP]/6-sensitive-data` directory in the **Agent** terminal window.
17-
- **Send a span containing `Sensitive data`** by running the **cURL** command from the `[WORKSHOP]/6-sensitive-data` directory in the **Test** terminal window to send `trace.json`.
18-
- **Check the debug output** of both the **Agent** and **Gateway** to confirm that `user.account_password` has been removed, and both `user.phone_number` & `user.email` have been updated.
1935
{{% tabs %}}
2036
{{% tab title="New Debug Output" %}}
2137

@@ -44,7 +60,7 @@ In this exercise, we will **delete** the `user.account_password`, **update** the
4460
{{% /tab %}}
4561
{{% /tabs %}}
4662

47-
- **Check** the new `gateway-traces.out` file to confirm that `user.account_password` has been removed, and `user.phone_number` & `user.email` have been updated.
63+
**Check file output**: In the new `gateway-traces.out` file confirm that `user.account_password` has been removed, and `user.phone_number` & `user.email` have been updated:
4864

4965
{{% tabs %}}
5066
{{% tab title="New File Output" %}}

content/en/ninja-workshops/10-advanced-otel/6-sensitive-data/6-3-test-redaction.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,17 @@ Delete the `*.out` files and clear the screen. Restart your **Gateway** terminal
3030
In this exercise, we will **redact** the `user.visa` & `user.mastercard` **values** in the span data before it is exported by the **Agent**.
3131
{{% notice title="Exercise" style="green" icon="running" %}}
3232

33-
- **Enable the `redaction/redact` processor** in the `traces` pipeline by removing the `#` in front of it and then restart the **Agent**.
34-
- **Start the **Agent** Collector** from the `[WORKSHOP]/6-sensitive-data` directory in the **Agent** terminal window.
35-
- **Send a span containing `Sensitive data`** by running the **cURL** command to send `trace.json`.
36-
- **Check the debug output** of both the **Agent** and **Gateway** to confirm the values for `user.visa` & `user.mastercard` have been updated. Notice `user.amex` attribute value was NOT redacted because a matching regex pattern was not added to `blocked_values`
33+
**Enable the `redaction/redact` processor**: In the **Agent** terminal window edit `agent.yaml` and remove the `#` we inserted in the previous exercise.
34+
35+
**Start the Agent**: In the **Agent** terminal window run:
36+
37+
```sh
38+
../otelcol --config=agent.yaml
39+
```
40+
41+
**Send a span**: Run the `curl` command and in the **Test** terminal window to send `trace.json`.
42+
43+
**Check the debug output**: For both the **Agent** and **Gateway** confirm the values for `user.visa` & `user.mastercard` have been updated. Notice `user.amex` attribute value was NOT redacted because a matching regex pattern was not added to `blocked_values`
3744

3845
{{% tabs %}}
3946
{{% tab title="New Debug Output" %}}
@@ -69,7 +76,7 @@ In this exercise, we will **redact** the `user.visa` & `user.mastercard` **value
6976
By including `summary:debug` in the redaction processor, the debug output will include summary information about which matching keys values were redacted, along with the count of values that were masked.
7077
{{% /notice %}}
7178

72-
- **Check** the new `gateway-traces.out` file to verify confirm that `user.visa` & `user.mastercard` have been updated.
79+
**Check file output**: In the newly created `gateway-traces.out` file to verify confirm that `user.visa` & `user.mastercard` have been updated.
7380

7481
{{% tabs %}}
7582
{{% tab title="New File Output" %}}
@@ -170,7 +177,7 @@ By including `summary:debug` in the redaction processor, the debug output will i
170177

171178
{{% /notice %}}
172179

173-
### (Optional) Redact Amex CC number
180+
**(Optional) Redact Amex CC number**:
174181

175182
Add the Amex card regex to `blocked_values` and restart **Agent** collector.
176183

0 commit comments

Comments
 (0)