diff --git a/.changelog/3758.changed.txt b/.changelog/3758.changed.txt new file mode 100644 index 0000000000..604c587758 --- /dev/null +++ b/.changelog/3758.changed.txt @@ -0,0 +1 @@ +chore: simplify reading logs from multiple container runtimes \ No newline at end of file diff --git a/deploy/helm/sumologic/conf/logs/collector/common/filelog_receiver.yaml b/deploy/helm/sumologic/conf/logs/collector/common/filelog_receiver.yaml index db47cc9b1a..0466a99e8e 100644 --- a/deploy/helm/sumologic/conf/logs/collector/common/filelog_receiver.yaml +++ b/deploy/helm/sumologic/conf/logs/collector/common/filelog_receiver.yaml @@ -40,174 +40,64 @@ filelog/containers: include_file_name: false include_file_path: true operators: - ## Detect the container runtime log format - ## Can be: docker-shim, CRI-O and containerd - - id: get-format + ## Parse the container runtime log format automatically + - type: container + add_metadata_from_filepath: true + + ## Reorganise attributes according to Sumo Logic requirements + ## - rename log.iostream to stream + - type: move + from: attributes["log.iostream"] + to: attributes["stream"] + ## Keep only the following attributes: + ## - stream + ## - k8s.pod.name + ## - k8s.container.name + ## - k8s.namespace.name + ## - log.file.path + ## - time if `sumologic.logs.container.keep_time_attribute` is set to `true` + - type: retain + id: keep-fields + fields: + - attributes["stream"] + - attributes["k8s.pod.name"] + - attributes["k8s.container.name"] + - attributes["k8s.namespace.name"] + - attributes["log.file.path"] +{{ if .Values.sumologic.logs.container.keep_time_attribute }} + - attributes["time"] +{{ end }} + + ## Strip trailing "\n" from the log body + - id: strip-trailing-newline-router +{{- if .Values.sumologic.logs.multiline.enabled }} + default: multiline +{{- else }} + default: merge-multiline-logs +{{- end }} routes: - - expr: 'body matches "^\\{"' - output: parser-docker - - expr: 'body matches "^[^ Z]+ "' - output: parser-crio - - expr: 'body matches "^[^ Z]+Z"' - output: parser-containerd + - expr: body matches "^.*\n$" + output: strip-trailing-newline type: router - ## Parse CRI-O format - - id: parser-crio - output: merge-cri-lines - parse_to: body - regex: '^(?P