1
1
# Head
2
2
3
- The ** head ** input plugin, allows to read events from the head of file. It's behavior is similar to the _ head _ command.
3
+ The _ Head _ input plugin reads events from the head of a file. Its behavior is similar to the ` head ` command.
4
4
5
- ## Configuration Parameters
5
+ ## Configuration parameters
6
6
7
7
The plugin supports the following configuration parameters:
8
8
9
9
| Key | Description |
10
- | :--- | :--- |
11
- | File | Absolute path to the target file, e.g: /proc/uptime |
12
- | Buf \_ Size | Buffer size to read the file. |
13
- | Interval \_ Sec | Polling interval \ ( seconds\ ) . |
14
- | Interval \_ NSec | Polling interval \( nanosecond \ ) . |
15
- | Add \_ Path | If enabled, filepath is appended to each records. Default value is _ false _ . |
16
- | Key | Rename a key. Default: head. |
17
- | Lines | Line number to read. If the number N is set, in \_ head reads first N lines like head\( 1 \ ) -n. |
18
- | Split \_ line | If enabled, in \_ head generates key-value pair per line. |
19
- | Threaded | Indicates whether to run this input in its own [ thread] ( ../../administration/multithreading.md#inputs ) . Default: ` false ` . |
10
+ | :-- | :------- --- |
11
+ | ` File ` | Absolute path to the target file. For example: ` /proc/uptime ` . |
12
+ | ` Buf_Size ` | Buffer size to read the file. |
13
+ | ` Interval_Sec ` | Polling interval (seconds). |
14
+ | ` Interval_NSec ` | Polling interval (nanoseconds ). |
15
+ | ` Add_Path ` | If enabled, the path is appended to each records. Default: ` false ` . |
16
+ | ` Key ` | Rename a key. Default: ` head ` . |
17
+ | ` Lines ` | Line number to read. If the number N is set, ` in_head ` reads first N lines like ` head(1 ) -n ` . |
18
+ | ` Split_line ` | If enabled, ` in_head ` generates key-value pair per line. |
19
+ | ` Threaded ` | Indicates whether to run this input in its own [ thread] ( ../../administration/multithreading.md#inputs ) . Default: ` false ` . |
20
20
21
- ### Split Line Mode
21
+ ### Split line mode
22
22
23
- This mode is useful to get a specific line. This is an example to get CPU frequency from /proc/cpuinfo.
23
+ Use this mode to get a specific line. The following example gets CPU frequency from ` /proc/cpuinfo ` .
24
24
25
- /proc/cpuinfo is a special file to get cpu information.
25
+ ` /proc/cpuinfo ` is a special file to get CPU information.
26
26
27
27
``` text
28
28
processor : 0
@@ -38,10 +38,11 @@ physical id : 0
38
38
siblings : 1
39
39
```
40
40
41
- Cpu frequency is " cpu MHz : 2791.009". We can get the line with this configuration file.
41
+ The CPU frequency is ` cpu MHz : 2791.009 ` . The following configuration file gets the needed line:
42
42
43
43
{% tabs %}
44
44
{% tab title="fluent-bit.conf" %}
45
+
45
46
``` python
46
47
[INPUT ]
47
48
Name head
@@ -60,9 +61,11 @@ Cpu frequency is "cpu MHz : 2791.009". We can get the line with this configurati
60
61
Name stdout
61
62
Match *
62
63
```
64
+
63
65
{% endtab %}
64
66
65
67
{% tab title="fluent-bit.yaml" %}
68
+
66
69
``` yaml
67
70
pipeline :
68
71
inputs :
@@ -79,13 +82,19 @@ pipeline:
79
82
- name : stdout
80
83
match : ' *'
81
84
` ` `
85
+
82
86
{% endtab %}
83
87
{% endtabs %}
84
88
85
- Output is
89
+ If you run the following command:
86
90
87
91
` ` ` bash
88
- $ bin/fluent-bit -c head.conf
92
+ bin/fluent-bit -c head.conf
93
+ ```
94
+
95
+ The output is something similar to;
96
+
97
+ ``` text
89
98
Fluent Bit v1.x.x
90
99
* Copyright (C) 2019-2020 The Fluent Bit Authors
91
100
* Copyright (C) 2015-2018 Treasure Data
@@ -99,16 +108,21 @@ Fluent Bit v1.x.x
99
108
[3] head.cpu: [1498484308.008447978, {"line7"=>"cpu MHz : 2791.009"}]
100
109
```
101
110
102
- ## Getting Started
111
+ ## Get started
103
112
104
- In order to read the head of a file, you can run the plugin from the command line or through the configuration file:
113
+ To read the head of a file, you can run the plugin from the command line or through the configuration file.
105
114
106
- ### Command Line
115
+ ### Command line
107
116
108
- 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:
117
+ 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:
109
118
110
119
``` bash
111
- $ fluent-bit -i head -t uptime -p File=/proc/uptime -o stdout -m '*'
120
+ fluent-bit -i head -t uptime -p File=/proc/uptime -o stdout -m ' *'
121
+ ```
122
+
123
+ The output will look similar to:
124
+
125
+ ``` text
112
126
Fluent Bit v1.x.x
113
127
* Copyright (C) 2019-2020 The Fluent Bit Authors
114
128
* Copyright (C) 2015-2018 Treasure Data
@@ -122,12 +136,13 @@ Fluent Bit v1.x.x
122
136
[3] uptime: [1463543637, {"head"=>"133520.70 194879.72"}]
123
137
```
124
138
125
- ### Configuration File
139
+ ### Configuration file
126
140
127
- In your main configuration file append the following _Input_ & _Output_ sections:
141
+ In your main configuration file append the following ` Input ` and ` Output ` sections:
128
142
129
143
{% tabs %}
130
144
{% tab title="fluent-bit.conf" %}
145
+
131
146
``` python
132
147
[INPUT ]
133
148
Name head
@@ -141,9 +156,11 @@ In your main configuration file append the following _Input_ & _Output_ sections
141
156
Name stdout
142
157
Match *
143
158
```
159
+
144
160
{% endtab %}
145
161
146
162
{% tab title="fluent-bit.yaml" %}
163
+
147
164
``` yaml
148
165
pipeline :
149
166
inputs :
@@ -157,9 +174,12 @@ pipeline:
157
174
- name : stdout
158
175
match : ' *'
159
176
` ` `
177
+
160
178
{% endtab %}
161
179
{% endtabs %}
162
180
163
- Note: Total interval \( sec\) = Interval\_ Sec + \( Interval\_ Nsec / 1000000000\) .
181
+ The interval is calculated like this:
182
+
183
+ ` Total interval (sec) = Interval_Sec + (Interval_Nsec / 1000000000)`.
164
184
165
- e.g. 1.5s = 1s + 500000000ns
185
+ For example : ` 1.5s = 1s + 500000000ns` .
0 commit comments