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 number_of_routing_shards config set to 30 #5570

Merged
merged 1 commit into from
Nov 17, 2017
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.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di
- Refactor add_kubernetes_metadata to support autodiscovery {pull}5434[5434]
- Improve custom flag handling and CLI flags usage message. {pull}5543[5543]
- Update to Golang 1.9.2
- Add number_of_routing_shards config set to 30 {pull}5570[5570]

*Auditbeat*

Expand Down
1 change: 1 addition & 0 deletions auditbeat/auditbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ setup.template.settings:
#index:
#number_of_shards: 1
#codec: best_compression
#number_of_routing_shards: 30

# A dictionary of settings for the _source field. For more details, please check
# https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html
Expand Down
1 change: 1 addition & 0 deletions filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,7 @@ setup.template.settings:
#index:
#number_of_shards: 1
#codec: best_compression
#number_of_routing_shards: 30

# A dictionary of settings for the _source field. For more details, please check
# https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html
Expand Down
1 change: 1 addition & 0 deletions heartbeat/heartbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ setup.template.settings:
#index:
#number_of_shards: 1
#codec: best_compression
#number_of_routing_shards: 30

# A dictionary of settings for the _source field. For more details, please check
# https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html
Expand Down
1 change: 1 addition & 0 deletions libbeat/_meta/config.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ setup.template.settings:
#index:
#number_of_shards: 1
#codec: best_compression
#number_of_routing_shards: 30

# A dictionary of settings for the _source field. For more details, please check
# https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html
Expand Down
12 changes: 10 additions & 2 deletions libbeat/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (

var (
// Defaults used in the template
defaultDateDetection = false
defaultTotalFieldsLimit = 10000
defaultDateDetection = false
defaultTotalFieldsLimit = 10000
defaultNumberOfRoutingShards = 30

// Array to store dynamicTemplate parts in
dynamicTemplates []common.MapStr
Expand Down Expand Up @@ -147,6 +148,13 @@ func (t *Template) generate(properties common.MapStr, dynamicTemplates []common.
},
},
}

// number_of_routing shards is only supported for ES version >= 6.1
version61, _ := common.NewVersion("6.1.0")
if !t.esVersion.LessThan(version61) {
indexSettings.Put("number_of_routing_shards", defaultNumberOfRoutingShards)
}

indexSettings.DeepUpdate(t.settings.Index)

var mappingName string
Expand Down
56 changes: 56 additions & 0 deletions libbeat/template/template_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// +build !integration

package template

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestNumberOfRoutingShards(t *testing.T) {

beatVersion := "6.1.0"
beatName := "testbeat"
config := TemplateConfig{}

// Test it exists in 6.1
template, err := New(beatVersion, beatName, "6.1.0", config)
assert.NoError(t, err)

data := template.generate(nil, nil)
shards, err := data.GetValue("settings.index.number_of_routing_shards")
assert.NoError(t, err)

assert.Equal(t, 30, shards.(int))

// Test it does not exist in 6.0
template, err = New(beatVersion, beatName, "6.0.0", config)
assert.NoError(t, err)

data = template.generate(nil, nil)
shards, err = data.GetValue("settings.index.number_of_routing_shards")
assert.Error(t, err)
assert.Equal(t, nil, shards)
}

func TestNumberOfRoutingShardsOverwrite(t *testing.T) {

beatVersion := "6.1.0"
beatName := "testbeat"
config := TemplateConfig{
Settings: TemplateSettings{
Index: map[string]interface{}{"number_of_routing_shards": 5},
},
}

// Test it exists in 6.1
template, err := New(beatVersion, beatName, "6.1.0", config)
assert.NoError(t, err)

data := template.generate(nil, nil)
shards, err := data.GetValue("settings.index.number_of_routing_shards")
assert.NoError(t, err)

assert.Equal(t, 5, shards.(int))
}
1 change: 1 addition & 0 deletions metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,7 @@ setup.template.settings:
#index:
#number_of_shards: 1
#codec: best_compression
#number_of_routing_shards: 30

# A dictionary of settings for the _source field. For more details, please check
# https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html
Expand Down
1 change: 1 addition & 0 deletions packetbeat/packetbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ setup.template.settings:
#index:
#number_of_shards: 1
#codec: best_compression
#number_of_routing_shards: 30

# A dictionary of settings for the _source field. For more details, please check
# https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html
Expand Down
1 change: 1 addition & 0 deletions winlogbeat/winlogbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ setup.template.settings:
#index:
#number_of_shards: 1
#codec: best_compression
#number_of_routing_shards: 30

# A dictionary of settings for the _source field. For more details, please check
# https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html
Expand Down