Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into test-close-on-signal
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoriano committed May 10, 2019
2 parents 072c4ff + 59378cd commit 34c627a
Show file tree
Hide file tree
Showing 12 changed files with 360 additions and 318 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ The list below covers the major changes between 7.0.0-rc2 and master only.
- Update urllib3 version to 1.24.2 {pull}11930[11930]
- Add libbeat/common/cleanup package. {pull}12134[12134]
- New helper to check for leaked goroutines on tests. {pull}12106[12106]
- Only Load minimal template if no fields are provided. {pull}12103[12103]
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Prevent duplicate packet loss error messages in HTTP events. {pull}10709[10709]
- Avoid reporting unknown MongoDB opcodes more than once. {pull}10878[10878]
- Fixed a memory leak when using process monitoring under Windows. {pull}12100[12100]
- Improved debug logging efficiency in PGQSL module. {issue}12150[12150]

*Winlogbeat*

Expand Down
5 changes: 5 additions & 0 deletions libbeat/outputs/elasticsearch/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"strconv"

"github.com/pkg/errors"

"github.com/elastic/beats/libbeat/common"
)

// QueryResult contains the result of a query.
Expand Down Expand Up @@ -235,6 +237,9 @@ func (es *Connection) SearchURIWithBody(
params map[string]string,
body interface{},
) (int, *SearchResults, error) {
if !es.version.LessThan(&common.Version{Major: 8}) {
docType = ""
}
status, resp, err := es.apiCall("GET", index, docType, "_search", "", params, body)
if err != nil {
return status, nil, err
Expand Down
4 changes: 2 additions & 2 deletions libbeat/outputs/elasticsearch/api_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestIndex(t *testing.T) {
}
_, result, err := client.SearchURIWithBody(index, "", nil, map[string]interface{}{})
if err != nil {
t.Errorf("SearchUriWithBody() returns an error: %s", err)
t.Fatalf("SearchUriWithBody() returns an error: %s", err)
}
if result.Hits.Total.Value != 1 {
t.Errorf("Wrong number of search results: %d", result.Hits.Total.Value)
Expand All @@ -72,7 +72,7 @@ func TestIndex(t *testing.T) {
}
_, result, err = client.SearchURI(index, "test", params)
if err != nil {
t.Errorf("SearchUri() returns an error: %s", err)
t.Fatalf("SearchUri() returns an error: %s", err)
}
if result.Hits.Total.Value != 1 {
t.Errorf("Wrong number of search results: %d", result.Hits.Total.Value)
Expand Down
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

0 comments on commit 34c627a

Please sign in to comment.