Skip to content

Commit b7baebd

Browse files
authored
Merge pull request #1726 from fluent/lynettemiles/sc-136179/update-fluent-bit-docs-pipeline-inputs-head
2 parents 7129f30 + 0ac59c6 commit b7baebd

File tree

1 file changed

+47
-27
lines changed

1 file changed

+47
-27
lines changed

pipeline/inputs/head.md

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
# Head
22

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

5-
## Configuration Parameters
5+
## Configuration parameters
66

77
The plugin supports the following configuration parameters:
88

99
| 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`. |
2020

21-
### Split Line Mode
21+
### Split line mode
2222

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`.
2424

25-
/proc/cpuinfo is a special file to get cpu information.
25+
`/proc/cpuinfo` is a special file to get CPU information.
2626

2727
```text
2828
processor : 0
@@ -38,10 +38,11 @@ physical id : 0
3838
siblings : 1
3939
```
4040

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:
4242

4343
{% tabs %}
4444
{% tab title="fluent-bit.conf" %}
45+
4546
```python
4647
[INPUT]
4748
Name head
@@ -60,9 +61,11 @@ Cpu frequency is "cpu MHz : 2791.009". We can get the line with this configurati
6061
Name stdout
6162
Match *
6263
```
64+
6365
{% endtab %}
6466

6567
{% tab title="fluent-bit.yaml" %}
68+
6669
```yaml
6770
pipeline:
6871
inputs:
@@ -79,13 +82,19 @@ pipeline:
7982
- name: stdout
8083
match: '*'
8184
```
85+
8286
{% endtab %}
8387
{% endtabs %}
8488
85-
Output is
89+
If you run the following command:
8690
8791
```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
8998
Fluent Bit v1.x.x
9099
* Copyright (C) 2019-2020 The Fluent Bit Authors
91100
* Copyright (C) 2015-2018 Treasure Data
@@ -99,16 +108,21 @@ Fluent Bit v1.x.x
99108
[3] head.cpu: [1498484308.008447978, {"line7"=>"cpu MHz : 2791.009"}]
100109
```
101110

102-
## Getting Started
111+
## Get started
103112

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

106-
### Command Line
115+
### Command line
107116

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:
109118

110119
```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
112126
Fluent Bit v1.x.x
113127
* Copyright (C) 2019-2020 The Fluent Bit Authors
114128
* Copyright (C) 2015-2018 Treasure Data
@@ -122,12 +136,13 @@ Fluent Bit v1.x.x
122136
[3] uptime: [1463543637, {"head"=>"133520.70 194879.72"}]
123137
```
124138

125-
### Configuration File
139+
### Configuration file
126140

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:
128142

129143
{% tabs %}
130144
{% tab title="fluent-bit.conf" %}
145+
131146
```python
132147
[INPUT]
133148
Name head
@@ -141,9 +156,11 @@ In your main configuration file append the following _Input_ & _Output_ sections
141156
Name stdout
142157
Match *
143158
```
159+
144160
{% endtab %}
145161

146162
{% tab title="fluent-bit.yaml" %}
163+
147164
```yaml
148165
pipeline:
149166
inputs:
@@ -157,9 +174,12 @@ pipeline:
157174
- name: stdout
158175
match: '*'
159176
```
177+
160178
{% endtab %}
161179
{% endtabs %}
162180
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)`.
164184

165-
e.g. 1.5s = 1s + 500000000ns
185+
For example: `1.5s = 1s + 500000000ns`.

0 commit comments

Comments
 (0)