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:

Key
Description
Default

add_path

If enabled, the path is appended to each record.

false

buf_size

Buffer size to read the file.

256

file

Absolute path to the target file. For example: /proc/uptime.

none

interval_nsec

Polling interval (nanoseconds).

0

interval_sec

Polling interval (seconds).

1

key

Rename a key.

head

lines

Line number to read. If the number N is set, in_head reads first N lines like head(1) -n.

0

split_line

If enabled, in_head generates key-value pair per line.

false

threaded

Indicates whether to run this input in its own thread.

false

Getting 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.

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.

The 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;

Last updated

Was this helpful?