# Logstash reading recursively directories

**URL:** <https://discuss.elastic.co/t/logstash-reading-recursively-directories/302213>\
**Category:** Logstash\
**Created:** [April 12, 2022, 10:36am UTC](https://discuss.elastic.co/t/logstash-reading-recursively-directories/302213 "2022-04-12T10:36:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrea\_Bozzano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrea_bozzano/32/73731_2.png) [@Andrea\_Bozzano](https://discuss.elastic.co/u/Andrea_Bozzano)\
**Post date:** [April 12, 2022, 10:36am UTC](https://discuss.elastic.co/t/logstash-reading-recursively-directories/302213/1 "2022-04-12T10:36:32Z")

</div>

Hi everyone,

in my environment I'm trying to read log files that are saved on the file system like this:

```auto
/home/andrea/mylogs/[subdir1....subdirN]/*.gz
/home/andrea/mylogs/[subdir1...subdirM]/*.gz
/home/andrea/mylogs/[subdir1...subdirP]/*.gz

```

With N, M, P, possibly different. And inside this structure there're all the log files i need to read.  
So basically I have this structure and I have to read all the log.gz files with Logstash to import in my indexes.  
I tried, searching on the web and in the Elastic community, to set the file input plugin for Logstash like this:

```auto
input{
    file {
      path => "/home/andrea/mylogs/**/*.gz"
      start_position => "beginning"
      sincedb_path => "/dev/null"
      mode => "read"
  }

```

But it looks like it can't actually find any file in the directories, I mean the pipeline goes up and running, and then it stops like it didn't find any file:

```auto
[INFO] 2022-04-12 13:26:14.310 [Api Webserver] agent - Successfully started Logstash API endpoint {:port=>9600, :ssl_enabled=>false}
[INFO] 2022-04-12 13:26:19.445 [LogStash::Runner] runner - Logstash shut down.

```

My questions are:

1. Do I have to gunzip the log files, to make them readable by Logstash? I saw people importing log files also in .gz format
2. How can i specify the path for file, to make Logstash read recursively the directories I specified in the path configuration? (they're quite a lot...)

Any hint would be appreciated, thank you for your help and I hope you'll have a very nice Easter 🙂

Andrea

---

<div class="post-metadata">

**Author:** ![Andrea\_Bozzano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrea_bozzano/32/73731_2.png) [@Andrea\_Bozzano](https://discuss.elastic.co/u/Andrea_Bozzano)\
**Post date:** [April 12, 2022, 3:30pm UTC](https://discuss.elastic.co/t/logstash-reading-recursively-directories/302213/2 "2022-04-12T15:30:46Z")

</div>

Edit, i just moved all the logs up in the same directory, from the "root" folder  
/home/andrea/mylogs/

```auto
find ./ -type f -print0 | xargs -0 mv -t .

```

And then started logstash, actually was simpler solution 🙂

---

<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:** [May 10, 2022, 3:31pm UTC](https://discuss.elastic.co/t/logstash-reading-recursively-directories/302213/3 "2022-05-10T15:31:09Z")

</div>

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