# Problems with Number of replicas and UNASSIGNED errors

**URL:** https://discuss.elastic.co/t/problems-with-number-of-replicas-and-unassigned-errors/342138
**Category:** Elastic Agent
**Created:** [September 1, 2023, 4:31pm UTC](https://discuss.elastic.co/t/problems-with-number-of-replicas-and-unassigned-errors/342138 "2023-09-01T16:31:30Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Ednei\_Rodrigues](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ednei_rodrigues/32/116221_2.png) [@Ednei\_Rodrigues](https://discuss.elastic.co/u/Ednei_Rodrigues)
#### Post date: [September 1, 2023, 4:31pm UTC](https://discuss.elastic.co/t/problems-with-number-of-replicas-and-unassigned-errors/342138/1 "2023-09-01T16:31:30Z")

</div>

Hello, how are you doing ?

So, I have a standalone ELK Stack and I am suffering with the error messages "UNASSIGNED" replicas. I know, to not use replica, I need to set 'number\_of\_replicas': 0 to the index. As I am using a docker, I destroyed my environment and I created a global index and defined this variable. Then, I added some integrations to my Fleet agents and....Well, All the index templates are creating a replica!!  
What Am I doing wrong ? Is there a way to set all these indexes to not use replicas ? (I've tried to use the API, but I will appreciate if someone give an example how to set)

Below, you can find the errors:

```auto
> index shard prirep state node unassigned.reason
> .ds-logs-elastic_agent-default-2023.08.29-000001 0 r UNASSIGNED INDEX_CREATED
> .ds-metrics-elastic_agent.metricbeat-default-2023.08.29-000001 0 r UNASSIGNED INDEX_CREATED
> .ds-metrics-system.network-default-2023.08.29-000001 0 r UNASSIGNED INDEX_CREATED
> .ds-logs-elastic_agent.packetbeat-default-2023.08.29-000001 0 r UNASSIGNED INDEX_CREATED
> .ds-metrics-system.cpu-default-2023.08.29-000001 0 r UNASSIGNED INDEX_CREATED
> .ds-logs-endpoint.events.file-default-2023.08.29-000001 0 r UNASSIGNED INDEX_CREATED
> .ds-metrics-system.socket_summary-default-2023.08.29-000001 0 r UNASSIGNED INDEX_CREATED
> .ds-metrics-system.diskio-default-2023.08.29-000001 0 r UNASSIGNED INDEX_CREATED
> .ds-logs-network_traffic.tls-default-2023.08.29-000001 0 r UNASSIGNED INDEX_CREATED
> .ds-logs-elastic_agent.metricbeat-default-2023.08.29-000001 0 r UNASSIGNED INDEX_CREATED
> .ds-metrics-system.fsstat-default-2023.08.29-000001 0 r UNASSIGNED INDEX_CREATED
> .ds-metrics-system.process.summary-default-2023.08.29-000001 0 r UNASSIGNED INDEX_CREATED
> .ds-logs-elastic_agent.endpoint_security-default-2023.08.29-000001 0 r UNASSIGNED INDEX_CREATED
> .ds-logs-network_traffic.icmp-default-2023.08.29-000001 0 r UNASSIGNED INDEX_CREATED

```

Thanks!

---

<div class="post-metadata">

### Author: ![Ednei\_Rodrigues](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ednei_rodrigues/32/116221_2.png) [@Ednei\_Rodrigues](https://discuss.elastic.co/u/Ednei_Rodrigues)
#### Post date: [September 4, 2023, 8:46am UTC](https://discuss.elastic.co/t/problems-with-number-of-replicas-and-unassigned-errors/342138/2 "2023-09-04T08:46:23Z")

</div>

Hello, someone to help here ?

---

<div class="post-metadata">

### Author: ![HiteshSingh](https://avatars.discourse-cdn.com/v4/letter/h/f475e1/32.png) [@HiteshSingh](https://discuss.elastic.co/u/HiteshSingh)
#### Post date: [September 4, 2023, 3:03pm UTC](https://discuss.elastic.co/t/problems-with-number-of-replicas-and-unassigned-errors/342138/3 "2023-09-04T15:03:09Z")

</div>

To set replica shard use below:

```auto
PUT /<YOUR_INDEX_NAME>
{
  "settings": {
    "index": { 
      "number_of_replicas": 0
    }
  }
}

```

For more details refer [this](https://www.elastic.co/guide/en/elasticsearch/reference/8.6/indices-create-index.html#indices-create-api-example) documentation.

---

<div class="post-metadata">

### Author: ![Ednei\_Rodrigues](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ednei_rodrigues/32/116221_2.png) [@Ednei\_Rodrigues](https://discuss.elastic.co/u/Ednei_Rodrigues)
#### Post date: [September 4, 2023, 3:19pm UTC](https://discuss.elastic.co/t/problems-with-number-of-replicas-and-unassigned-errors/342138/4 "2023-09-04T15:19:33Z")

</div>

Hello, Thanks for you answer.

These templates are not blank, there are others settings and, If I run this "PUT", it will remove these settings, right ?

---

<div class="post-metadata">

### Author: ![HiteshSingh](https://avatars.discourse-cdn.com/v4/letter/h/f475e1/32.png) [@HiteshSingh](https://discuss.elastic.co/u/HiteshSingh)
#### Post date: [September 4, 2023, 3:22pm UTC](https://discuss.elastic.co/t/problems-with-number-of-replicas-and-unassigned-errors/342138/5 "2023-09-04T15:22:10Z")

</div>

> [@Ednei\_Rodrigues](#):
>
> Hello, Thanks for you answer.
> 
> These templates are not blank, there are others settings and, If I run this "PUT", it will remove these settings, right ?

No, if you run this, It will only update the `"number_of_replicas": 0` property. All other properties will remain the same since 'PUT' will only update the property specified.

---

<div class="post-metadata">

### Author: ![Ednei\_Rodrigues](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ednei_rodrigues/32/116221_2.png) [@Ednei\_Rodrigues](https://discuss.elastic.co/u/Ednei_Rodrigues)
#### Post date: [September 4, 2023, 3:59pm UTC](https://discuss.elastic.co/t/problems-with-number-of-replicas-and-unassigned-errors/342138/6 "2023-09-04T15:59:55Z")

</div>

Well, I got this error:

```auto
_index_template/metrics-elastic_agent.filebeat" -H "Content-Type: application/json" -d '
{
        "settings": {
        "index": { 
                "number_of_replicas": 0
        }
        }
}'
{"error":{"root_cause":[{"type":"x_content_parse_exception","reason":"[3:2] [index_template] unknown field [settings]"}],"type":"x_content_parse_exception","reason":"[3:2] [index_template] unknown field [settings]"},"status":400}

```

THe template context that we trying to modify is:

```auto
_index_template/metrics-elastic_agent.filebeat"
{"index_templates":[{"name":"metrics-elastic_agent.filebeat","index_template":{"index_patterns":["metrics-elastic_agent.filebeat-*"],"template":{"settings":{"index":{"mode":"time_series"}},"mappings":{"_meta":{"package":{"name":"elastic_agent"},"managed_by":"fleet","managed":true}}},"composed_of":["metrics-elastic_agent.filebeat@package","metrics-elastic_agent.filebeat@custom",".fleet_globals-1",".fleet_agent_id_verification-1"],"priority":200,"_meta":{"package":{"name":"elastic_agent"},"managed_by":"fleet","managed":true},"data_stream":{"hidden":false,"allow_custom_routing":false}}}]}

```

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [September 4, 2023, 5:21pm UTC](https://discuss.elastic.co/t/problems-with-number-of-replicas-and-unassigned-errors/342138/7 "2023-09-04T17:21:28Z")

</div>

Hi @Ednei_Rodrigues

Perhaps I can clarify a bit.

Assuming you only have a single node what you are seeing with unallocated replicas is normal behavior AND you are not actually required to fix anything but you will see Yellow health.

What @HiteshSingh suggested was to set the replicas to 0 on **existing** indices not the template which will be used when **new** indices are created. It looks like You tried to apply the setting to the template  
.. which you can but will need to use the correct syntax

From what it looks to me you are using metricbeat and agent , these have built in built template s.

All in all your cluster and replicas are operating as the should and really the **Yellow** status is to remind you that with only one node you could have data loss.

Perhaps take a look at this thread

> [@Has anyone come up with a maintainable way to set index.number\_of\_replicas cluster wide?](https://discuss.elastic.co/t/has-anyone-come-up-with-a-maintainable-way-to-set-index-number-of-replicas-cluster-wide/341288):
>
> Thanks to budget issues, I'm trying to slim down the footprint of my Elastic stack. While not ideal, running in single-node mode would make things easier to manage. But, as far as I can tell, Elastic Agent creates everything to have at least 1 replica. Due to the [defaults](https://www.elastic.co/guide/en/elasticsearch/reference/8.9/index-modules.html#dynamic-index-settings) I'm sure. That results in any single node cluster always using twice as much space as it should, and always being "yellow". Not exactly the setup I need. index.number\_of\_replicas is the setting I think I need to update. Set…

Hope this helps

---

<div class="post-metadata">

### Author: ![HiteshSingh](https://avatars.discourse-cdn.com/v4/letter/h/f475e1/32.png) [@HiteshSingh](https://discuss.elastic.co/u/HiteshSingh)
#### Post date: [September 5, 2023, 8:09am UTC](https://discuss.elastic.co/t/problems-with-number-of-replicas-and-unassigned-errors/342138/8 "2023-09-05T08:09:10Z")

</div>

> [@Ednei\_Rodrigues](#):
>
> Well, I got this error:
> 
> ```auto
> _index_template/metrics-elastic_agent.filebeat" -H "Content-Type: application/json" -d '
> {
> "settings": {
> "index": { 
> "number_of_replicas": 0
> }
> }
> }'
> {"error":{"root_cause":[{"type":"x_content_parse_exception","reason":"[3:2] [index_t
> 
> ```

@Ednei_Rodrigues is right. But if you still want to apply this setting over your template use this:

```auto
PUT /_index_template/metrics-elastic_agent.filebeat
{
  "index_patterns" : [".ds-*"], // Give regex pattern for all the indexes you want to apply this setting.
  "priority" : 1,
  "template": {
    "settings" : {
         "number_of_replicas": 0
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![Ednei\_Rodrigues](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ednei_rodrigues/32/116221_2.png) [@Ednei\_Rodrigues](https://discuss.elastic.co/u/Ednei_Rodrigues)
#### Post date: [September 5, 2023, 9:36am UTC](https://discuss.elastic.co/t/problems-with-number-of-replicas-and-unassigned-errors/342138/9 "2023-09-05T09:36:58Z")

</div>

Hum, So I am doing wrong running ELK stack in standalone mode and this alert should be ignored. I thought this is the cause of my ELK getting slow and I started to chase a solution for it. 😓

@HiteshSingh it is worked!

@stephenb Thank you for your impressions and I will create a second node to avoid this situation.

Guys, thank you all, I am very happy with the support. Have a nice day.

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [September 5, 2023, 1:32pm UTC](https://discuss.elastic.co/t/problems-with-number-of-replicas-and-unassigned-errors/342138/10 "2023-09-05T13:32:54Z")

</div>

@Ednei_Rodrigues

Glad we could help.

Really you should create 3 nodes it is the best minimal solution for reliability/ resiliency..

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [October 3, 2023, 1:33pm UTC](https://discuss.elastic.co/t/problems-with-number-of-replicas-and-unassigned-errors/342138/11 "2023-10-03T13:33:04Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
