1
1
{{- define "clusterAgent.otelCollectorConfig" -}}
2
+ {{ $logCollectionEnabled := .Values.clusterCollection.logs.enabled }}
3
+ {{ $watchdogLogsEnabled := and .Values.watchdog.enabled .Values.watchdog.logs.enabled }}
2
4
receivers :
3
- {{- if or .Values.watchdog.logs.enabled .Values.watchdog.logs.include }}
4
- filelog/watchdog :
5
- include :
6
- - /var/log/pods/{{ .Release.Namespace }}_{{ include "helm.fullname" . }}-controller-manager_*/*/*.log
7
- - /var/log/pods/{{ .Release.Namespace }}_{{ include "helm.fullname" . }}-telemetry-proxy_*/*/*.log
8
- {{- end }}
5
+ {{ if $logCollectionEnabled }}
9
6
filelog/application :
10
7
include :
11
- {{ if .Values.clusterCollection.logs.include }}
12
- {{- range .Values.clusterCollection.logs.include }}
8
+ {{ if .Values.clusterCollection.logs.include }}
9
+ {{- range .Values.clusterCollection.logs.include }}
13
10
- /var/log/pods/{{ .namespacePattern | default "*" }}_{{ .podPattern | default "*" }}_*/{{ .containerPattern | default "*" }}/*.log
14
- {{- end }}
15
- {{- else }}
11
+ {{- end }}
12
+ {{- else }}
16
13
- /var/log/pods/*/*/*.log
17
- {{- end }}
14
+ {{- end }}
18
15
exclude :
16
+ - /var/log/pods/{{ .Release.Namespace }}_*/*/*.log
19
17
- /var/log/pods/kube-system_*/*/*.log
20
- - /var/log/pods/lumigo-system_*/*/*.log
21
18
# Exclude logs from the otlp-sink in tests (Kind cluster)
22
19
- /var/log/pods/local-path-storage_*/*/*.log
23
20
- /var/log/pods/otlp-sink_*/*/*.log
@@ -30,76 +27,20 @@ receivers:
30
27
include_file_path : true
31
28
include_file_name : false
32
29
operators :
33
- # Find out which format is used by kubernetes
34
- - type : router
35
- id : get-format
36
- routes :
37
- - output : parser-docker
38
- expr : ' body matches "^\\{"'
39
- - output : parser-crio
40
- expr : ' body matches "^[^ Z]+ "'
41
- - output : parser-containerd
42
- expr : ' body matches "^[^ Z]+Z"'
43
- # Parse CRI-O format
44
- - type : regex_parser
45
- id : parser-crio
46
- regex :
47
- ' ^(?P<time>[^ Z]+) (?P<stream>stdout|stderr) (?P<logtag>[^ ]*) ?(?P<log>.*)$'
48
- output : overwrite-log-body
49
- timestamp :
50
- parse_from : attributes.time
51
- layout_type : gotime
52
- layout : ' 2006-01-02T15:04:05.999999999Z07:00'
53
- # Parse CRI-Containerd format
54
- - type : regex_parser
55
- id : parser-containerd
56
- regex :
57
- ' ^(?P<time>[^ ^Z]+Z) (?P<stream>stdout|stderr) (?P<logtag>[^ ]*) ?(?P<log>.*)$'
58
- output : overwrite-log-body
59
- timestamp :
60
- parse_from : attributes.time
61
- layout : ' %Y-%m-%dT%H:%M:%S.%LZ'
62
- # Parse Docker format
63
- - type : json_parser
64
- id : parser-docker
65
- output : overwrite-log-body
66
- timestamp :
67
- parse_from : attributes.time
68
- layout : ' %Y-%m-%dT%H:%M:%S.%LZ'
69
- - type : move
70
- id : overwrite-log-body
71
- from : attributes["log"]
72
- to : body
73
- # best effort attempt to parse the body as a stringified JSON object
74
- - type : json_parser
75
- parse_to : body
76
- on_error : send_quiet
77
- # Extract metadata from file path
78
- - type : regex_parser
79
- id : extract-metadata-from-filepath
80
- regex : ' ^.*\/(?P<namespace>[^_]+)_(?P<pod_name>[^_]+)_(?P<uid>[a-f0-9\-]{36})\/(?P<container_name>[^\._]+)\/(?P<restart_count>\d+)\.log$'
81
- parse_from : attributes["log.file.path"]
82
- cache :
83
- size : 128 # default maximum amount of Pods per Node is 110
84
- # Rename attributes
85
- - type : move
86
- from : attributes.stream
87
- to : attributes["log.iostream"]
88
- - type : move
89
- from : attributes.container_name
90
- to : resource["k8s.container.name"]
91
- - type : move
92
- from : attributes.namespace
93
- to : resource["k8s.namespace.name"]
94
- - type : move
95
- from : attributes.pod_name
96
- to : resource["k8s.pod.name"]
97
- - type : move
98
- from : attributes.restart_count
99
- to : resource["k8s.container.restart_count"]
100
- - type : move
101
- from : attributes.uid
102
- to : resource["k8s.pod.uid"]
30
+ {{ include "clusterAgent.otelCollectorConfig.filelogreceiver.operators" . | indent 4 }}
31
+ {{- end }}
32
+ {{- if $watchdogLogsEnabled }}
33
+ filelog/watchdog :
34
+ include :
35
+ - /var/log/pods/{{ .Release.Namespace }}_{{ include "helm.fullname" . }}-controller-manager-*_*/*/*.log
36
+ - /var/log/pods/{{ .Release.Namespace }}_{{ include "helm.fullname" . }}-telemetry-proxy-*_*/*/*.log
37
+ start_at : end
38
+ include_file_path : true
39
+ include_file_name : false
40
+ operators :
41
+ {{ include "clusterAgent.otelCollectorConfig.filelogreceiver.operators" . | indent 4 }}
42
+ {{- end }}
43
+
103
44
exporters :
104
45
otlphttp :
105
46
endpoint : ${env:LUMIGO_LOGS_ENDPOINT}
@@ -110,6 +51,7 @@ exporters:
110
51
verbosity : detailed
111
52
{{- end }}
112
53
processors :
54
+ batch :
113
55
transform/application :
114
56
log_statements :
115
57
- context : log
@@ -120,13 +62,15 @@ processors:
120
62
log_statements :
121
63
- context : log
122
64
statements :
123
- - set(instrumentation_scope.name, "lumigo-operator.watchdog_log_file_collector ")
65
+ - set(instrumentation_scope.name, "lumigo-operator.watchdog.log_file_collector ")
124
66
- set(resource.attributes["k8s.cluster.name"], "${env:KUBERNETES_CLUSTER_NAME}")
125
67
filter/drop_non_error_logs :
68
+ error_mode : propagate
126
69
logs :
127
70
log_record :
128
- - ' not IsMatch(body, ".*error.*")'
129
- batch :
71
+ - not IsMap(log.attributes["parsed_body"])
72
+ - not IsString(log.attributes["parsed_body"]["error"])
73
+
130
74
service :
131
75
{{- if .Values.debug.enabled }}
132
76
telemetry :
@@ -135,7 +79,7 @@ service:
135
79
encoding : json
136
80
{{- end }}
137
81
pipelines :
138
- {{- if .Values.watchdog.logs.enabled }}
82
+ {{ if $logCollectionEnabled }}
139
83
logs/application :
140
84
receivers :
141
85
- filelog/application
@@ -148,6 +92,7 @@ service:
148
92
- debug
149
93
{{- end }}
150
94
{{- end }}
95
+ {{- if $watchdogLogsEnabled }}
151
96
logs/watchdog :
152
97
receivers :
153
98
- filelog/watchdog
@@ -161,3 +106,4 @@ service:
161
106
- debug
162
107
{{- end }}
163
108
{{- end }}
109
+ {{- end }}
0 commit comments