@@ -113,19 +113,83 @@ otelcol:
113
113
auth_type: "serviceAccount"
114
114
endpoint: "https://${env:K8S_NODE_NAME}:10250"
115
115
insecure_skip_verify: true
116
+ filelog:
117
+ include: [ /var/log/pods/*/*/*.log ]
118
+ include_file_name: false
119
+ include_file_path: true
120
+ start_at: end # Recommended: use "end" for production
121
+ operators:
122
+ - type: router
123
+ id: get-format
124
+ routes:
125
+ - expr: body matches "^\\{"
126
+ output: parser-docker
127
+ - expr: body matches "^[^ Z]+ "
128
+ output: parser-crio
129
+ - expr: body matches "^[^ Z]+Z"
130
+ output: parser-containerd
131
+ - type: regex_parser
132
+ id: parser-crio
133
+ output: extract_metadata_from_filepath
134
+ regex: ^(?P<time>[^ Z]+) (?P<stream>stdout|stderr) (?P<logtag>[^ ]*) ?(?P<log>.*)$
135
+ timestamp:
136
+ layout: 2006-01-02T15:04:05.999999999Z07:00
137
+ layout_type: gotime
138
+ parse_from: attributes.time
139
+ - type: regex_parser
140
+ id: parser-containerd
141
+ output: extract_metadata_from_filepath
142
+ regex: ^(?P<time>[^ ^Z]+Z) (?P<stream>stdout|stderr) (?P<logtag>[^ ]*) ?(?P<log>.*)$
143
+ timestamp:
144
+ layout: '%Y-%m-%dT%H:%M:%S.%LZ'
145
+ parse_from: attributes.time
146
+ - type: json_parser
147
+ id: parser-docker
148
+ output: extract_metadata_from_filepath
149
+ timestamp:
150
+ layout: '%Y-%m-%dT%H:%M:%S.%LZ'
151
+ parse_from: attributes.time
152
+ - type: regex_parser
153
+ id: extract_metadata_from_filepath
154
+ parse_from: attributes["log.file.path"]
155
+ regex: ^.*\/(?P<namespace>[^_]+)_(?P<pod_name>[^_]+)_(?P<uid>[a-f0-9\-]+)\/(?P<container_name>[^\._]+)\/(?P<restart_count>\d+)\.log$
156
+ - type: move
157
+ from: attributes.stream
158
+ to: attributes["log.iostream"]
159
+ - type: move
160
+ from: attributes.container_name
161
+ to: resource["k8s.container.name"]
162
+ - type: move
163
+ from: attributes.namespace
164
+ to: resource["k8s.namespace.name"]
165
+ - type: move
166
+ from: attributes.pod_name
167
+ to: resource["k8s.pod.name"]
168
+ - type: move
169
+ from: attributes.restart_count
170
+ to: resource["k8s.container.restart_count"]
171
+ - type: move
172
+ from: attributes.uid
173
+ to: resource["k8s.pod.uid"]
174
+ - type: move
175
+ from: attributes.log
176
+ to: body
177
+
116
178
processors:
117
179
resourcedetection:
118
- detectors: ['system']
180
+ detectors: ['system', 'k8snode' ]
119
181
cumulativetodelta:
120
182
batch:
121
183
send_batch_size: 10000
122
184
timeout: 15s
185
+
123
186
exporters:
124
187
debug:
125
188
otlp/local:
126
189
endpoint: http://my-uptrace:14317
127
190
tls: { insecure: true }
128
191
headers: { 'uptrace-dsn': 'http://project1_secret_token@localhost:14317/1' }
192
+
129
193
service:
130
194
pipelines:
131
195
traces:
@@ -137,8 +201,8 @@ otelcol:
137
201
processors: [cumulativetodelta, batch]
138
202
exporters: [debug, otlp/local]
139
203
logs:
140
- receivers: [otlp, k8s_cluster]
141
- processors: [batch]
204
+ receivers: [otlp, k8s_cluster, filelog ]
205
+ processors: [batch, resourcedetection ]
142
206
exporters: [debug, otlp/local]
143
207
144
208
nameOverride : ' '
0 commit comments