# Reading previous week indice with elastic input plugin

**URL:** https://discuss.elastic.co/t/reading-previous-week-indice-with-elastic-input-plugin/103236
**Category:** Logstash
**Created:** [October 9, 2017, 1:45pm UTC](https://discuss.elastic.co/t/reading-previous-week-indice-with-elastic-input-plugin/103236 "2017-10-09T13:45:48Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![RickT](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@RickT](https://discuss.elastic.co/u/RickT)
#### Post date: [October 9, 2017, 1:45pm UTC](https://discuss.elastic.co/t/reading-previous-week-indice-with-elastic-input-plugin/103236/1 "2017-10-09T13:45:48Z")

</div>

Hello,  
today, a mystery...

How to read only the previous week indice of Elastic using input plugin Elastic (in logstash conf).  
For example, today just the **40th** week.

The actives indices are :  
data\_test-2017.39  
**data\_test-2017.40**  
data\_test-2017.41

I'm trying this but without good result :

* * *

input {  
elasticsearch {  
hosts =\> ["SRV1001:9200"]  
**index =\> "data\_test-%{+YYYY.ww}-1"**  
... }

and too :  
index =\> "data\_test-%{+YYYY.ww-1}"  
index =\> "data\_test-%{+xxxx.ww-1}"

* * *

i always obtain : "status":404  
There is a solution?

my **logstash version is 2.4.1**  
Thanks.

---

<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: [October 10, 2017, 2:33am UTC](https://discuss.elastic.co/t/reading-previous-week-indice-with-elastic-input-plugin/103236/2 "2017-10-10T02:33:53Z")

</div>

> [@RickT](#):
>
> index =\> "data\_test-%{+YYYY.ww}-1"

You can't do that sort of date math in the output unfortunately.

---

<div class="post-metadata">

### Author: ![RickT](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@RickT](https://discuss.elastic.co/u/RickT)
#### Post date: [October 10, 2017, 7:17am UTC](https://discuss.elastic.co/t/reading-previous-week-indice-with-elastic-input-plugin/103236/3 "2017-10-10T07:17:06Z")

</div>

well, it means that there is no solution to do that (select the previous week's indice) !?  
Surprising !

---

<div class="post-metadata">

### Author: ![RickT](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@RickT](https://discuss.elastic.co/u/RickT)
#### Post date: [October 11, 2017, 3:01pm UTC](https://discuss.elastic.co/t/reading-previous-week-indice-with-elastic-input-plugin/103236/4 "2017-10-11T15:01:10Z")

</div>

hi,  
If someone is looking for an answer, look at this, it's mine !

> > > **config logstash plugin** :  
> > > input {  
> > > elasticsearch {  
> > > hosts =\> ["SRV1001:9200"]  
> > > index =\> "data\_test-${an}.${nbELK:NOVAL}"  
> > > }  
> > > }  
> > > ...  
> > > Here, i'm using two SYSVAR called "an" and "nbELK" and that are declared in advance.  
> > > Be careful, in Logstash version 2.41, you must execute with the flag " **--allow-env**"  
> > > like this \>\>\> logstash -f ficLogstash.conf --allow-env

It's OK on Windows env. Probably no problem also on Linux...

---

<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 8, 2017, 3:01pm UTC](https://discuss.elastic.co/t/reading-previous-week-indice-with-elastic-input-plugin/103236/5 "2017-11-08T15:01:10Z")

</div>

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