Skip to content
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

Add minimal ES template functionality. #12103

Merged
merged 6 commits into from
May 10, 2019
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ The list below covers the major changes between 7.0.0-rc2 and master only.
- Reduce idxmgmt.Supporter interface and rework export commands to reuse logic. {pull}11777[11777], {pull}12065[12065], {pull}12067[12067]
- Update urllib3 version to 1.24.2 {pull}11930[11930]
- Add libbeat/common/cleanup package. {pull}12134[12134]
- Only Load minimal template if no fields are provided. {pull}12103[12103]
12 changes: 12 additions & 0 deletions libbeat/template/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ func buildBody(tmpl *Template, config TemplateConfig, fields []byte) (common.Map
if config.Fields != "" {
return buildBodyFromFile(tmpl, config)
}
if fields == nil {
return buildMinimalTemplate(tmpl)
}
return buildBodyFromFields(tmpl, fields)
}

Expand Down Expand Up @@ -216,6 +219,15 @@ func buildBodyFromFields(tmpl *Template, fields []byte) (common.MapStr, error) {
return body, nil
}

func buildMinimalTemplate(tmpl *Template) (common.MapStr, error) {
logp.Debug("template", "Load minimal template")
body, err := tmpl.LoadMinimal()
if err != nil {
return nil, fmt.Errorf("error creating mimimal template: %v", err)
}
return body, nil
}

func esVersionParams(ver common.Version) map[string]string {
if ver.Major == 6 && ver.Minor == 7 {
return map[string]string{
Expand Down
Loading