# Selectively read certain files from S3?

**URL:** <https://discuss.elastic.co/t/selectively-read-certain-files-from-s3/61548>\
**Category:** Logstash\
**Created:** [September 27, 2016, 1:05am UTC](https://discuss.elastic.co/t/selectively-read-certain-files-from-s3/61548 "2016-09-27T01:05:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allie\_Yang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/allie_yang/32/16538_2.png) [@Allie\_Yang](https://discuss.elastic.co/u/Allie_Yang)\
**Post date:** [September 27, 2016, 1:05am UTC](https://discuss.elastic.co/t/selectively-read-certain-files-from-s3/61548/1 "2016-09-27T01:05:02Z")

</div>

**how can i selectively only read certain files?:**

The prefix setting below doesn't work.. What can i do??

My config below (i used CLI credential to terminal).  
input {  
s3 {  
bucket =\> "fotolia-prod-logs"  
**prefix** =\> "/ **/** /\*\*/event\_log/generic.log.gz"  
region =\> "eu-west-1"  
type =\> "generic"  
codec =\> "plain"  
delete =\> false  
}  
}

filter {  
grok{  
break\_on\_match =\> false  
match =\> { "message" =\> "%{SYSLOGBASE} %{GREEDYDATA:message}" }  
overwrite =\> ["message"]  
}  
}

output {  
stdout { codec =\> rubydebug }  
}

Coz i only want to read generic.log.gz files.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 28, 2016, 5:37am UTC](https://discuss.elastic.co/t/selectively-read-certain-files-from-s3/61548/2 "2016-09-28T05:37:58Z")

</div>

The `prefix` is just that, a pathname prefix. Wildcards aren't supported. I think your best bet is to use the `exclude_pattern` option to craft a regular expression that excludes all files _except_ generic.log.gz.

---

<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:** [July 6, 2017, 4:36am UTC](https://discuss.elastic.co/t/selectively-read-certain-files-from-s3/61548/3 "2017-07-06T04:36:37Z")

</div>


