Skip to content

Commit 927db20

Browse files
committed
feat: collect all pods logs
1 parent f7f22b3 commit 927db20

File tree

2 files changed

+73
-3
lines changed

2 files changed

+73
-3
lines changed

charts/uptrace/templates/otelcol-deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ spec:
2626
volumeMounts:
2727
- name: config
2828
mountPath: /etc/config
29+
- name: varlogpods
30+
mountPath: /var/log/pods
31+
readOnly: true
2932
imagePullPolicy: IfNotPresent
3033
env:
3134
{{- toYaml .Values.uptrace.env | nindent 12 }}
3235
volumes:
3336
- name: config
3437
configMap:
3538
name: otelcontribcol
39+
- name: varlogpods
40+
hostPath:
41+
path: /var/log/pods
3642
{{ end }}

charts/uptrace/values.yaml

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,83 @@ otelcol:
113113
auth_type: "serviceAccount"
114114
endpoint: "https://${env:K8S_NODE_NAME}:10250"
115115
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+
116178
processors:
117179
resourcedetection:
118-
detectors: ['system']
180+
detectors: ['system', 'k8snode']
119181
cumulativetodelta:
120182
batch:
121183
send_batch_size: 10000
122184
timeout: 15s
185+
123186
exporters:
124187
debug:
125188
otlp/local:
126189
endpoint: http://my-uptrace:14317
127190
tls: { insecure: true }
128191
headers: { 'uptrace-dsn': 'http://project1_secret_token@localhost:14317/1' }
192+
129193
service:
130194
pipelines:
131195
traces:
@@ -137,8 +201,8 @@ otelcol:
137201
processors: [cumulativetodelta, batch]
138202
exporters: [debug, otlp/local]
139203
logs:
140-
receivers: [otlp, k8s_cluster]
141-
processors: [batch]
204+
receivers: [otlp, k8s_cluster, filelog]
205+
processors: [batch, resourcedetection]
142206
exporters: [debug, otlp/local]
143207
144208
nameOverride: ''

0 commit comments

Comments
 (0)