# Daily indices into monthly

**URL:** https://discuss.elastic.co/t/daily-indices-into-monthly/99777
**Category:** Logstash
**Created:** [September 8, 2017, 1:51am UTC](https://discuss.elastic.co/t/daily-indices-into-monthly/99777 "2017-09-08T01:51:53Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![niraj\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_kumar/32/4130_2.png) [@niraj\_kumar](https://discuss.elastic.co/u/niraj_kumar)
#### Post date: [September 8, 2017, 1:51am UTC](https://discuss.elastic.co/t/daily-indices-into-monthly/99777/1 "2017-09-08T01:51:53Z")

</div>

I read @warkolm post about moving daily indices into monthly and i thank him for the great example. ( [Example](https://gist.github.com/markwalkom/8a7201e3f6ea4354ae06) )

I have couple hundred individual indexes which i managed to create the logstash.conf file using a ruby program. My question here is, if i try to merge daily indices into monthly with the process below, will it duplicate the data if i re-run after the logstash crashes somehow and if yes, is there a way to avoid it.?

```
input {
  elasticsearch {
    hosts => ["xx.xx.xx.xx"]
    index => "cloudtrail-test1-2017.08.*"
    size => 1000
    scroll => "5m"
    docinfo => true
  }
 elasticsearch {
    hosts => ["xx.xx.xx.xx"]
    index => "cloudtrail-test2-2017.08.*"
    size => 1000
    scroll => "5m"
    docinfo => true
  }
}

output {
  elasticsearch {
    hosts => ["xx.xx.xx.xx"]
    index => "%{[@metadata][_type]}-%{+YYYY-MM}"
    document_type => "%{[@metadata][_type]}"
    document_id => "%{[@metadata][_id]}"
  }
  stdout {
    codec => "dots"
  }
}

```

--  
Niraj

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [September 8, 2017, 2:03am UTC](https://discuss.elastic.co/t/daily-indices-into-monthly/99777/2 "2017-09-08T02:03:31Z")

</div>

You should use the [`_reindex`](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/docs-reindex.html) API for this, then there is no reliance on Logstash 🙂

Here's an example on how to do it with your data -[https://www.elastic.co/guide/en/elasticsearch/reference/5.5/docs-reindex.html#\_reindex\_daily\_indices](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/docs-reindex.html#_reindex_daily_indices)

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [September 8, 2017, 4:47am UTC](https://discuss.elastic.co/t/daily-indices-into-monthly/99777/3 "2017-09-08T04:47:12Z")

</div>

[Elasticsearch Curator](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/reindex.html) can also help with this.

---

<div class="post-metadata">

### Author: ![niraj\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_kumar/32/4130_2.png) [@niraj\_kumar](https://discuss.elastic.co/u/niraj_kumar)
#### Post date: [September 8, 2017, 4:33pm UTC](https://discuss.elastic.co/t/daily-indices-into-monthly/99777/4 "2017-09-08T16:33:41Z")

</div>

@theuntergeek

Can you give me an short example how to accomplish this?

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [September 8, 2017, 6:31pm UTC](https://discuss.elastic.co/t/daily-indices-into-monthly/99777/5 "2017-09-08T18:31:10Z")

</div>

The first example in the [Filter-Selected Indices](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/option_request_body.html#_filter_selected_indices) section of the `request_body` documentation has a very good example of what you're seeking.

---

<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 6, 2017, 6:31pm UTC](https://discuss.elastic.co/t/daily-indices-into-monthly/99777/6 "2017-10-06T18:31:15Z")

</div>

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