# Exclude\_pattern in logstash s3 input

**URL:** <https://discuss.elastic.co/t/exclude-pattern-in-logstash-s3-input/97993>\
**Category:** Logstash\
**Created:** [August 23, 2017, 3:53am UTC](https://discuss.elastic.co/t/exclude-pattern-in-logstash-s3-input/97993 "2017-08-23T03:53:38Z")\
**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:** [August 23, 2017, 3:53am UTC](https://discuss.elastic.co/t/exclude-pattern-in-logstash-s3-input/97993/1 "2017-08-23T03:53:38Z")

</div>

This is my s3 input config. I am trying to exclude a key that has name called CloudTrail-Digest.

```
input {
  s3 {
    type => "cloudtrail"
    bucket => "aws"
    prefix => "Accounts/"
    add_field => { source => gzfiles }
    backup_to_dir => "/mnt/aws/s3backup"
    exclude_pattern => "^CloudTrail-Digest/"
    codec => cloudtrail {}
    region => "us-west-2"
    sincedb_path => "/etc/s3backup/sincedb"
  }
}

```

But when i try to run logstash. It still downloads that file. Any idea if my regex is wrong.

```
20:47:01.414 [[main]<s3] DEBUG logstash.inputs.s3 - S3 input: Adding to objects[] {:key=>"Accounts/bigdata/AWSLogs/xxxxxxxxxxx/CloudTrail-Digest/ap-northeast-2/2017/07/12/xxxxxxxxxxxx_CloudTrail-Digest_ap-northeast-2_CybersecurityTemplate-CloudTrailImpl-11EE2N5EAOL3B_us-west-2_20170712T090720Z.json.gz"}
20:47:01.414 [[main]<s3] DEBUG logstash.inputs.s3 - objects[] length is: {:length=>2999}
```

---

<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:** [August 24, 2017, 7:57pm UTC](https://discuss.elastic.co/t/exclude-pattern-in-logstash-s3-input/97993/2 "2017-08-24T19:57:52Z")

</div>

I'm not familiar with the s3 input but: `^CloudTrail-Digest/` matches strings that _begin_ with CloudTrail-Digest, which the path in question clearly doesn't.

---

<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:** [August 24, 2017, 8:20pm UTC](https://discuss.elastic.co/t/exclude-pattern-in-logstash-s3-input/97993/3 "2017-08-24T20:20:33Z")

</div>

> [@magnusbaeck](#):
>
> ^CloudTrail-Digest/

So how can i exclude all the files that start with CloudTrail-Digest?

---

<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:** [August 24, 2017, 8:23pm UTC](https://discuss.elastic.co/t/exclude-pattern-in-logstash-s3-input/97993/4 "2017-08-24T20:23:22Z")

</div>

You can use `/CloudTrail-Digest/` to exclude all files that has CloudTrail-Digest as one patch component.

---

<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:** [August 24, 2017, 8:28pm UTC](https://discuss.elastic.co/t/exclude-pattern-in-logstash-s3-input/97993/5 "2017-08-24T20:28:15Z")

</div>

I will try this one and update you.

---

<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:** [September 21, 2017, 8:28pm UTC](https://discuss.elastic.co/t/exclude-pattern-in-logstash-s3-input/97993/6 "2017-09-21T20:28:19Z")

</div>

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