Skip to content

Commit 84b753a

Browse files
authored
logzio-logs-collector version 2.0.2
[Feature] add dynamic auto resource detection
2 parents 46702b2 + ed374fc commit 84b753a

File tree

7 files changed

+77
-7
lines changed

7 files changed

+77
-7
lines changed

charts/logzio-logs-collector/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Changes by Version
22

33
<!-- next version -->
4+
## 2.0.2
5+
- Add support for auto resource detection with `distribution` and `resourceDetection.enabled` flags.
6+
47
## 2.0.1
58
- Add support for global tolerations
9+
610
## 2.0.0
711
- **Breaking changes**
812
- Secret values are now global

charts/logzio-logs-collector/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: logzio-logs-collector
3-
version: 2.0.1
3+
version: 2.0.2
44
description: kubernetes logs collection agent for logz.io based on opentelemetry collector
55
type: application
66
home: https://logz.io/

charts/logzio-logs-collector/templates/_config.tpl

+49-4
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,26 @@
88
{{- define "logs-collector.loggingDaemonsetConfig" -}}
99
{{- $values := deepCopy .Values -}}
1010
{{- $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) . -}}
1318
{{- end }}
1419

1520
# Build config file for standalone logs Collector
1621
{{- define "logs-collector.loggingStandaloneConfig" -}}
1722
{{- $values := deepCopy .Values -}}
1823
{{- $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) . -}}
2131
{{- end }}
2232

2333
{{/* Build the list of port for service */}}
@@ -52,4 +62,39 @@
5262
{{- end }}
5363
{{- end }}
5464
{{- 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 }}
55100
{{- end }}

charts/logzio-logs-collector/templates/_helpers.tpl

+14
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,17 @@ listener.logz.io
204204
{{- end -}}
205205
{{- end }}
206206

207+
{{/*
208+
Returns the value of resource detection enablement state
209+
*/}}
210+
{{- define "logs-collector.resourceDetectionEnabled" -}}
211+
{{- if (hasKey .Values "resourceDetection") }}
212+
{{- if (hasKey .Values.resourceDetection "enabled") }}
213+
{{- .Values.resourceDetection.enabled }}
214+
{{- else }}
215+
{{- .Values.global.resourceDetection.enabled }}
216+
{{- end }}
217+
{{- else }}
218+
{{- .Values.global.resourceDetection.enabled }}
219+
{{- end }}
220+
{{- end }}

charts/logzio-logs-collector/templates/configmap-agent.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ metadata:
88
labels:
99
{{- include "logs-collector.labels" . | nindent 4 }}
1010
data:
11-
relay: {{- include "logs-collector.loggingDaemonsetConfig" . | nindent 4 }}
11+
relay: |
12+
{{- include "logs-collector.loggingDaemonsetConfig" . | nindent 4 }}
1213
{{- end }}
1314
{{ end }}

charts/logzio-logs-collector/templates/configmap-standalone.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ metadata:
88
labels:
99
{{- include "logs-collector.labels" . | nindent 4 }}
1010
data:
11-
relay: {{- include "logs-collector.loggingStandaloneConfig" . | nindent 4 }}
11+
relay: |
12+
{{- include "logs-collector.loggingStandaloneConfig" . | nindent 4 }}
1213
{{- end }}
1314
{{ end }}

charts/logzio-logs-collector/values.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ global:
3232
logzioRegion: "us"
3333
# Secret with your custom endpoint, for example:http://endpoint:8080. Overrides secrets.LogzioRegion listener adress
3434
customLogsEndpoint: ""
35+
# Optional - Identifier for the Kubernetes distribution used. One of "eks", "aks" or "gke".
36+
distribution: ""
37+
# Optional - Control enabling of the OpenTelemetry Collector's resource detection feature. Dependent on `distribution` value.
38+
resourceDetection:
39+
enabled: false
3540

3641
standaloneCollector:
3742
# Number of replicas in standalone collector mode

0 commit comments

Comments
 (0)