From fbcc69a4976f7fb51412c01db4f77edbc449d830 Mon Sep 17 00:00:00 2001 From: Max Anderson Date: Fri, 6 Jun 2025 12:57:19 -0400 Subject: [PATCH] fix: Fixed issue with mapping field still being required and not omitting empty Signed-off-by: Max Anderson --- ...logging.banzaicloud.io_clusteroutputs.yaml | 2 -- .../logging.banzaicloud.io_outputs.yaml | 1 - ...logging.banzaicloud.io_clusteroutputs.yaml | 2 -- .../crds/logging.banzaicloud.io_outputs.yaml | 1 - ...logging.banzaicloud.io_clusteroutputs.yaml | 2 -- .../bases/logging.banzaicloud.io_outputs.yaml | 1 - docs/configuration/plugins/outputs/lm_logs.md | 2 +- pkg/sdk/logging/model/output/lm_logs.go | 2 +- pkg/sdk/logging/model/output/lm_logs_test.go | 33 +++++++++++++++++++ 9 files changed, 35 insertions(+), 11 deletions(-) diff --git a/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_clusteroutputs.yaml b/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_clusteroutputs.yaml index aba91b2a4..fb15319c4 100644 --- a/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_clusteroutputs.yaml +++ b/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_clusteroutputs.yaml @@ -4378,7 +4378,6 @@ spec: type: string required: - company_name - - resource_mapping type: object logdna: properties: @@ -12050,7 +12049,6 @@ spec: type: string required: - company_name - - resource_mapping type: object logdna: properties: diff --git a/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_outputs.yaml b/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_outputs.yaml index 6074d66c6..729759723 100644 --- a/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_outputs.yaml +++ b/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_outputs.yaml @@ -11107,7 +11107,6 @@ spec: type: string required: - company_name - - resource_mapping type: object logdna: properties: diff --git a/charts/logging-operator/crds/logging.banzaicloud.io_clusteroutputs.yaml b/charts/logging-operator/crds/logging.banzaicloud.io_clusteroutputs.yaml index 4893b41bc..4742517de 100644 --- a/charts/logging-operator/crds/logging.banzaicloud.io_clusteroutputs.yaml +++ b/charts/logging-operator/crds/logging.banzaicloud.io_clusteroutputs.yaml @@ -4375,7 +4375,6 @@ spec: type: string required: - company_name - - resource_mapping type: object logdna: properties: @@ -12047,7 +12046,6 @@ spec: type: string required: - company_name - - resource_mapping type: object logdna: properties: diff --git a/charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml b/charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml index 9332ea01b..8dcc1a081 100644 --- a/charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml +++ b/charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml @@ -11104,7 +11104,6 @@ spec: type: string required: - company_name - - resource_mapping type: object logdna: properties: diff --git a/config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml b/config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml index 4893b41bc..4742517de 100644 --- a/config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml +++ b/config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml @@ -4375,7 +4375,6 @@ spec: type: string required: - company_name - - resource_mapping type: object logdna: properties: @@ -12047,7 +12046,6 @@ spec: type: string required: - company_name - - resource_mapping type: object logdna: properties: diff --git a/config/crd/bases/logging.banzaicloud.io_outputs.yaml b/config/crd/bases/logging.banzaicloud.io_outputs.yaml index 9332ea01b..8dcc1a081 100644 --- a/config/crd/bases/logging.banzaicloud.io_outputs.yaml +++ b/config/crd/bases/logging.banzaicloud.io_outputs.yaml @@ -11104,7 +11104,6 @@ spec: type: string required: - company_name - - resource_mapping type: object logdna: properties: diff --git a/docs/configuration/plugins/outputs/lm_logs.md b/docs/configuration/plugins/outputs/lm_logs.md index 6a05cee7e..54e455dc9 100644 --- a/docs/configuration/plugins/outputs/lm_logs.md +++ b/docs/configuration/plugins/outputs/lm_logs.md @@ -107,7 +107,7 @@ When true, appends additional metadata to the log Default: false -### resource_mapping (string, required) {#logicmonitorlogs-resource_mapping} +### resource_mapping (string, optional) {#logicmonitorlogs-resource_mapping} The mapping that defines the source of the log event to the LM resource. In this case, the in the incoming event is mapped to the value of diff --git a/pkg/sdk/logging/model/output/lm_logs.go b/pkg/sdk/logging/model/output/lm_logs.go index 3241eb005..55a4e2383 100644 --- a/pkg/sdk/logging/model/output/lm_logs.go +++ b/pkg/sdk/logging/model/output/lm_logs.go @@ -69,7 +69,7 @@ type LMLogsOutputConfig struct { // LogicMonitor account domain. For eg. for url test.logicmonitor.com, company_domain is logicmonitor.com (default: logicmonitor.com) CompanyDomain string `json:"company_domain,omitempty" plugin:"default:logicmonitor.com"` // The mapping that defines the source of the log event to the LM resource. In this case, the in the incoming event is mapped to the value of - ResourceMapping string `json:"resource_mapping"` + ResourceMapping string `json:"resource_mapping,omitempty"` // LM API Token access ID // +docLink:"Secret,../secret/" AccessID *secret.Secret `json:"access_id,omitempty"` diff --git a/pkg/sdk/logging/model/output/lm_logs_test.go b/pkg/sdk/logging/model/output/lm_logs_test.go index a75c1befb..63c5c47d0 100644 --- a/pkg/sdk/logging/model/output/lm_logs_test.go +++ b/pkg/sdk/logging/model/output/lm_logs_test.go @@ -144,3 +144,36 @@ force_encoding: "UTF-8" test := render.NewOutputPluginTest(t, s) test.DiffResult(expected) } + +func TestLMLogsOutputConfigWithoutResourceMapping(t *testing.T) { + CONFIG := []byte(` +company_name: mycompany +access_id: + value: "my_access_id" +access_key: + value: "my_access_key" +`) + + expected := ` + + @type lm + @id test + access_id my_access_id + access_key my_access_key + company_domain logicmonitor.com + company_name mycompany + flush_interval 60s + + @type file + path /buffers/test.*.buffer + retry_forever true + timekey 10m + timekey_wait 1m + + +` + s := &output.LMLogsOutputConfig{} + require.NoError(t, yaml.Unmarshal(CONFIG, s)) + test := render.NewOutputPluginTest(t, s) + test.DiffResult(expected) +}