# Using filebeat to trigger a python code

**URL:** <https://discuss.elastic.co/t/using-filebeat-to-trigger-a-python-code/131107>\
**Category:** Beats\
**Created:** [May 9, 2018, 6:25am UTC](https://discuss.elastic.co/t/using-filebeat-to-trigger-a-python-code/131107 "2018-05-09T06:25:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashay.dhavale](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@ashay.dhavale](https://discuss.elastic.co/u/ashay.dhavale)\
**Post date:** [May 9, 2018, 6:25am UTC](https://discuss.elastic.co/t/using-filebeat-to-trigger-a-python-code/131107/1 "2018-05-09T06:25:24Z")

</div>

Hi

Can i use filebeat to monitor a directory and trigger a python code as soon as a new file is received in that directory? What changes do i need and where.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 9, 2018, 6:38am UTC](https://discuss.elastic.co/t/using-filebeat-to-trigger-a-python-code/131107/2 "2018-05-09T06:38:49Z")

</div>

Filebeat is not built to do this sort of thing.

Perhaps if you can explain what the script does we can suggest other options.

---

<div class="post-metadata">

**Author:** ![ashay.dhavale](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@ashay.dhavale](https://discuss.elastic.co/u/ashay.dhavale)\
**Post date:** [May 9, 2018, 7:41am UTC](https://discuss.elastic.co/t/using-filebeat-to-trigger-a-python-code/131107/3 "2018-05-09T07:41:20Z")

</div>

We wanted to use filebeat more like a filewatcher. Capture the incoming filename, pass that as an argument to a python code and then the python code does transformation on that incoming file data.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 9, 2018, 11:00pm UTC](https://discuss.elastic.co/t/using-filebeat-to-trigger-a-python-code/131107/4 "2018-05-09T23:00:41Z")

</div>

What does the script do? Why not use Logstash for it?

---

<div class="post-metadata">

**Author:** ![ashay.dhavale](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@ashay.dhavale](https://discuss.elastic.co/u/ashay.dhavale)\
**Post date:** [May 10, 2018, 12:37pm UTC](https://discuss.elastic.co/t/using-filebeat-to-trigger-a-python-code/131107/5 "2018-05-10T12:37:15Z")

</div>

If the incoming file is zipped, the python code will unzip the files, the read each unzipped file and apply some transformation rules on that file content.

---

<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:** [June 7, 2018, 2:37pm UTC](https://discuss.elastic.co/t/using-filebeat-to-trigger-a-python-code/131107/6 "2018-06-07T14:37:19Z")

</div>

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