Skip to content

Commit

Permalink
chore!: move parameters from fluentd.logs.containers into sumologic.l…
Browse files Browse the repository at this point in the history
…og.container

- move `fluentd.logs.containers.sourceHost` to `sumologic.log.container.sourceHost`
- move `fluentd.logs.containers.sourceName` to `sumologic.log.container.sourceName`
- move `fluentd.logs.contianers.sourceCategory` to `sumologic.log.container.sourceCategory`
- move `fluentd.logs.containers.sourceCategoryPrefix` to `sumologic.log.container.sourceCategoryPrefix`
- move `fluentd.logs.contianers.sourceCategoryReplaceDash` to `sumologic.log.container.sourceCategoryReplaceDash`
- move `fluentd.logs.containers.excludeContainerRegex` to `sumologic.log.container.excludeContainerRegex`
- move `fluentd.logs.containers.excludeHostRegex` to `sumologic.log.container.excludeHostRegex`
- move `fluentd.logs.containers.excludeNamespaceRegex` to `sumologic.log.container.excludeNamespaceRegex`
- move `fluentd.logs.containers.excludePodRegex` to `sumologic.log.container.excludePodRegex`
- move `fluentd.logs.containers.sourceHost` to `sumologic.log.container.sourceHost`
- move `fluentd.logs.containers.perContainerAnnotationsEnabled` to `sumologic.log.container.perContainerAnnotationsEnabled`
- move `fluentd.logs.containers.perContainerAnnotationPrefixes` to `sumologic.log.container.perContainerAnnotationPrefixes`
  • Loading branch information
kasia-kujawa committed Nov 24, 2022
1 parent 95fe79f commit 96db415
Show file tree
Hide file tree
Showing 11 changed files with 425 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
source_name {{ .Values.fluentd.logs.containers.sourceName | quote }}
source_host {{ .Values.fluentd.logs.containers.sourceHost | quote }}
source_name {{ .Values.sumologic.logs.container.sourceName | quote }}
source_host {{ .Values.sumologic.logs.container.sourceHost | quote }}
log_format {{ .Values.fluentd.logs.output.logFormat | quote }}
source_category {{ .Values.fluentd.logs.containers.sourceCategory | quote }}
source_category_prefix {{ .Values.fluentd.logs.containers.sourceCategoryPrefix | quote }}
source_category_replace_dash {{ .Values.fluentd.logs.containers.sourceCategoryReplaceDash | quote }}
exclude_pod_regex {{ .Values.fluentd.logs.containers.excludePodRegex | quote }}
exclude_container_regex {{ .Values.fluentd.logs.containers.excludeContainerRegex | quote }}
exclude_host_regex {{ .Values.fluentd.logs.containers.excludeHostRegex | quote }}
per_container_annotations_enabled {{ .Values.fluentd.logs.containers.perContainerAnnotationsEnabled }}
per_container_annotation_prefixes {{ join "," .Values.fluentd.logs.containers.perContainerAnnotationPrefixes }}
source_category {{ .Values.sumologic.logs.container.sourceCategory | quote }}
source_category_prefix {{ .Values.sumologic.logs.container.sourceCategoryPrefix | quote }}
source_category_replace_dash {{ .Values.sumologic.logs.container.sourceCategoryReplaceDash | quote }}
exclude_pod_regex {{ .Values.sumologic.logs.container.excludePodRegex | quote }}
exclude_container_regex {{ .Values.sumologic.logs.container.excludeContainerRegex | quote }}
exclude_host_regex {{ .Values.sumologic.logs.container.excludeHostRegex | quote }}
per_container_annotations_enabled {{ .Values.sumologic.logs.container.perContainerAnnotationsEnabled }}
per_container_annotation_prefixes {{ join "," .Values.sumologic.logs.container.perContainerAnnotationPrefixes }}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<filter containers.**>
@type kubernetes_sumologic
@include logs.kubernetes.sumologic.filter.conf
exclude_namespace_regex {{ include "fluentd.excludeNamespaces" . }}
exclude_namespace_regex {{ include "logs.excludeNamespaces" . }}
</filter>
<filter **>
@type record_modifier
Expand Down
22 changes: 11 additions & 11 deletions deploy/helm/sumologic/conf/logs/otelcol/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,23 +189,23 @@ processors:
- from: build_hostname
source/containers:
collector: {{ .Values.sumologic.collectorName | default .Values.sumologic.clusterName | quote }}
source_host: "%{k8s.pod.hostname}"
source_name: "%{k8s.namespace.name}.%{k8s.pod.name}.%{k8s.container.name}"
source_category: "%{k8s.namespace.name}/%{k8s.pod.pod_name}"
source_category_prefix: {{ .Values.fluentd.logs.containers.sourceCategoryPrefix | quote }}
source_category_replace_dash: {{ .Values.fluentd.logs.containers.sourceCategoryReplaceDash | quote }}
source_host: {{ .Values.sumologic.logs.container.sourceHost | quote }}
source_name: {{ .Values.sumologic.logs.container.sourceName | quote }}
source_category: {{ .Values.sumologic.logs.container.sourceCategory | quote }}
source_category_prefix: {{ .Values.sumologic.logs.container.sourceCategoryPrefix | quote }}
source_category_replace_dash: {{ .Values.sumologic.logs.container.sourceCategoryReplaceDash | quote }}
exclude:
k8s.namespace.name: {{ include "fluentd.excludeNamespaces" . }}
k8s.pod.name: {{ .Values.fluentd.logs.containers.excludePodRegex | quote }}
k8s.container.name: {{ .Values.fluentd.logs.containers.excludeContainerRegex | quote }}
k8s.pod.hostname: {{ .Values.fluentd.logs.containers.excludeHostRegex | quote }}
k8s.namespace.name: {{ include "logs.excludeNamespaces" . }}
k8s.pod.name: {{ .Values.sumologic.logs.container.excludePodRegex | quote }}
k8s.container.name: {{ .Values.sumologic.logs.container.excludeContainerRegex | quote }}
k8s.pod.hostname: {{ .Values.sumologic.logs.container.excludeHostRegex | quote }}
annotation_prefix: "pod_annotations_"
pod_template_hash_key: "pod_labels_pod-template-hash"
pod_name_key: "k8s.pod.pod_name"
pod_key: "k8s.pod.name"
container_annotations:
enabled: {{ .Values.fluentd.logs.containers.perContainerAnnotationsEnabled }}
prefixes: {{ toJson .Values.fluentd.logs.containers.perContainerAnnotationPrefixes }}
enabled: {{ .Values.sumologic.logs.container.perContainerAnnotationsEnabled }}
prefixes: {{ toJson .Values.sumologic.logs.container.perContainerAnnotationPrefixes }}
{{ end }}
{{ if .Values.sumologic.logs.systemd.enabled }}
## Systemd related processors
Expand Down
10 changes: 5 additions & 5 deletions deploy/helm/sumologic/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1245,13 +1245,13 @@ Returns list of namespaces to exclude
Example:
{{ include "fluentd.excludeNamespaces" . }}
{{ include "logs.excludeNamespaces" . }}
*/}}
{{- define "fluentd.excludeNamespaces" -}}
{{- $excludeNamespaceRegex := .Values.fluentd.logs.containers.excludeNamespaceRegex | quote -}}
{{- define "logs.excludeNamespaces" -}}
{{- $excludeNamespaceRegex := .Values.sumologic.logs.container.excludeNamespaceRegex | quote -}}
{{- if eq .Values.sumologic.collectionMonitoring false -}}
{{- if .Values.fluentd.logs.containers.excludeNamespaceRegex -}}
{{- $excludeNamespaceRegex = printf "%s|%s" .Release.Namespace .Values.fluentd.logs.containers.excludeNamespaceRegex | quote -}}
{{- if .Values.sumologic.logs.container.excludeNamespaceRegex -}}
{{- $excludeNamespaceRegex = printf "%s|%s" .Release.Namespace .Values.sumologic.logs.container.excludeNamespaceRegex | quote -}}
{{- else -}}
{{- $excludeNamespaceRegex = printf "%s" .Release.Namespace | quote -}}
{{- end -}}
Expand Down
63 changes: 29 additions & 34 deletions deploy/helm/sumologic/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,35 @@ sumologic:
container:
enabled: true

## Set the _sourceHost metadata field in Sumo Logic.
sourceHost: "%{k8s.pod.hostname}"
## Set the _sourceName metadata field in Sumo Logic.
sourceName: "%{k8s.namespace.name}.%{k8s.pod.name}.%{k8s.container.name}"
## Set the _sourceCategory metadata field in Sumo Logic.
sourceCategory: "%{k8s.namespace.name}/%{k8s.pod.pod_name}"
## Set the prefix, for _sourceCategory metadata.
sourceCategoryPrefix: "kubernetes/"
## Used to replace - with another character.
sourceCategoryReplaceDash: "/"

## A regular expression for containers.
## Matching containers will be excluded from Sumo. The logs will still be sent to logs provider (FluentD/otelcol).
excludeContainerRegex: ""
## A regular expression for hosts.
## Matching hosts will be excluded from Sumo. The logs will still be sent to logs provider (FluentD/otelcol).
excludeHostRegex: ""
## A regular expression for namespaces.
## Matching namespaces will be excluded from Sumo. The logs will still be sent to logs provider (FluentD/otelcol).
excludeNamespaceRegex: ""
## A regular expression for pods.
## Matching pods will be excluded from Sumo. The logs will still be sent to logs provider (FluentD/otelcol).
excludePodRegex: ""

## Defines whether container-level pod annotations are enabled.
perContainerAnnotationsEnabled: false
## Defines the list of prefixes of container-level pod annotations.
perContainerAnnotationPrefixes: []

systemd:
enabled: true
# systemd units to collect logs from
Expand Down Expand Up @@ -596,40 +625,6 @@ fluentd:
## Override output section for container logs. Leave empty for the default output section
overrideOutputConf: |-
## Set the _sourceHost metadata field in Sumo Logic.
sourceHost: ""
## Set the _sourceName metadata field in Sumo Logic.
sourceName: "%{namespace}.%{pod}.%{container}"
## Set the _sourceCategory metadata field in Sumo Logic.
sourceCategory: "%{namespace}/%{pod_name}"
## Set the prefix, for _sourceCategory metadata.
sourceCategoryPrefix: "kubernetes/"
## Used to replace - with another character.
sourceCategoryReplaceDash: "/"

## A regular expression for containers.
## Matching containers will be excluded from Sumo. The logs will still be sent to FluentD.
excludeContainerRegex: ""
## A regular expression for hosts.
## Matching hosts will be excluded from Sumo. The logs will still be sent to FluentD.
excludeHostRegex: ""
## A regular expression for namespaces.
## Matching namespaces will be excluded from Sumo. The logs will still be sent to FluentD.
excludeNamespaceRegex: ""
## A regular expression for pods.
## Matching pods will be excluded from Sumo. The logs will still be sent to FluentD.
excludePodRegex: ""

## Defines whether container-level pod annotations are enabled.
## Setting this to `true` might slightly affect Fluentd performance.
## See below link for full reference:
## https://github.com/SumoLogic/sumologic-kubernetes-fluentd/tree/v1.14.6-sumo-5/fluent-plugin-kubernetes-sumologic#container-level-pod-annotations
perContainerAnnotationsEnabled: false
## Defines the list of prefixes of container-level pod annotations.
## See below link for full reference:
## https://github.com/SumoLogic/sumologic-kubernetes-fluentd/tree/v1.14.6-sumo-5/fluent-plugin-kubernetes-sumologic#container-level-pod-annotations
perContainerAnnotationPrefixes: []

## ref: https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter#configuration
k8sMetadataFilter:
## Option to control the enabling of metadata filter plugin watch.
Expand Down
19 changes: 19 additions & 0 deletions tests/helm/metadata_logs_fluentd/static/default_v2.input.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
sumologic:
collectorName: my_collectorName
logs:
metadata:
provider: fluentd

container:
enabled: true
sourceHost: # in v2 this parameter is not set in values.yaml
sourceName: "%{namespace}.%{pod}.%{container}"
sourceCategory: "%{namespace}/%{pod_name}"
sourceCategoryPrefix: "kubernetes/"
sourceCategoryReplaceDash: "/"
excludeContainerRegex: ""
excludeHostRegex: ""
excludeNamespaceRegex: ""
excludePodRegex: ""
perContainerAnnotationsEnabled: false
perContainerAnnotationPrefixes: []
Loading

0 comments on commit 96db415

Please sign in to comment.