diff --git a/elk_metrics_7x/roles/elastic_data_hosts/defaults/main.yml b/elk_metrics_7x/roles/elastic_data_hosts/defaults/main.yml index edc8bba0..1a1db482 100644 --- a/elk_metrics_7x/roles/elastic_data_hosts/defaults/main.yml +++ b/elk_metrics_7x/roles/elastic_data_hosts/defaults/main.yml @@ -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 }}" diff --git a/elk_metrics_7x/roles/elastic_data_hosts/vars/data-node-variables.yml b/elk_metrics_7x/roles/elastic_data_hosts/vars/data-node-variables.yml index 3bc23c57..b8958476 100644 --- a/elk_metrics_7x/roles/elastic_data_hosts/vars/data-node-variables.yml +++ b/elk_metrics_7x/roles/elastic_data_hosts/vars/data-node-variables.yml @@ -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: |- diff --git a/elk_metrics_7x/templates/_macros.j2 b/elk_metrics_7x/templates/_macros.j2 index 325eb449..b6ba9940 100644 --- a/elk_metrics_7x/templates/_macros.j2 +++ b/elk_metrics_7x/templates/_macros.j2 @@ -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: