Because of my current Elasticsearch cluster deployment (only one Hot node, not best practice, I know), I need to set the "number_of_replicas" of all my already an newly created indexes to 0.
As I use a Fleet Server with many Agent Policies and integrations, I used to paste in Stack Management > Index Management > Templates > logs (Managed) > Index settings :
Unfortunately customization like this on Elastic Agent is still pretty bad and you will need to create a custom template for each dataset in each one of your integrations.
Go into Stack Management > Index Management > Component templates and search for custom, you will see multiple @custom templates like these ones:
You will need to edit each one of them and add the number_of_replicas settings.
Thanks a lot @leandrojmp for pointing me to the right direction!
As I have approximately 120 custom component templates, I managed to edit them using a simple bash script :
# Retrieve the list of all component templates
curl --cacert <http_ca.crt> -u <username>:'<password>' -X GET https://<es_master_node>:9200/_component_template | tee elastic_component_template_list.json
# Extract all component templates with pattern name @custom
cat elastic_component_template_list.json | jq . | grep custom | sed 's/^[[:space:]]*"name": "\(.*\)",$/\1/' | tee elastic_component_template_custom_list.txt
# Do some verification / manual edit if needed on elastic_component_template_custom_list.txt
# Update all @custom component templates settings
for i in $(cat elastic_component_template_custom_list.txt); do curl --cacert <http_ca.crt> -u <username>:'<password>' -X PUT "https://<es_master_node>:9200/_component_template/$i" -H 'Content-Type: application/json' -d'{"template": {"settings": {"index": {"number_of_replicas": "0"}}}}'; done
So now, do you thing that everything is fine? No other manual operation needed on my side like mapping custom component templates to index templates?
It seems that it is already set :
A curious thing is that I'm on 8.12.1 and the logs@custom does not exists and it seems that the logs template was never updated to include ignore_missing_component_templates": ["logs@custom"].
So you got this error if you try to preview the logs template.
{
"statusCode": 400,
"error": "Bad Request",
"message": "index_template [simulate_template_yka2wonftvyovf3wx0jz2w] invalid, cause [index template [simulate_template_yka2wonftvyovf3wx0jz2w] specifies component templates [logs@custom] that do not exist]",
"attributes": {
"error": {
"root_cause": [
{
"type": "invalid_index_template_exception",
"reason": "index_template [simulate_template_yka2wonftvyovf3wx0jz2w] invalid, cause [index template [simulate_template_yka2wonftvyovf3wx0jz2w] specifies component templates [logs@custom] that do not exist]"
}
],
"type": "invalid_index_template_exception",
"reason": "index_template [simulate_template_yka2wonftvyovf3wx0jz2w] invalid, cause [index template [simulate_template_yka2wonftvyovf3wx0jz2w] specifies component templates [logs@custom] that do not exist]"
}
}
}
Manually creating an empty logs@custom component template solves this.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.