diff --git a/CHANGELOG.md b/CHANGELOG.md index c1ec1e47da..7ecf5ebb16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - chore: remove support for AKS 1.22 [#2756] - feat(logs): add daemonset and statefulset to default fields [#2766] - feat: collect metrics from otelcol event collector [#2754] +- feat(logs): parse JSON logs [#2773] ### Fixed @@ -37,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#2766]: https://github.com/SumoLogic/sumologic-kubernetes-collection/pull/2766 [#2754]: https://github.com/SumoLogic/sumologic-kubernetes-collection/pull/2754 [#2771]: https://github.com/SumoLogic/sumologic-kubernetes-collection/pull/2771 +[#2773]: https://github.com/SumoLogic/sumologic-kubernetes-collection/pull/2773 [v1.15.3-sumo-0]: https://github.com/SumoLogic/sumologic-kubernetes-fluentd/releases/tag/v1.15.3-sumo-0 [Unreleased]: https://github.com/SumoLogic/sumologic-kubernetes-collection/compare/v3.0.0-beta.0...main diff --git a/deploy/helm/sumologic/conf/logs/otelcol/config.yaml b/deploy/helm/sumologic/conf/logs/otelcol/config.yaml index 146927cf83..b5cfb0f77a 100644 --- a/deploy/helm/sumologic/conf/logs/otelcol/config.yaml +++ b/deploy/helm/sumologic/conf/logs/otelcol/config.yaml @@ -205,6 +205,14 @@ processors: container_annotations: enabled: {{ .Values.sumologic.logs.container.perContainerAnnotationsEnabled }} prefixes: {{ toJson .Values.sumologic.logs.container.perContainerAnnotationPrefixes }} + ## logstransformprocessor is experimental, but the same functionality in transformprocessor doesn't offer robust enough error handling + ## TODO: use transformprocessor here after https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16519 is closed + logstransform/containers_parse_json: + operators: + - type: json_parser + parse_from: body + parse_to: body + if: body matches "^{.*" {{ end }} {{ if .Values.sumologic.logs.systemd.enabled }} ## Systemd related processors @@ -421,6 +429,7 @@ service: - k8s_tagger - resource/add_cluster - source/containers + - logstransform/containers_parse_json - resource/remove_k8s_pod_pod_name - resource/drop_annotations - resource/containers_copy_node_to_host diff --git a/tests/helm/metadata_logs_otc/static/otel.output.yaml b/tests/helm/metadata_logs_otc/static/otel.output.yaml index 8b6bd47d27..207e2e28c1 100644 --- a/tests/helm/metadata_logs_otc/static/otel.output.yaml +++ b/tests/helm/metadata_logs_otc/static/otel.output.yaml @@ -222,6 +222,12 @@ data: passthrough: false pod_association: - from: build_hostname + logstransform/containers_parse_json: + operators: + - if: body matches "^{.*" + parse_from: body + parse_to: body + type: json_parser memory_limiter: check_interval: 5s limit_percentage: 75 @@ -305,6 +311,7 @@ data: - k8s_tagger - resource/add_cluster - source/containers + - logstransform/containers_parse_json - resource/remove_k8s_pod_pod_name - resource/drop_annotations - resource/containers_copy_node_to_host diff --git a/tests/helm/metadata_logs_otc/static/templates.output.yaml b/tests/helm/metadata_logs_otc/static/templates.output.yaml index 3b7de2c232..5a4ce34d41 100644 --- a/tests/helm/metadata_logs_otc/static/templates.output.yaml +++ b/tests/helm/metadata_logs_otc/static/templates.output.yaml @@ -222,6 +222,12 @@ data: passthrough: false pod_association: - from: build_hostname + logstransform/containers_parse_json: + operators: + - if: body matches "^{.*" + parse_from: body + parse_to: body + type: json_parser memory_limiter: check_interval: 5s limit_percentage: 75 @@ -305,6 +311,7 @@ data: - k8s_tagger - resource/add_cluster - source/containers + - logstransform/containers_parse_json - resource/remove_k8s_pod_pod_name - resource/drop_annotations - resource/containers_copy_node_to_host