Hi
I had a similar issue in our cluster. I see 2 ways to disable the replica's:
- After creation of the index, you disable them
- Before creation of the index, you disable them (index template, component template which is added to every index template, ...)
As per the previous comment, you can disable replica's on created indicies:
Please note that the I had to add the first command to also alter the system indices.
PUT /.ds-*/_settings
{
"index":{
"number_of_replicas": 0
}
}
PUT /_settings
{
"index":{
"number_of_replicas": 0
}
}
Disabling replica's on future indices, can be done via index/component templates:
E.g.
PUT _component_template/metrics-apm.service_summary.10m@custom
{"template":{"settings":{"index":{"lifecycle":{"name":"Justx-Metrics-Default"},"number_of_replicas":"0"}}},"_meta":{"package":{"name":"apm"},"managed_by":"fleet","managed":true}}
PUT _component_template/metrics-system.network@custom
{"template":{"settings":{"index":{"lifecycle":{"name":"Justx-Metrics-Default"},"number_of_replicas":"0"}}},"_meta":{"package":{"name":"system"},"managed_by":"fleet","managed":true}}
PUT _component_template/metrics-elastic_agent.auditbeat@custom
{"template":{"settings":{"index":{"lifecycle":{"name":"Justx-Metrics-Default"},"number_of_replicas":"0"}}},"_meta":{"package":{"name":"elastic_agent"},"managed_by":"fleet","managed":true}}
I had to alter a lot of templates, so I'll share some of the commands used to gather the names for the custom components (Fleet/Elastic Agent). With some smart regexes you could easily get the above commands to run them all at once:
TIP: they slightly differ between apm, system and elastic-agent
GET /_component_template/metrics-*custom
GET /_component_template/metrics-apm.*custom
GET /_component_template/metrics-system.*custom
GET /_component_template/metrics-elastic_agent.*custom
GET /_component_template/logs-*custom?filter_path=component_templates.name
GET /_component_template/logs-system.*custom
GET /_component_template/logs-elastic_agent.*custom
GET /_component_template/logs-apm.*custom
PS: I can share all the commands if you would like to
Coming back to the index templates, I prefer to have some component templates which are used over multiple index templates, e.g.:
TIP: Keep in mind that if you configure something via Kibana, the last screen has a tab "request" where you can get below requests.
PUT _component_template/logs-justx-settings
{
"template": {
"settings": {
"index": {
"number_of_replicas": "0",
"default_pipeline": "calculate_lag"
}
}
}
}
And using them to construct the template (with ILM):
PUT _ilm/policy/logs-trace-prd
{
"policy": {
"phases": {
"hot": {
"min_age": "0ms",
"actions": {
"rollover": {
"max_primary_shard_size": "5gb",
"max_age": "1d"
},
"set_priority": {
"priority": 100
}
}
},
"warm": {
"min_age": "3d",
"actions": {
"readonly": {},
"forcemerge": {
"max_num_segments": 1
},
"set_priority": {
"priority": 50
},
"migrate": {
"enabled": false
}
}
},
"delete": {
"min_age": "7d",
"actions": {
"delete": {
"delete_searchable_snapshot": true
}
}
}
}
}
}
PUT _index_template/logs-trace-prd
{
"version": 1,
"priority": 500,
"template": {
"settings": {
"index": {
"lifecycle": {
"name": "logs-trace-prd"
}
}
}
},
"index_patterns": [
"logs-trace-prd"
],
"data_stream": {
"hidden": false,
"allow_custom_routing": false
},
"composed_of": [
"logs-mappings",
"data-streams-mappings",
"logs-justx-settings",
"logs-justx-mappings"
]
}
Conflicting settings will be overwritten by the last component defining them:
"composed_of": [
"logs-mappings",
"data-streams-mappings",
"logs-justx-settings",
"logs-justx-mappings"
]
Good luck!