# Metricbeat not creating Index correctly

**URL:** <https://discuss.elastic.co/t/metricbeat-not-creating-index-correctly/285863>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [October 5, 2021, 1:49am UTC](https://discuss.elastic.co/t/metricbeat-not-creating-index-correctly/285863 "2021-10-05T01:49:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhare](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mhare/32/52213_2.png) [@mhare](https://discuss.elastic.co/u/mhare)\
**Post date:** [October 5, 2021, 1:49am UTC](https://discuss.elastic.co/t/metricbeat-not-creating-index-correctly/285863/1 "2021-10-05T01:49:37Z")

</div>

I am running Stack version 7.13.4 with Metricbeat

Everything seemed to be working fine, then we wanted to remove all the metricbeat data and start over. So we stopped metricbeat, and deleted all of the Metricbeat indexes. When we restarted metricbeat the index was created but not as it was before.

Prior we had index names like: metricbeat-7.13.4-2021-10-04-000001  
But after the restart, they are named as: metricbeat-7.13.4 (no date, no counter)

Looking in the metricbeat logs I see:

```auto
ERROR [publisher_pipeline_output] pipeline/output.go:154 Failed to connect to backoff(elasticsearch([http://192.168.123.121:9200](http://192.168.123.121:9200/))): Connection marked as failed because the onConnect callback failed: resource 'metricbeat-7.13.4' exists, but it is not an alias

```

Any ideas why this is?

THanks,

Michael

---

<div class="post-metadata">

**Author:** ![Kaiyan\_Sheng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kaiyan_sheng/32/38247_2.png) [@Kaiyan\_Sheng](https://discuss.elastic.co/u/Kaiyan_Sheng)\
**Post date:** [October 8, 2021, 2:56am UTC](https://discuss.elastic.co/t/metricbeat-not-creating-index-correctly/285863/2 "2021-10-08T02:56:21Z")

</div>

Hmmm could you try `./metricbeat setup` command to see if that will help? Thanks.

---

<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:** [October 8, 2021, 4:13am UTC](https://discuss.elastic.co/t/metricbeat-not-creating-index-correctly/285863/3 "2021-10-08T04:13:48Z")

</div>

> [@mhare](#):
>
> So we stopped metricbeat, and deleted all of the Metricbeat indexes. happens when you accidentally delete the write alias.

So when you did that you deleted the write alias `metricbeat-7.13.4` as well besides the actual indexes with the data in it. You don't want to do that.

When you initially ran setup the `metricbeat-7.13.4` write alias was created it looked something like this you can read about them [here](https://www.elastic.co/guide/en/elasticsearch/reference/7.15/aliases.html#write-index). They are part of ILM. running setup will re-create it.

```auto
  "metricbeat-7.13.4-2021.10.07-000001" : {
    "aliases" : {
      "metricbeat-7.13.4" : {
        "is_write_index" : true
      }

```

When working properly, metricbeat writes to `metricbeat-7.13.4` which is alias to the real index `metricbeat-7.13.4-2021.10.07-000001`

When the index rolls over another write alias is created and so on.

```auto
  "metricbeat-7.13.4-2021.10.08-000002" : {
    "aliases" : {
      "metricbeat-7.13.4" : {
        "is_write_index" : true
      }

```

(and the old one is no longer the write alias. ` "is_write_index" : false`

When you deleted the alias and restarted metricbeat now the docs get written to `metricbeat-7.13.4` because it is no longer aliased and it will no longer roll over etc.

Unfortunately you will need to delete that index and then run set up again.

You need to delete that new real index because its named the same as the write index... A case of name collision.

Need to clean it up, And then be careful not to delete it in the future.  
🙂

---

<div class="post-metadata">

**Author:** ![mhare](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mhare/32/52213_2.png) [@mhare](https://discuss.elastic.co/u/mhare)\
**Post date:** [October 8, 2021, 12:40pm UTC](https://discuss.elastic.co/t/metricbeat-not-creating-index-correctly/285863/4 "2021-10-08T12:40:49Z")

</div>

Thanks!, You are exactly correct. I was confused when I stopped metricbeat, deleted the index, restarted metricbeat and the index didn't come back as expected. The problem was there was another instance of metricbeat running somewhere else and as soon as I deleted the index, it was recreated (incorrectly again) by the other instance of metricbeat. Once I stopped both instances, removed the index and the restart metricbeat, the index came back correctly.

Thanks for the Help!

---

<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:** [October 8, 2021, 2:36pm UTC](https://discuss.elastic.co/t/metricbeat-not-creating-index-correctly/285863/5 "2021-10-08T14:36:25Z")

</div>

> [@mhare](#):
>
> The problem was there was another instance of metricbeat running somewhere else and as soon as I deleted the index, it was recreated (incorrectly again) by the other instance of metricbeat

Ohh yes I have run into that myself!

---

<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:** [November 5, 2021, 4:36pm UTC](https://discuss.elastic.co/t/metricbeat-not-creating-index-correctly/285863/6 "2021-11-05T16:36:43Z")

</div>

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