Search code examples
fluentd

Unable to Run a Simple Python Script on Fluentd


I have a python script called script.py. When I run this script, it creates a logs folder on the Desktop and downloads all the necessary logs from a website and writes them as .log files in this logs folder. I want Fluentd to run this script every 5 minutes and do nothing more. The next source I have on the config file does the real job of sending this log data to another place. If I already have the logs folder on the Desktop, this log files are uploaded correctly to the next destination. But the script never runs. If I delete my logs folder locally, this is the output fluentd gives:

2020-07-27 10:20:42 +0200 [trace]: #0 plugin/buffer.rb:350:enqueue_all: enqueueing all chunks in buffer instance=47448563172440
2020-07-27 10:21:09 +0200 [trace]: #0 plugin/buffer.rb:350:enqueue_all: enqueueing all chunks in buffer instance=47448563172440
2020-07-27 10:21:36 +0200 [debug]: #0 plugin_helper/child_process.rb:255:child_process_execute_once: Executing command title=:exec_input spawn=[{}, "python /home/zohair/Desktop/script.py"] mode=[:read] stderr=:discard

This never gives a logs folder on my Desktop which the script normally does output if run locally like python script.py

If I already have the logs folder, I can see the logs on the stdout normally. Here is my config file:

<source>
@type exec
command python /home/someuser/Desktop/script.py
run_interval 5m
<parse>
@type none
keys none
</parse>
<extract> 
tag_key none
</extract>
</source>
 
 
<source>
@type tail
read_from_head true
path /home/someuser/Desktop/logs/*
tag sensor_1.log-raw-data
refresh_interval 5m
<parse>
@type none
</parse>
</source>
 
<match sensor_1.log-raw-data>
@type stdout
</match>
 

I just need fluentd to run the script and do nothing else, and let the other source take this data and send it to somewhere else. Any solutions?


Solution

  • Problem was solved by creating another @type exec for pip install -r requirements.txt which fulfilled the missing module error which was not being shown on the fluentd error log (Was running fluentd as superuser).