You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this exercise, you will configure the **Routing Connector** in the `gateway.yaml` file. This setup enables the **Gateway** to route traces based on the `deployment.environment` attribute in the spans you send. By implementing this, you can process and handle traces differently depending on their attributes.
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).
**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`:
14
+
15
+
```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
22
+
```
23
+
11
24
In OpenTelemetry configuration files, `connectors` have their own dedicated section, similar to receivers and processors.
12
25
13
26
**Add the `routing` connector**:
14
27
In the **Gateway terminal** window, edit `gateway.yaml` and uncomment the `#connectors:` section. Then, add the following below the `connectors:` section:
15
28
16
29
```yaml
17
-
connectors:
18
30
routing:
19
-
default_pipelines: [traces/standard]# Default pipeline if no rule matches
31
+
default_pipelines: [traces/route1] # Default pipeline if no rule matches
20
32
error_mode: ignore # Ignore errors in routing
21
33
table: # Define routing rules
22
34
# Routes spans to a target pipeline if the resourceSpan attribute matches the rule
23
35
- statement: route() where attributes["deployment.environment"] == "security-applications"
24
-
pipelines: [traces/security] # Target pipeline
25
-
```
26
-
27
-
The rules above apply to traces, but this approach also applies to `metrics` and `logs`, allowing them to be routed based on attributes in `resourceMetrics` or `resourceLogs`.
28
-
29
-
**Configure `file:` exporters**: The `routing` connector requires separate targets for routing. In the `exporters:` section, add two file exporters, `file/traces/security` and `file/traces/standard`, to ensure data is directed correctly.
30
-
31
-
```yaml
32
-
file/traces/standard: # Exporter for regular traces
33
-
path: "./gateway-traces-standard.out" # Path for saving trace data
34
-
append: false # Overwrite the file each time
35
-
file/traces/security: # Exporter for security traces
36
-
path: "./gateway-traces-security.out" # Path for saving trace data
Copy file name to clipboardExpand all lines: content/en/conf/1-advanced-collector/6-routing-data/6-2-pipelines.md
+26-26Lines changed: 26 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,26 +8,24 @@ weight: 2
8
8
9
9
**Update the `traces` pipeline to use routing**:
10
10
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.
12
-
2. Remove all processors and replace it with an empty array (`[]`). These are now defined in the `traces/standard` and `traces/security` pipelines.
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.
13
12
14
13
```yaml
15
-
pipelines:
16
-
traces: # Original traces pipeline
17
-
receivers:
18
-
- otlp # OTLP Receiver
19
-
processors: []
20
-
exporters:
21
-
- routing # Routing Connector
14
+
traces: # Traces pipeline
15
+
receivers:
16
+
- otlp # OTLP receiver
17
+
processors: [] # Processors for traces
18
+
exporters:
19
+
- routing
22
20
```
23
21
24
-
**Add both the `standard` and `security` traces pipelines**:
22
+
**Add both the `route1` and `route2` traces pipelines**:
25
23
26
-
1. **Configure the Security pipeline**: This pipeline will handle all spans that match the routing rule for `security`.
24
+
1. **Configure Route1 pipeline**: This pipeline will handle all spans that match the routing rule for `route1`.
27
25
This uses `routing` as its receiver. Place it below the existing `traces:` pipeline:
28
26
29
27
```yaml
30
-
traces/security: # New Security Traces/Spans Pipeline
28
+
traces/route1: # Default pipeline for unmatched spans
31
29
receivers:
32
30
- routing # Receive data from the routing connector
33
31
processors:
@@ -36,7 +34,7 @@ This uses `routing` as its receiver. Place it below the existing `traces:` pipel
36
34
- batch
37
35
exporters:
38
36
- debug # Debug Exporter
39
-
- file/traces/security # File Exporter for spans matching rule
37
+
- file/traces/route1 # File Exporter for unmatched spans
40
38
```
41
39
42
40
2. **Add the Standard pipeline**: This pipeline processes all spans that do not match the routing rule.
@@ -57,6 +55,7 @@ This pipeline is also using `routing` as its receiver. Add this below the `trace
57
55
58
56
{{% /notice %}}
59
57
58
+
<!--
60
59
Validate the agent configuration using **[otelbin.io](https://www.otelbin.io/)**. For reference, the `traces:` section of your pipelines will look similar to this:
0 commit comments