# Read the same file several times

**URL:** <https://discuss.elastic.co/t/read-the-same-file-several-times/76655>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [February 27, 2017, 4:34pm UTC](https://discuss.elastic.co/t/read-the-same-file-several-times/76655 "2017-02-27T16:34:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jstar](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@jstar](https://discuss.elastic.co/u/jstar)\
**Post date:** [February 27, 2017, 4:34pm UTC](https://discuss.elastic.co/t/read-the-same-file-several-times/76655/1 "2017-02-27T16:34:09Z")

</div>

Hi,

I have a file that I want to harvest many time with filebeat. That means the file has some logs (say 1000 logs lines) which don't change. Once filebeat has finish harvesting these 1000 logs, I want it to reharvest again those logs starting from the beginning.

I know that this can be done by deleting the file **/var/lib/filebeat/registry** but I don't want to do it that want. I was wondering if it is possible to configure filebeat so that it will reset all its offsets in the file **/var/lib/filebeat/registry** so that each time it will keep on sending the same logs.

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [March 1, 2017, 8:11am UTC](https://discuss.elastic.co/t/read-the-same-file-several-times/76655/2 "2017-03-01T08:11:02Z")

</div>

You can use the clean\_\* options which will clean the registry. But to pick up the file again, the modtime must change. You could use `touch` for that. Can you share some more background on the above use case, especially what you use it for?

---

<div class="post-metadata">

**Author:** ![jstar](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@jstar](https://discuss.elastic.co/u/jstar)\
**Post date:** [March 4, 2017, 3:14pm UTC](https://discuss.elastic.co/t/read-the-same-file-several-times/76655/3 "2017-03-04T15:14:11Z")

</div>

Thanks for the reply @ruflin. The idea is send some logs repeatly to a kafka topic. I will then collect those logs and do some analyses with them. Here is my config

```
filebeat.prospectors:

- paths:
    - "/path/to/logs/*.*"

output.kafka:
  enabled: true

  hosts: ["kakfaip1:9092","kakfaip2:9092","kakfaip3:9092"]

  topic: mytopic

  username: username
  password: pwduser

```

This config works well. But once filebeat have finished reading the files in **/path/to/logs/** , it stops sending logs to the topic **mytopic**. So I want filebeat to reread the file again and again starting from the begining each time.

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [March 6, 2017, 2:43pm UTC](https://discuss.elastic.co/t/read-the-same-file-several-times/76655/4 "2017-03-06T14:43:07Z")

</div>

Did you try out the clean\_\* options?

---

<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:** [April 3, 2017, 2:43pm UTC](https://discuss.elastic.co/t/read-the-same-file-several-times/76655/5 "2017-04-03T14:43:17Z")

</div>

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