8
8
{ {- define " logs-collector.loggingDaemonsetConfig" -} }
9
9
{ {- $values := deepCopy .Values -} }
10
10
{ {- $data := dict " Values" $values | mustMergeOverwrite (deepCopy .) -} }
11
- { {- $config := include " logs-collector.baseLoggingConfig" $data -} }
12
- { {- tpl $config . -} }
11
+ { {- $config := deepCopy .Values.config } }
12
+
13
+ { {- if (eq (include " logs-collector.resourceDetectionEnabled" .) " true" ) } }
14
+ { {- include " logs-collector.addResourceDetectionProcessors" (dict " config" $config " distribution" .Values.global.distribution) } }
15
+ { {- end } }
16
+
17
+ { {- tpl ($config | toYaml) . -} }
13
18
{ {- end } }
14
19
15
20
# Build config file for standalone logs Collector
16
21
{ {- define " logs-collector.loggingStandaloneConfig" -} }
17
22
{ {- $values := deepCopy .Values -} }
18
23
{ {- $data := dict " Values" $values | mustMergeOverwrite (deepCopy .) -} }
19
- { {- $config := include " logs-collector.baseLoggingConfig" $data -} }
20
- { {- tpl $config . -} }
24
+ { {- $config := deepCopy .Values.config } }
25
+
26
+ { {- if (eq (include " logs-collector.resourceDetectionEnabled" .) " true" ) } }
27
+ { {- include " logs-collector.addResourceDetectionProcessors" (dict " config" $config " distribution" .Values.global.distribution) } }
28
+ { {- end } }
29
+
30
+ { {- tpl ($config | toYaml) . -} }
21
31
{ {- end } }
22
32
23
33
{ {/* Build the list of port for service */} }
52
62
{ {- end } }
53
63
{ {- end } }
54
64
{ {- end } }
65
+ { {- end } }
66
+
67
+ { {/* Build config for Resource Detection according to distribution */} }
68
+ { {- define " logs-collector.resourceDetectionConfig" -} }
69
+ { {- if . } }
70
+ { {- if eq . " eks" } }
71
+ resourcedetection/distribution:
72
+ timeout: 15s
73
+ detectors: ["eks", "ec2"]
74
+ { {- else if eq . " aks" } }
75
+ resourcedetection/distribution:
76
+ detectors: ["aks", "azure"]
77
+ { {- else if eq . " gke" } }
78
+ resourcedetection/distribution:
79
+ detectors: ["gcp"]
80
+ { {- else } }
81
+ resourcedetection/all:
82
+ detectors: [ec2, azure, gcp]
83
+ { {- end } }
84
+ { {- else } }
85
+ resourcedetection/all:
86
+ detectors: [ec2, azure, gcp]
87
+ { {- end } }
88
+ { {- end } }
89
+
90
+ { {/* Append Resource Detection to Opentelemetry config */} }
91
+ { {- define " logs-collector.addResourceDetectionProcessors" -} }
92
+ { {- $config := .config -} }
93
+ { {- $resDetectionConfig := (include " logs-collector.resourceDetectionConfig" .distribution | fromYaml) } }
94
+ { {- if $resDetectionConfig } }
95
+ { {- range $key , $value := $resDetectionConfig } }
96
+ { {- $_ := set $config " processors" (merge (index $config " processors" ) (dict $key $value )) } }
97
+ { {- $_ := set (index $config " service" " pipelines" " logs" ) " processors" (prepend (index $config " service" " pipelines" " logs" " processors" ) $key ) } }
98
+ { {- end } }
99
+ { {- end } }
55
100
{ {- end } }
0 commit comments