# \[FILEBEAT\] How to read, send to ElasticSearch and close each files

**URL:** <https://discuss.elastic.co/t/filebeat-how-to-read-send-to-elasticsearch-and-close-each-files/137029>\
**Category:** Beats\
**Created:** [June 22, 2018, 1:34pm UTC](https://discuss.elastic.co/t/filebeat-how-to-read-send-to-elasticsearch-and-close-each-files/137029 "2018-06-22T13:34:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyl](https://avatars.discourse-cdn.com/v4/letter/d/5fc32e/32.png) [@dyl](https://discuss.elastic.co/u/dyl)\
**Post date:** [June 22, 2018, 1:34pm UTC](https://discuss.elastic.co/t/filebeat-how-to-read-send-to-elasticsearch-and-close-each-files/137029/1 "2018-06-22T13:34:33Z")

</div>

Hello everybody.

I would like to know if I had possibility for each files that Filebeat listen to do :

- Open the file.
- Reading the file.
- Do a logstash treatment.
- Send the file to logstash output.
- Close this file.

I found "close\_eof" option, it's good but all my files in my filebeat listening directory are opened in the same time :

```
|2018-06-22T15:23:55.804+0200|INFO|log/harvester.go:216|Harvester started for file: C:\Users\busy\Desktop\bic\trie-2391460397.log|
|---|---|---|---|
|2018-06-22T15:23:55.805+0200|INFO|log/harvester.go:216|Harvester started for file: C:\Users\busy\Desktop\bic\trie-279990785.log|
|2018-06-22T15:23:55.806+0200|INFO|log/harvester.go:216|Harvester started for file: C:\Users\busy\Desktop\bic\trie-3654726275.log|
|2018-06-22T15:23:55.806+0200|INFO|log/harvester.go:216|Harvester started for file: C:\Users\busy\Desktop\bic\trie-400042090.log|
|2018-06-22T15:23:55.811+0200|INFO|log/harvester.go:216|Harvester started for file: C:\Users\busy\Desktop\bic\trie-1850010684.log|
|2018-06-22T15:23:55.812+0200|INFO|log/harvester.go:216|Harvester started for file: C:\Users\busy\Desktop\bic\trie-1929394145.log|
|2018-06-22T15:23:55.815+0200|INFO|log/harvester.go:216|Harvester started for file: C:\Users\busy\Desktop\bic\trie-384824503.log|
|2018-06-22T15:23:55.818+0200|INFO|log/harvester.go:216|Harvester started for file: C:\Users\busy\Desktop\bic\trie-2854993123.log|
|2018-06-22T15:23:55.819+0200|INFO|log/harvester.go:239|End of file reached: C:\Users\busy\Desktop\bic\trie-279990785.log. Closing because close_eof is enabled.|
|2018-06-22T15:23:55.821+0200|INFO|log/harvester.go:216|Harvester started for file: C:\Users\busy\Desktop\bic\trie-3489823606.log|
|2018-06-22T15:23:55.824+0200|INFO|log/harvester.go:239|End of file reached: C:\Users\busy\Desktop\bic\trie-2854993123.log. Closing because close_eof is enabled.|
|2018-06-22T15:23:55.826+0200|INFO|log/harvester.go:239|End of file reached: C:\Users\busy\Desktop\bic\trie-3489823606.log. Closing because close_eof is enabled.|
|2018-06-22T15:23:55.864+0200|INFO|log/harvester.go:239|End of file reached: C:\Users\busy\Desktop\bic\trie-1929394145.log. Closing because close_eof is enabled.|
|2018-06-22T15:23:55.865+0200|INFO|log/harvester.go:239|End of file reached: C:\Users\busy\Desktop\bic\trie-2391460397.log. Closing because close_eof is enabled.|
|2018-06-22T15:23:55.865+0200|INFO|log/harvester.go:239|End of file reached: C:\Users\busy\Desktop\bic\trie-3654726275.log. Closing because close_eof is enabled.|
|2018-06-22T15:23:55.865+0200|INFO|log/harvester.go:239|End of file reached: C:\Users\busy\Desktop\bic\trie-1850010684.log. Closing because close_eof is enabled.|
|2018-06-22T15:23:55.865+0200|INFO|log/harvester.go:239|End of file reached: C:\Users\busy\Desktop\bic\trie-400042090.log. Closing because close_eof is enabled.|
|2018-06-22T15:23:55.865+0200|INFO|log/harvester.go:239|End of file reached: C:\Users\busy\Desktop\bic\trie-384824503.log. Closing because close_eof is enabled.|

```

But I would like to be able to read only ONE file at the same time, then close him and pass in an other one.

Is it possible ?

Thx u

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [June 22, 2018, 2:08pm UTC](https://discuss.elastic.co/t/filebeat-how-to-read-send-to-elasticsearch-and-close-each-files/137029/2 "2018-06-22T14:08:23Z")

</div>

Filebeat does not enforce any order when writing. It tries to publish logs concurrently. You can limit the number of active files being processed, by the configuring [harvester\_limit](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-log.html#filebeat-input-log-harvester-limit) in the prospector settings.

---

<div class="post-metadata">

**Author:** ![dyl](https://avatars.discourse-cdn.com/v4/letter/d/5fc32e/32.png) [@dyl](https://discuss.elastic.co/u/dyl)\
**Post date:** [June 22, 2018, 6:10pm UTC](https://discuss.elastic.co/t/filebeat-how-to-read-send-to-elasticsearch-and-close-each-files/137029/3 "2018-06-22T18:10:01Z")

</div>

Thx for all @steffens

you solved my problem

---

<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 20, 2018, 8:10pm UTC](https://discuss.elastic.co/t/filebeat-how-to-read-send-to-elasticsearch-and-close-each-files/137029/4 "2018-07-20T20:10:12Z")

</div>

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