Alter default shard count in index templates

Currently, we use only a single primary shard for each beat index,
as configured by the index templates. This is not usually an optimal
setup, as all index searching is handled on a single node. A more
efficient configuration for a small number of different indices is
to balance, with around one primary shard per node. This
commit exposes the config option to set the number of primary shards,
which was previously hardcoded to 1. This now defaults to one shard
per data node in the cluster.

Change-Id: Icacf76c2270c98f8676d57952c00773646ca7b51
This commit is contained in:
Duncan Martin Walker
2020-04-30 14:11:27 +01:00
parent 3606af8175
commit 0cd1f76757
3 changed files with 5 additions and 1 deletions

View File

@@ -34,6 +34,9 @@ elastic_data_interface: "{{ ansible_default_ipv4['alias'] }}"
## Elasticsearch index template settings
# Set the default max number of fields used in a query
# elastic_max_docvalue_fields_search: "100"
# Set the number of primary shards for each index
# (defaults to the number of Elasticsearch data nodes)
# elastic_primary_shard_count: 1
# The set of nodes used for elasticsearch discovery
# elasticsearch_discovery_seed_hosts: "{{ (elastic_hosts | union(groups['kibana'])) | map('extract', hostvars, 'ansible_host') | list }}"

View File

@@ -169,6 +169,7 @@ elasticsearch_number_of_replicas: "{{ ((data_nodes | length) > 2) | ternary('2',
elasticsearch_beat_settings:
number_of_replicas: "{{ elasticsearch_number_of_replicas }}"
max_docvalue_fields_search: "{{ elastic_max_docvalue_fields_search | default('100') }}"
shard_count: "{{ elastic_primary_shard_count | default(elasticsearch_data_node_details | length) }}"
# Shuffled elasticsearch endpoints (with localhost if relevant) for use in beat config files
elasticsearch_data_hosts: |-

View File

@@ -281,7 +281,7 @@ setup.template.fields: "${path.config}/fields.yml"
# Overwrite existing template
setup.template.overwrite: {{ host == data_nodes[0] | default(false)}}
{% set shards = 1 %}
{% set shards = elasticsearch_beat_settings.shard_count | int %}
# Elasticsearch template settings
setup.template.settings: