Skip to content

Commit 22bcf50

Browse files
committed
tests: data: add context routing configuration examples
This patch adds YAML configuration examples for context-based conditional routing. Signed-off-by: Eduardo Silva <[email protected]>
1 parent 34c08fe commit 22bcf50

File tree

2 files changed

+211
-0
lines changed

2 files changed

+211
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
pipeline:
2+
inputs:
3+
- name: dummy
4+
routes:
5+
logs:
6+
- name: ctx_route
7+
condition:
8+
rules:
9+
- context: metadata
10+
field: "$['meta_key']"
11+
op: eq
12+
value: "meta"
13+
- context: group_attributes
14+
field: "$['group_attr']"
15+
op: eq
16+
value: "attr"
17+
- context: otel_resource_attributes
18+
field: "$['service.name']"
19+
op: eq
20+
value: "backend"
21+
to:
22+
outputs:
23+
- name: ctx_out
24+
outputs:
25+
- name: null
26+
alias: ctx_out
27+
match: "*"
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
pipeline:
2+
inputs:
3+
- name: opentelemetry
4+
port: 4318
5+
routes:
6+
logs:
7+
# Route 1: Match by resource attribute - service_name
8+
- name: service_a_logs
9+
condition:
10+
rules:
11+
- context: otel_resource_attributes
12+
field: "$service_name"
13+
op: eq
14+
value: "service-a"
15+
to:
16+
outputs:
17+
- name: service_a_destination
18+
19+
# Route 2: Match by resource attribute - service_version
20+
- name: version_2_logs
21+
condition:
22+
rules:
23+
- context: otel_resource_attributes
24+
field: "$service_version"
25+
op: eq
26+
value: "2.0.0"
27+
to:
28+
outputs:
29+
- name: version_2_destination
30+
31+
# Route 3: Match by resource attribute - environment
32+
- name: production_logs
33+
condition:
34+
rules:
35+
- context: otel_resource_attributes
36+
field: "$environment"
37+
op: eq
38+
value: "production"
39+
to:
40+
outputs:
41+
- name: production_destination
42+
43+
# Route 4: Match by scope name
44+
- name: scope_a_logs
45+
condition:
46+
rules:
47+
- context: otel_scope_metadata
48+
field: "$name"
49+
op: eq
50+
value: "scope-a"
51+
to:
52+
outputs:
53+
- name: scope_a_destination
54+
55+
# Route 5: Match by scope version
56+
- name: scope_v2_logs
57+
condition:
58+
rules:
59+
- context: otel_scope_metadata
60+
field: "$version"
61+
op: eq
62+
value: "v2.0"
63+
to:
64+
outputs:
65+
- name: scope_v2_destination
66+
67+
# Route 6: Match by scope attributes
68+
- name: backend_component_logs
69+
condition:
70+
rules:
71+
- context: otel_scope_attributes
72+
field: "$component"
73+
op: eq
74+
value: "backend"
75+
to:
76+
outputs:
77+
- name: backend_component_destination
78+
79+
# Route 7: Match by record body content
80+
- name: error_body_logs
81+
condition:
82+
rules:
83+
- context: body
84+
field: "$log"
85+
op: regex
86+
value: "error"
87+
to:
88+
outputs:
89+
- name: error_body_destination
90+
91+
# Route 8: Match by record attributes (metadata)
92+
- name: info_level_logs
93+
condition:
94+
rules:
95+
- context: metadata
96+
field: "$otlp['attributes']['level']"
97+
op: eq
98+
value: "info"
99+
to:
100+
outputs:
101+
- name: info_level_destination
102+
103+
# Route 9: Match by record attributes in metadata
104+
- name: select_operation_logs
105+
condition:
106+
rules:
107+
- context: metadata
108+
field: "$otlp['attributes']['operation']"
109+
op: eq
110+
value: "SELECT"
111+
to:
112+
outputs:
113+
- name: select_operation_destination
114+
115+
# Route 10: Default route for unmatched records
116+
- name: default_logs
117+
condition:
118+
default: true
119+
to:
120+
outputs:
121+
- name: default_destination
122+
123+
outputs:
124+
- name: file
125+
alias: service_a_destination
126+
match: service_a_logs
127+
path: otlp_routing_test_output
128+
file: service_a_logs.out
129+
130+
- name: file
131+
alias: version_2_destination
132+
match: version_2_logs
133+
path: otlp_routing_test_output
134+
file: version_2_logs.out
135+
136+
- name: file
137+
alias: production_destination
138+
match: production_logs
139+
path: otlp_routing_test_output
140+
file: production_logs.out
141+
142+
- name: file
143+
alias: scope_a_destination
144+
match: scope_a_logs
145+
path: otlp_routing_test_output
146+
file: scope_a_logs.out
147+
148+
- name: file
149+
alias: scope_v2_destination
150+
match: scope_v2_logs
151+
path: otlp_routing_test_output
152+
file: scope_v2_logs.out
153+
154+
- name: file
155+
alias: backend_component_destination
156+
match: backend_component_logs
157+
path: otlp_routing_test_output
158+
file: backend_component_logs.out
159+
160+
- name: file
161+
alias: error_body_destination
162+
match: error_body_logs
163+
path: otlp_routing_test_output
164+
file: error_body_logs.out
165+
166+
- name: file
167+
alias: info_level_destination
168+
match: info_level_logs
169+
path: otlp_routing_test_output
170+
file: info_level_logs.out
171+
172+
- name: file
173+
alias: select_operation_destination
174+
match: select_operation_logs
175+
path: otlp_routing_test_output
176+
file: select_operation_logs.out
177+
178+
- name: file
179+
alias: default_destination
180+
match: default_logs
181+
path: otlp_routing_test_output
182+
file: default_logs.out
183+
184+

0 commit comments

Comments
 (0)