Head
The Head input plugin reads events from the head of a file. Its behavior is similar to the head command.
Configuration parameters
The plugin supports the following configuration parameters:
File
Absolute path to the target file. For example: /proc/uptime.
Buf_Size
Buffer size to read the file.
Interval_Sec
Polling interval (seconds).
Interval_NSec
Polling interval (nanoseconds).
Add_Path
If enabled, the path is appended to each records. Default: false.
Key
Rename a key. Default: head.
Lines
Line number to read. If the number N is set, in_head reads first N lines like head(1) -n.
Split_line
If enabled, in_head generates key-value pair per line.
Threaded
Indicates whether to run this input in its own thread. Default: false.
Split line mode
Use this mode to get a specific line. The following example gets CPU frequency from /proc/cpuinfo.
/proc/cpuinfo is a special file to get CPU information.
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz
stepping : 7
microcode : 41
cpu MHz : 2791.009
cache size : 4096 KB
physical id : 0
siblings : 1The CPU frequency is cpu MHz : 2791.009. The following configuration file gets the needed line:
If you run the following command:
The output is something similar to;
Get started
To read the head of a file, you can run the plugin from the command line or through the configuration file.
Command line
The following example will read events from the /proc/uptime file, tag the records with the uptime name and flush them back to the stdout plugin:
The output will look similar to:
Configuration file
In your main configuration file append the following:
The interval is calculated like this:
Total interval (sec) = Interval_Sec + (Interval_Nsec / 1000000000).
For example: 1.5s = 1s + 500000000ns.
Last updated
Was this helpful?