Skip to content

Fix for LogicMonitor resource_mapping field #2061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4378,7 +4378,6 @@ spec:
type: string
required:
- company_name
- resource_mapping
type: object
logdna:
properties:
Expand Down Expand Up @@ -12050,7 +12049,6 @@ spec:
type: string
required:
- company_name
- resource_mapping
type: object
logdna:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11107,7 +11107,6 @@ spec:
type: string
required:
- company_name
- resource_mapping
type: object
logdna:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4375,7 +4375,6 @@ spec:
type: string
required:
- company_name
- resource_mapping
type: object
logdna:
properties:
Expand Down Expand Up @@ -12047,7 +12046,6 @@ spec:
type: string
required:
- company_name
- resource_mapping
type: object
logdna:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11104,7 +11104,6 @@ spec:
type: string
required:
- company_name
- resource_mapping
type: object
logdna:
properties:
Expand Down
2 changes: 0 additions & 2 deletions config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4375,7 +4375,6 @@ spec:
type: string
required:
- company_name
- resource_mapping
type: object
logdna:
properties:
Expand Down Expand Up @@ -12047,7 +12046,6 @@ spec:
type: string
required:
- company_name
- resource_mapping
type: object
logdna:
properties:
Expand Down
1 change: 0 additions & 1 deletion config/crd/bases/logging.banzaicloud.io_outputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11104,7 +11104,6 @@ spec:
type: string
required:
- company_name
- resource_mapping
type: object
logdna:
properties:
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/plugins/outputs/lm_logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <event_key> in the incoming event is mapped to the value of <lm_property>

Expand Down
2 changes: 1 addition & 1 deletion pkg/sdk/logging/model/output/lm_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <event_key> in the incoming event is mapped to the value of <lm_property>
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"`
Expand Down
33 changes: 33 additions & 0 deletions pkg/sdk/logging/model/output/lm_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 := `
<match **>
@type lm
@id test
access_id my_access_id
access_key my_access_key
company_domain logicmonitor.com
company_name mycompany
flush_interval 60s
<buffer tag,time>
@type file
path /buffers/test.*.buffer
retry_forever true
timekey 10m
timekey_wait 1m
</buffer>
</match>
`
s := &output.LMLogsOutputConfig{}
require.NoError(t, yaml.Unmarshal(CONFIG, s))
test := render.NewOutputPluginTest(t, s)
test.DiffResult(expected)
}