exec

The in_exec Input plugin executes external programs to receive or pull event logs. It will then read TSV (tab-separated values), JSON or MessagePack from the standard output of the program.
You can run a program periodically or permanently. To run periodically, please use the run_interval parameter.
It is included in Fluentd's core.
Example Configuration
Refer to the Configuration File article for the basic structure and syntax of the configuration file.
Plugin Helpers
Parameters
See Common Parameters.
@type
@typeThe value must be exec.
command
commandstring
required parameter
0.14.0
The command (program) to execute.
tag
tagstring
required if extract/tag_key is not specified
0.14.0
The tag of the output events.
run_interval
run_intervaltime
nil
0.14.0
The interval time between periodic program runs. If not specified, command script runs only once.
read_block_size
read_block_sizesize
10240
0.14.9
The default block size to read if parser requires partial read.
connect_mode
connect_modeenum
read
read/read_with_stderr
1.11.3
Control target IO:
read: Read logs from stdioread_with_stderr: Read logs from stdio and stderr.
read_with_stderr is mainly for debug.
<parse> section
<parse> sectionfalse
false
0.14.9
Refer these for more details about parse section:
@type
@typestring
tsv
0.14.9
Overwrites the default value in this plugin.
time_type
time_typestring
float
0.14.9
Overwrites the default value in this plugin.
time_key
time_keystring
nil
0.14.9
Overwrites the default value in this plugin.
estimate_current_event
estimate_current_eventbool
false
0.14.9
Overwrites the default value in this plugin.
<extract> Section
<extract> Sectionfalse
false
0.14.9
See Extract section configurations.
time_type
time_typestring
float
0.14.9
Overwrites the default value in this plugin.
Use Cases
Monitor Load Averages
Here is a simple example to fetch load average stats on Linux systems. This configuration instructs Fluentd to read /proc/loadavg once per minute and emit the file content as events.
This configuration emits events like this one:
Real World Example: Scrape Hacker News Top Page
If you already have a script that runs periodically (say, via cron) that you wish to store the output to multiple backend systems (HDFS, AWS, Elasticsearch, etc.), in_exec is a great choice.
The only requirement for the script is that it outputs TSV, JSON or MessagePack.
For example, this script scrapes the front page of Hacker News and scrapes information about each post:
Suppose that script is called hn.rb. Then, you can run it every 5 minutes with the following configuration:
And if you run Fluentd with it, you will see the following output (if you are impatient, CTRL+C to flush the stdout buffer):
Of course, you can use Fluentd's many output plugins to store the data into various backend systems like Elasticsearch, HDFS, MongoDB, AWS, etc.
If this article is incorrect or outdated, or omits critical information, please let us know. Fluentd is an open-source project under Cloud Native Computing Foundation (CNCF). All components are available under the Apache 2 License.
Last updated
Was this helpful?