# Limit audit logs to a certain number of days

**URL:** <https://discuss.elastic.co/t/limit-audit-logs-to-a-certain-number-of-days/219153>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-monitoring, elastic-stack-security, elastic-stack-alerting\
**Created:** [February 13, 2020, 8:11am UTC](https://discuss.elastic.co/t/limit-audit-logs-to-a-certain-number-of-days/219153 "2020-02-13T08:11:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![soumendra](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@soumendra](https://discuss.elastic.co/u/soumendra)\
**Post date:** [February 13, 2020, 8:11am UTC](https://discuss.elastic.co/t/limit-audit-logs-to-a-certain-number-of-days/219153/1 "2020-02-13T08:11:31Z")

</div>

We have the following configuration in our `elasticsearch.yml` file. Is there any way we can limit the audit logs to be stored only for the last 2 weeks.

```
xpack.security.audit.enabled: true
xpack.security.audit.outputs: [index, logfile]
xpack.security.audit.logfile.events.emit_request_body: true

```

ES version: 7.3.2  
X-pack tier: Platinum pack

---

<div class="post-metadata">

**Author:** ![ahmed\_charafouddine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmed_charafouddine/32/45129_2.png) [@ahmed\_charafouddine](https://discuss.elastic.co/u/ahmed_charafouddine)\
**Post date:** [February 13, 2020, 8:59am UTC](https://discuss.elastic.co/t/limit-audit-logs-to-a-certain-number-of-days/219153/2 "2020-02-13T08:59:48Z")

</div>

Here is an approach that can provide a solution. you have to index the data in a daily index. 1 index per day. Then, either you use the curator tool to define a retention date of 2 weeks (either 2 \* 7 days = 14 days), or you create a script that will do this job.

---

<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 12, 2020, 8:59am UTC](https://discuss.elastic.co/t/limit-audit-logs-to-a-certain-number-of-days/219153/3 "2020-03-12T08:59:51Z")

</div>

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