# How can filebeat collect logs current date?

**URL:** https://discuss.elastic.co/t/how-can-filebeat-collect-logs-current-date/363754
**Category:** Beats
**Tags:** filebeat
**Created:** [July 25, 2024, 3:54am UTC](https://discuss.elastic.co/t/how-can-filebeat-collect-logs-current-date/363754 "2024-07-25T03:54:48Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![BevisDev](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BevisDev](https://discuss.elastic.co/u/BevisDev)
#### Post date: [July 25, 2024, 3:54am UTC](https://discuss.elastic.co/t/how-can-filebeat-collect-logs-current-date/363754/1 "2024-07-25T03:54:48Z")

</div>

Hi everyone, I am new in ELK Stack, I am encountered problems while collecting logs via Filebeat. Specifically I want to collect logs by path for example: /var/logs/\<current\_date\>/app.log and how can I collect current date and ignore previous dates?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/c/4c1981158654403002d76bb2ffba2b7ab25f9599.png)

---

<div class="post-metadata">

### Author: ![BevisDev](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BevisDev](https://discuss.elastic.co/u/BevisDev)
#### Post date: [July 26, 2024, 3:32am UTC](https://discuss.elastic.co/t/how-can-filebeat-collect-logs-current-date/363754/2 "2024-07-26T03:32:15Z")

</div>

Hi, anybody can support me?

---

<div class="post-metadata">

### Author: ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)
#### Post date: [July 26, 2024, 5:09am UTC](https://discuss.elastic.co/t/how-can-filebeat-collect-logs-current-date/363754/3 "2024-07-26T05:09:39Z")

</div>

Does this mean you only want to collect only from the last day, the last week or how?

---

<div class="post-metadata">

### Author: ![BevisDev](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BevisDev](https://discuss.elastic.co/u/BevisDev)
#### Post date: [July 26, 2024, 10:00am UTC](https://discuss.elastic.co/t/how-can-filebeat-collect-logs-current-date/363754/4 "2024-07-26T10:00:39Z")

</div>

Hi Rios,  
thanks for replying, I want to collect logs only current date.

---

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [July 26, 2024, 12:09pm UTC](https://discuss.elastic.co/t/how-can-filebeat-collect-logs-current-date/363754/5 "2024-07-26T12:09:26Z")

</div>

> [@BevisDev](#):
>
> I want to collect logs only current date

You want it to change dynamically? If so, this is not possible.

When you configure a [filestream](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-filestream.html) input in filebeat you need to specify the path, you can pass the full path, like `/var/log/2024-07-26/app.log` or use globs like `/var/log/*/*.log`, but you cannot configure it to be dynamically change the date.

If on `2024-07-26` you want to get logs only for the path `/var/log/2024-07-26` then you need to configure your path without globs in this part, something like `/var/log/2024-07-26/*.log`.

But to get logs for tomorrow you would need to change the file tomorrow and restart filebeat (all this can be automated outside filebeat with other tools).

You also have the [ignore\_older](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-filestream.html#filebeat-input-filestream-ignore-older) option that tells filebeat to ignore files older than some specific time when starting, but this may not work as you want.

This is based on the time filebeat starts (or restarts) and if somefile is added to some older folder filebeat would harvest it.

So, to get logs only for the current date you need to have the current date in the path when configuring your input.

---

<div class="post-metadata">

### Author: ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)
#### Post date: [July 26, 2024, 1:54pm UTC](https://discuss.elastic.co/t/how-can-filebeat-collect-logs-current-date/363754/6 "2024-07-26T13:54:55Z")

</div>

Leandro told you main point of FB is the feature: _ignore\_older_. Maybe you can use the script processor to drop events if they are not matched by timestemp or date in the directory path.

What you can consider is to involve LS which more powerful for data transformation, where is easy to add a control mechanism to drop all events which are not from today's directory.

There is also the age LS plugin, which was discussed on the [topic](https://discuss.elastic.co/t/drop-events-older-than-three-days/83423) however it's based on the timestamp field not directory.

---

<div class="post-metadata">

### Author: ![BevisDev](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BevisDev](https://discuss.elastic.co/u/BevisDev)
#### Post date: [July 26, 2024, 3:18pm UTC](https://discuss.elastic.co/t/how-can-filebeat-collect-logs-current-date/363754/7 "2024-07-26T15:18:43Z")

</div>

Thank Leandro and Riot so much, Perhaps i need to investigate more.  
Thanks
