Skip to content

Commit 3e4bdd2

Browse files
committed
updateted the text and flow of section 6
1 parent 9242897 commit 3e4bdd2

File tree

4 files changed

+44
-45
lines changed

4 files changed

+44
-45
lines changed

content/en/conf/1-advanced-collector/6-routing-data/6-1-connector.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,38 @@ linkTitle: 6.1 Routing Configuration
44
weight: 1
55
---
66

7-
In this exercise, you will configure the **Routing Connector** in the `gateway.yaml`. While the Routing Connector can route metrics, traces, and logs based on any attributes, we will focus exclusively on trace routing.
8-
9-
This setup enables the Gateway to route traces based on the `deployment.environment` attribute (though any span attribute can be used).
7+
In this exercise, you will configure the **Routing Connector** in the `gateway.yaml`. The Routing Connector can route metrics, traces, and logs based on any attributes, we will focus exclusively on trace routing based on the `deployment.environment` attribute (though any span/log/metirc attribute can be used).
108

119
{{% notice title="Exercise" style="green" icon="running" %}}
1210

13-
**Configure `file` exporters**: The `routing` connector requires separate targets for routing. Create two new file exporters, `file/traces/route1` and `file/traces/route2`, to ensure data is directed correctly in the `exporters` section of the `gateway.yaml`:
11+
**Add new `file` exporters**: The `routing` connector requires different targets for routing. Create two new file exporters, `file/traces/route1-regular` and `file/traces/route2-security`, to ensure data is directed correctly in the `exporters` section of the `gateway.yaml`:
1412

1513
```yaml
16-
file/traces/route1: # Exporter for regular traces
17-
path: "./gateway-traces-route1.out" # Path for saving trace data
18-
append: false # Overwrite the file each time
19-
file/traces/route2: # Exporter for security traces
20-
path: "./gateway-traces-route2.out" # Path for saving trace data
21-
append: false # Overwrite the file each time
14+
file/traces/route1-regular: # Exporter for regular traces
15+
path: "./gateway-traces-route1-regular.out" # Path for saving trace data
16+
append: false # Overwrite the file each time
17+
file/traces/route2-security: # Exporter for security traces
18+
path: "./gateway-traces-route2-security.out" # Path for saving trace data
19+
append: false # Overwrite the file each time
2220
```
2321
24-
In OpenTelemetry configuration files, `connectors` have their own dedicated section, similar to receivers and processors.
22+
**Enable Routing** by adding the `routing` connector. In OpenTelemetry configuration files, `connectors` have their own dedicated section, similar to receivers and processors.
2523

26-
**Add the `routing` connector**:
27-
In the **Gateway terminal** window, edit `gateway.yaml` and uncomment the `#connectors:` section. Then, add the following below the `connectors:` section:
24+
In the **Gateway terminal** window, edit `gateway.yaml` and find and uncomment the `#connectors:` section. Then, add the following below the `connectors:` section:
2825

2926
```yaml
3027
routing:
31-
default_pipelines: [traces/route1] # Default pipeline if no rule matches
32-
error_mode: ignore # Ignore errors in routing
33-
table: # Define routing rules
28+
default_pipelines: [traces/route1-regular] # Default pipeline if no rule matches
29+
error_mode: ignore # Ignore errors in routing
30+
table: # Define routing rules
3431
# Routes spans to a target pipeline if the resourceSpan attribute matches the rule
3532
- statement: route() where attributes["deployment.environment"] == "security-applications"
36-
pipelines: [traces/route2] # Target pipeline
33+
pipelines: [traces/route2-security] # Security target pipeline
3734
```
3835

3936
{{% /notice %}}
4037

38+
The default pipeline in the configuration file works at a Catch all. It will be the routing target for any data (spans in our case) that does match a rule in the routing rules table, In this table you find the pipeline that is the target for any span that matches the following rule: "[deployment.environment"] == "security-applications"
39+
40+
4141
With the `routing` configuration complete, the next step is to configure the `pipelines` to apply these routing rules.

content/en/conf/1-advanced-collector/6-routing-data/6-2-pipelines.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ weight: 2
66

77
{{% notice title="Exercise" style="green" icon="running" %}}
88

9-
**Update the `traces` pipeline to use routing**:
9+
**Update the original `traces` pipeline to use routing**:
1010

11-
1. To enable `routing`, update the original `traces:` pipeline by using `routing` as the only exporter. This ensures all span data is sent through the **Routing Connector** for evaluation. Also, remove **all** processors and replace it with an empty array (`[]`) as these are now defined in the `traces/route1` and `traces/route2` pipelines.
11+
1. To enable `routing`, update the original `traces:` pipeline to use `routing` as the only exporter. This ensures all span data is sent through the **Routing Connector** for evaluation and then onwards to connected pipelines. Also, remove **all** processors and replace it with an empty array (`[]`) as this will now behandeld in the `traces/route1-regular` and `traces/route2-security` pipelines, allowing for custom behaviour for each route. Your `traces:` configuration should look like this:
1212

1313
```yaml
1414
traces: # Traces pipeline
@@ -19,38 +19,37 @@ weight: 2
1919
- routing
2020
```
2121
22-
**Add both the `route1` and `route2` traces pipelines**:
22+
**Add both the `route1-regular` and `route2-security` traces pipelines** below the existing `traces:` pipeline:
2323

24-
1. **Configure Route1 pipeline**: This pipeline will handle all spans that match the routing rule for `route1`.
25-
This uses `routing` as its receiver. Place it below the existing `traces:` pipeline:
24+
1. **Configure Route1-regular pipeline**: This pipeline will handle all spans that have **no match** in the routing table in the connector.
25+
Notice this uses `routing` as its only receiver and will recieve data thought its `connection` from the original traces pipeline.
2626

2727
```yaml
28-
traces/route1: # Default pipeline for unmatched spans
28+
traces/route1-regular: # Default pipeline for unmatched spans
2929
receivers:
30-
- routing # Receive data from the routing connector
30+
- routing # Receive data from the routing connector
3131
processors:
32-
- memory_limiter # Memory Limiter Processor
33-
- resource/add_mode # Adds collector mode metadata
32+
- memory_limiter # Memory Limiter Processor
33+
- resource/add_mode # Adds collector mode metadata
3434
- batch
3535
exporters:
36-
- debug # Debug Exporter
37-
- file/traces/route1 # File Exporter for unmatched spans
36+
- debug # Debug Exporter
37+
- file/traces/route1-regular # File Exporter for unmatched spans
3838
```
3939

40-
2. **Add the Standard pipeline**: This pipeline processes all spans that do not match the routing rule.
41-
This pipeline is also using `routing` as its receiver. Add this below the `traces/security` one:
40+
2. **Add the route2-security pipeline**: This pipeline processes all spans that do match our rule "[deployment.environment"] == "security-applications" in the the routing rule. This pipeline is also using `routing` as its receiver. Add this pipline below the `traces/route1-regular` one.
4241

4342
```yaml
44-
traces/standard: # Default pipeline for unmatched spans
43+
traces/route2-security: # Default pipeline for unmatched spans
4544
receivers:
46-
- routing # Receive data from the routing connector
45+
- routing # Receive data from the routing connector
4746
processors:
48-
- memory_limiter # Memory Limiter Processor
49-
- resource/add_mode # Adds collector mode metadata
47+
- memory_limiter # Memory Limiter Processor
48+
- resource/add_mode # Adds collector mode metadata
5049
- batch
5150
exporters:
52-
- debug # Debug exporter
53-
- file/traces/standard # File exporter for unmatched spans
51+
- debug # Debug exporter
52+
- file/traces/route2-security # File exporter for unmatched spans
5453
```
5554

5655
{{% /notice %}}

content/en/conf/1-advanced-collector/6-routing-data/6-3-test-routing.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ weight: 3
66

77
{{% notice title="Exercise" style="green" icon="running" %}}
88

9-
In this section, we will test the `routing` rule configured for the **Gateway**. The expected result is that the`span` generated by the `loadgen` will be sent to the `gateway-traces-security.out` file.
9+
In this section, we will test the `routing` rule configured for the **Gateway**. The expected result is that the`span` generated by the `loadgen` that match the “[deployment.environment”] == “security-applications” rule will be sent to the `gateway-traces-route2-security.out` file.
1010

1111
**Start the Gateway**: In your **Gateway terminal** window start the **Gateway**.
1212

@@ -26,10 +26,10 @@ In this section, we will test the `routing` rule configured for the **Gateway**.
2626
../loadgen -count 1
2727
```
2828

29-
Both the **Agent** and **Gateway** will display debug information. The gateway will also generate a new `gateway-traces-standard.out` file, as this is now the designated destination for regular spans.
29+
Both the **Agent** and **Gateway** will display debug information. The gateway will also generate a new `gateway-traces-route1-regular.out` file, as this is now the designated destination for regular spans.
3030

3131
{{% notice title="Tip" style="primary" icon="lightbulb" %}}
32-
If you check `gateway-traces-standard.out`, it will contain the `span` sent by `loadgen`. You will also see an empty `gateway-traces-security.out` file, as the routing configuration creates output files immediately, even if no matching spans have been processed yet.
32+
If you check `gateway-traces-route1-regular.out`, it will contain the `span` sent by `loadgen`. You will also see an empty `gateway-traces-route2-security..out` file, as the routing configuration creates output files immediately, even if no matching spans have been processed yet.
3333
{{% /notice %}}
3434

3535
**Send a Security Span**: In the **Loadgen terminal** window send a security span using the `security` flag:
@@ -38,14 +38,14 @@ If you check `gateway-traces-standard.out`, it will contain the `span` sent by `
3838
../loadgen -security -count 1
3939
```
4040

41-
Again, both the **Agent** and **Gateway** should display debug information, including the span you just sent. This time, the **Gateway** will write a line to the `gateway-traces-security.out` file, which is designated for spans where the `deployment.environment` resource attribute matches `"security-applications"`.
42-
The `gateway-traces-standard.out` should be unchanged.
41+
Again, both the **Agent** and **Gateway** should display debug information, including the span you just sent. This time, the **Gateway** will write a line to the `gateway-traces-route2-security.out` file, which is designated for spans where the `deployment.environment` resource attribute matches `"security-applications"`.
42+
The `gateway-traces-route1-regular.out` should be unchanged.
4343

4444
{{% tabs %}}
4545
{{% tab title="Validate resource attribute matches" %}}
4646

4747
```bash
48-
jq -c '.resourceSpans[] as $resource | $resource.scopeSpans[].spans[] | {spanId: .spanId, deploymentEnvironment: ($resource.resource.attributes[] | select(.key == "deployment.environment") | .value.stringValue)}' gateway-traces-security.out
48+
jq -c '.resourceSpans[] as $resource | $resource.scopeSpans[].spans[] | {spanId: .spanId, deploymentEnvironment: ($resource.resource.attributes[] | select(.key == "deployment.environment") | .value.stringValue)}' gateway-traces-route2-security.out
4949
```
5050

5151
{{% /tabs %}}
@@ -69,9 +69,9 @@ You can repeat this scenario multiple times, and each trace will be written to i
6969

7070
In this section, we successfully tested the routing connector in the gateway by sending different spans and verifying their destinations.
7171

72-
- **Regular spans** were correctly routed to `gateway-traces-standard.out`, confirming that spans without a matching `deployment.environment` attribute follow the default pipeline.
72+
- **Regular spans** were correctly routed to `gateway-traces-route1-regular.out`, confirming that spans without a matching `deployment.environment` attribute follow the default pipeline.
7373

74-
- **Security-related spans** were routed to `gateway-traces-security.out`, demonstrating that the routing rule based on `"deployment.environment": "security-applications"` works as expected.
74+
- **Security-related spans** were routed to `gateway-traces-route2-security.out`, demonstrating that the routing rule based on `"deployment.environment": "security-applications"` works as expected.
7575

7676
By inspecting the output files, we confirmed that the OpenTelemetry Collector *correctly evaluates span attributes and routes them to the appropriate destinations*. This validates that routing rules can effectively separate and direct telemetry data for different use cases.
7777

content/en/conf/1-advanced-collector/6-routing-data/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ time: 10 minutes
55
weight: 8
66
---
77

8-
The [**Routing Connector**](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/routingconnector) in OpenTelemetry is a powerful feature that allows you to direct data (`traces`, `metrics`, or `logs`) to different pipelines based on specific criteria. This is especially useful in scenarios where you want to apply different processing or exporting logic to subsets of your telemetry data.
8+
The [**Routing Connector**](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/routingconnector) in OpenTelemetry is a powerful feature that allows you to direct data (`traces`, `metrics`, or `logs`) to different pipelines/destinations based on specific criteria. This is especially useful in scenarios where you want to apply different processing or exporting logic to subsets of your telemetry data.
99

1010
For example, you might want to send *production* data to one exporter while directing *test* or *development* data to another. Similarly, you could route certain spans based on their attributes, such as service name, environment, or span name, to apply custom processing or storage logic.
1111

0 commit comments

Comments
 (0)