From c295cb4c31d1f9d915006dbe227ec0498d618949 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek <58699848+sumo-drosiek@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:21:33 +0100 Subject: [PATCH] docs(upgrading): deprecate json_logs (#1377) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs(upgrading): deprecate json_logs Signed-off-by: Dominik Rosiek * Update docs/upgrading.md Co-authored-by: Mikołaj Świątek * docs: minor fixes Signed-off-by: Dominik Rosiek --------- Signed-off-by: Dominik Rosiek Co-authored-by: Mikołaj Świątek --- .changelog/1377.changed.txt | 1 + docs/upgrading.md | 151 +++++++++++++++++++++ pkg/exporter/sumologicexporter/exporter.go | 5 + 3 files changed, 157 insertions(+) create mode 100644 .changelog/1377.changed.txt diff --git a/.changelog/1377.changed.txt b/.changelog/1377.changed.txt new file mode 100644 index 0000000000..a77ace2fc0 --- /dev/null +++ b/.changelog/1377.changed.txt @@ -0,0 +1 @@ +chore(sumologicexporter): deprecate json_logs \ No newline at end of file diff --git a/docs/upgrading.md b/docs/upgrading.md index 9641627650..427a38683d 100644 --- a/docs/upgrading.md +++ b/docs/upgrading.md @@ -5,6 +5,7 @@ - [Change configuration for `syslogexporter`](#change-configuration-for-syslogexporter) - [`sumologic` exporter: deprecate `clear_logs_timestamp`](#sumologic-exporter-deprecate-clear_logs_timestamp) - [`sumologic` exporter: remove `routing_attributes_to_drop`](#sumologic-exporter-remove-routing_attributes_to_drop) + - [`sumologic` exporter: deprecate `json_logs`](#sumologic-exporter-deprecate-json_logs) - [Upgrading to v0.89.0-sumo-0](#upgrading-to-v0890-sumo-0) - [`remoteobserver` processor: renamed to `remotetap` processor](#remoteobserver-processor-renamed-to-remotetap-processor) - [`sumologic` exporter: changed default `timeout` from `5s` to `30s`](#sumologic-exporter-changed-default-timeout-from-5s-to-30s) @@ -161,6 +162,156 @@ exporters: sumologic: ``` +### `sumologic` exporter: deprecate `json_logs` + +`json_logs` has been deprecated in favor of `transform` processor. It is going to be removed in `v0.95.0-sumo-0`. + +To migrate perform the following steps: + +- use `transform` processor in replace of `json_logs.add_timestamp` and `json_logs.timestamp_key`: + + ```yaml + processors: + transform/add_timestamp: + log_statements: + - context: log + statements: + - set(time, Now()) where time_unix_nano == 0 + - set(attributes["timestamp_key"], Int(time_unix_nano / 1000000)) + ``` + +- use `transform` processor in replace of `json_logs.flatten_body`: + + ```yaml + processors: + transform/flatten: + error_mode: ignore + log_statements: + - context: log + statements: + - merge_maps(attributes, body, "insert") where IsMap(body) + - set(body, "") where IsMap(body) + + ``` + +- use `transform` processor in replace of `json_logs.log_key`: + + ```yaml + processors: + transform/set_log_key: + log_statements: + - context: log + statements: + - set(attributes["log"], body) + - set(body, "") + ``` + +#### Migration example for `add_timestamp` and `timestamp_key` + +Given the following configuration: + +```yaml +exporters: + sumologic: + log_format: json + json_logs: + timestamp_key: timestamp_key + add_timestamp: true +``` + +change it to: + +```yaml +exporters: + sumologic: + log_format: json + json_logs: + add_timestamp: false +processors: + transform/add_timestamp: + log_statements: + - context: log + statements: + - set(time, Now()) where time_unix_nano == 0 + - set(attributes["timestamp_key"], Int(time_unix_nano / 1000000)) +service: + pipelines: + logs: + processors: + # ... + - transform/add_timestamp +``` + +#### Migration example for `flatten_body` + +Given the following configuration: + +```yaml +exporters: + sumologic: + log_format: json + json_logs: + flatten_body: true +``` + +change it to: + +```yaml +exporters: + sumologic: + log_format: json + json_logs: + flatten_body: false +processors: + transform/flatten: + error_mode: ignore + log_statements: + - context: log + statements: + - merge_maps(attributes, body, "insert") where IsMap(body) + - set(body, "") where IsMap(body) +service: + pipelines: + logs: + processors: + # ... + - transform/flatten +``` + +#### Migration example for `log_key` + +Given the following configuration: + +```yaml +exporters: + sumologic: + log_format: json + json_logs: + log_key: my_log +``` + +change it to: + +```yaml +exporters: + sumologic: + log_format: json + json_logs: +processors: + transform/set_log_key: + log_statements: + - context: log + statements: + - set(attributes["my_log"], body) + - set(body, "") +service: + pipelines: + logs: + processors: + # ... + - transform/set_log_key +``` + ## Upgrading to v0.89.0-sumo-0 ### `remoteobserver` processor: renamed to `remotetap` processor diff --git a/pkg/exporter/sumologicexporter/exporter.go b/pkg/exporter/sumologicexporter/exporter.go index 8cf6c124f5..18de0e573c 100644 --- a/pkg/exporter/sumologicexporter/exporter.go +++ b/pkg/exporter/sumologicexporter/exporter.go @@ -101,6 +101,11 @@ func initExporter(cfg *Config, createSettings exporter.CreateSettings) (*sumolog "https://github.com/SumoLogic/sumologic-otel-collector/blob/main/docs/upgrading.md#sumologic-exporter-deprecate-clear_logs_timestamp") } + if cfg.LogFormat == JSONFormat { + se.logger.Warn("'json_logs' is deprecated and suboptimal. It is going to be removed in 'v0.95.0-sumo-0'. Please follow the upgrade guide: " + + "https://github.com/SumoLogic/sumologic-otel-collector/blob/main/docs/upgrading.md#sumologic-exporter-deprecate-json_logs") + } + return se, nil }