# How to handle rotating directory in input file for logstash

**URL:** <https://discuss.elastic.co/t/how-to-handle-rotating-directory-in-input-file-for-logstash/297104>\
**Category:** Logstash\
**Created:** [February 14, 2022, 7:02am UTC](https://discuss.elastic.co/t/how-to-handle-rotating-directory-in-input-file-for-logstash/297104 "2022-02-14T07:02:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![selflabs](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@selflabs](https://discuss.elastic.co/u/selflabs)\
**Post date:** [February 14, 2022, 7:02am UTC](https://discuss.elastic.co/t/how-to-handle-rotating-directory-in-input-file-for-logstash/297104/1 "2022-02-14T07:02:02Z")

</div>

Hi Team,

I wants logstash to read logs from AWS S3 bucket but my log path directory is keep rotating on month basis and am not understand how to handle it. please suggest.

```auto
input {
      s3 {
          "access_key_id" => "***"
          "secret_access_key" => "***"
          "bucket" => "org"
          "prefix" => "org_2022/ourorg/20220201-20220301/"
          "region" => "us-north-1"
            }
          }

```

---

<div class="post-metadata">

**Author:** ![sholzhauer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sholzhauer/32/110282_2.png) [@sholzhauer](https://discuss.elastic.co/u/sholzhauer)\
**Post date:** [February 14, 2022, 8:54am UTC](https://discuss.elastic.co/t/how-to-handle-rotating-directory-in-input-file-for-logstash/297104/2 "2022-02-14T08:54:39Z")

</div>

Presuming the `20220201-20220301` part is what rotates it should work by specifying the prefix as  
`org_2022/ourorg/`; It will retrieve all files below it I believe.

---

<div class="post-metadata">

**Author:** ![selflabs](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@selflabs](https://discuss.elastic.co/u/selflabs)\
**Post date:** [February 14, 2022, 9:22am UTC](https://discuss.elastic.co/t/how-to-handle-rotating-directory-in-input-file-for-logstash/297104/3 "2022-02-14T09:22:00Z")

</div>

Hi, Yes. "20220201-20220301" is that directory and change on every month basis, under this directory logs are written. like below :  
"org\_2022/ourorg/20220201-20220301/ourorg.logs".

---

<div class="post-metadata">

**Author:** ![sholzhauer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sholzhauer/32/110282_2.png) [@sholzhauer](https://discuss.elastic.co/u/sholzhauer)\
**Post date:** [February 14, 2022, 9:59am UTC](https://discuss.elastic.co/t/how-to-handle-rotating-directory-in-input-file-for-logstash/297104/4 "2022-02-14T09:59:09Z")

</div>

Then this should work:

```auto
input {
      s3 {
          "access_key_id" => "***"
          "secret_access_key" => "***"
          "bucket" => "org"
          "prefix" => "org_2022/ourorg/"
          "region" => "us-north-1"
            }
          }

```

---

<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:** [March 14, 2022, 10:00am UTC](https://discuss.elastic.co/t/how-to-handle-rotating-directory-in-input-file-for-logstash/297104/5 "2022-03-14T10:00:03Z")

</div>

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