Skip to content

Commit 3c33a47

Browse files
authored
Merge pull request #2061 from MaxAnderson95/fix/lm-mapping-field
Fix for LogicMonitor resource_mapping field
2 parents db1beb7 + fbcc69a commit 3c33a47

File tree

9 files changed

+35
-11
lines changed

9 files changed

+35
-11
lines changed

charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_clusteroutputs.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4378,7 +4378,6 @@ spec:
43784378
type: string
43794379
required:
43804380
- company_name
4381-
- resource_mapping
43824381
type: object
43834382
logdna:
43844383
properties:
@@ -12050,7 +12049,6 @@ spec:
1205012049
type: string
1205112050
required:
1205212051
- company_name
12053-
- resource_mapping
1205412052
type: object
1205512053
logdna:
1205612054
properties:

charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_outputs.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11107,7 +11107,6 @@ spec:
1110711107
type: string
1110811108
required:
1110911109
- company_name
11110-
- resource_mapping
1111111110
type: object
1111211111
logdna:
1111311112
properties:

charts/logging-operator/crds/logging.banzaicloud.io_clusteroutputs.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4375,7 +4375,6 @@ spec:
43754375
type: string
43764376
required:
43774377
- company_name
4378-
- resource_mapping
43794378
type: object
43804379
logdna:
43814380
properties:
@@ -12047,7 +12046,6 @@ spec:
1204712046
type: string
1204812047
required:
1204912048
- company_name
12050-
- resource_mapping
1205112049
type: object
1205212050
logdna:
1205312051
properties:

charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11104,7 +11104,6 @@ spec:
1110411104
type: string
1110511105
required:
1110611106
- company_name
11107-
- resource_mapping
1110811107
type: object
1110911108
logdna:
1111011109
properties:

config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4375,7 +4375,6 @@ spec:
43754375
type: string
43764376
required:
43774377
- company_name
4378-
- resource_mapping
43794378
type: object
43804379
logdna:
43814380
properties:
@@ -12047,7 +12046,6 @@ spec:
1204712046
type: string
1204812047
required:
1204912048
- company_name
12050-
- resource_mapping
1205112049
type: object
1205212050
logdna:
1205312051
properties:

config/crd/bases/logging.banzaicloud.io_outputs.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11104,7 +11104,6 @@ spec:
1110411104
type: string
1110511105
required:
1110611106
- company_name
11107-
- resource_mapping
1110811107
type: object
1110911108
logdna:
1111011109
properties:

docs/configuration/plugins/outputs/lm_logs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ When true, appends additional metadata to the log
107107
108108
Default: false
109109
110-
### resource_mapping (string, required) {#logicmonitorlogs-resource_mapping}
110+
### resource_mapping (string, optional) {#logicmonitorlogs-resource_mapping}
111111
112112
The mapping that defines the source of the log event to the LM resource. In this case, the <event_key> in the incoming event is mapped to the value of <lm_property>
113113

pkg/sdk/logging/model/output/lm_logs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type LMLogsOutputConfig struct {
6969
// LogicMonitor account domain. For eg. for url test.logicmonitor.com, company_domain is logicmonitor.com (default: logicmonitor.com)
7070
CompanyDomain string `json:"company_domain,omitempty" plugin:"default:logicmonitor.com"`
7171
// The mapping that defines the source of the log event to the LM resource. In this case, the <event_key> in the incoming event is mapped to the value of <lm_property>
72-
ResourceMapping string `json:"resource_mapping"`
72+
ResourceMapping string `json:"resource_mapping,omitempty"`
7373
// LM API Token access ID
7474
// +docLink:"Secret,../secret/"
7575
AccessID *secret.Secret `json:"access_id,omitempty"`

pkg/sdk/logging/model/output/lm_logs_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,36 @@ force_encoding: "UTF-8"
144144
test := render.NewOutputPluginTest(t, s)
145145
test.DiffResult(expected)
146146
}
147+
148+
func TestLMLogsOutputConfigWithoutResourceMapping(t *testing.T) {
149+
CONFIG := []byte(`
150+
company_name: mycompany
151+
access_id:
152+
value: "my_access_id"
153+
access_key:
154+
value: "my_access_key"
155+
`)
156+
157+
expected := `
158+
<match **>
159+
@type lm
160+
@id test
161+
access_id my_access_id
162+
access_key my_access_key
163+
company_domain logicmonitor.com
164+
company_name mycompany
165+
flush_interval 60s
166+
<buffer tag,time>
167+
@type file
168+
path /buffers/test.*.buffer
169+
retry_forever true
170+
timekey 10m
171+
timekey_wait 1m
172+
</buffer>
173+
</match>
174+
`
175+
s := &output.LMLogsOutputConfig{}
176+
require.NoError(t, yaml.Unmarshal(CONFIG, s))
177+
test := render.NewOutputPluginTest(t, s)
178+
test.DiffResult(expected)
179+
}

0 commit comments

Comments
 (0)