-
Notifications
You must be signed in to change notification settings - Fork 5k
[metricbeat][libbeat] template setup fails with number_of_shards=4 #9119
Description
- Version: 6.5.0
- Operating System: Ubuntu 18.04
- Steps to Reproduce: edit
metricbeat.yml:
setup.template:
enabled: true
name: metricbeat
pattern: metrics-*
settings:
index.number_of_shards: 4The following mapping is produced by metricbeat: (metricbeat export template)
{
"index_patterns": [
"metrics-*"
],
"mappings": {
"doc": {
"_meta": {
"version": "6.5.0"
},
...
"settings": {
"index": {
"mapping": {
"total_fields": {
"limit": 10000
}
},
"number_of_routing_shards": 30,
"number_of_shards": 4,
"refresh_interval": "5s"
}
}
}When the above template is uploaded to elasticsearch, like this
metricbeat export template | curl -XPUT "http://localhost:9200/_template/fail?pretty" -H "Content-Type: application/json" -d @-
the following is returned
{
"error" : {
"root_cause" : [
{
"type" : "remote_transport_exception",
"reason" : "[elk3][10.135.125.207:9300][indices:admin/template/put]"
}
],
"type" : "illegal_argument_exception",
"reason" : "the number of source shards [4] must be a must be a factor of [30]"
},
"status" : 400
}When running metricbeat setup --template -e, the error is lost in the huge output.
This bug was introduced in #5570. Choosing a hard-coded default value of 30 just because it fits the largest number of possible number_of_shards values sounds like a lazy solution to me. It doesn't fit 4.
The offending line is this:
beats/libbeat/template/template.go
Lines 207 to 211 in df74c26
| // 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) | |
| } |
Proposed fix: why not set number_of_routing_shards to, say, six times the number_of_shards when it is set in the configuration file, or 30 otherwise?
Addendum:
I can't find anything about this number_of_routing_shards in the most recent documentation w.r.t. metricbeat configuration: https://www.elastic.co/guide/en/beats/metricbeat/master/configuration-template.html
even though it seemed clear from the linked PR that the option should have been documented.
Editing the metricbeat configuration like this would have fixed the issue.
setup.template:
enabled: true
name: metricbeat-fail
pattern: "metrics-*"
settings:
index.number_of_shards: 4
index.number_of_routing_shards: 24