Skip to content

Commit 268b914

Browse files
authored
Updated head input plugin doc for standards and order. Fixes #2260. (#2261)
Updated head input plugin doc for standards and order. Fixes #2260. Signed-off-by: Eric D. Schabell <eric@schabell.org>
1 parent 47ab62f commit 268b914

File tree

1 file changed

+115
-115
lines changed

1 file changed

+115
-115
lines changed

pipeline/inputs/head.md

Lines changed: 115 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,95 @@ The _Head_ input plugin reads events from the head of a file. Its behavior is si
66

77
The plugin supports the following configuration parameters:
88

9-
| Key | Description |
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-
21-
### Split line mode
9+
| Key | Description | Default |
10+
|:----------------|:--------------------------------------------------------------------------------------------------------|:--------|
11+
| `Add_Path` | If enabled, the path is appended to each record. | `false` |
12+
| `Buf_Size` | Buffer size to read the file. | `256` |
13+
| `File` | Absolute path to the target file. For example: `/proc/uptime`. | _none_ |
14+
| `Interval_NSec` | Polling interval (nanoseconds). | `0` |
15+
| `Interval_Sec` | Polling interval (seconds). | `1` |
16+
| `Key` | Rename a key. | `head` |
17+
| `Lines` | Line number to read. If the number N is set, `in_head` reads first N lines like `head(1) -n`. | `0` |
18+
| `Split_line` | If enabled, `in_head` generates key-value pair per line. | `false` |
19+
| `Threaded` | Indicates whether to run this input in its own [thread](../../administration/multithreading.md#inputs). | `false` |
20+
21+
## Getting started
22+
23+
To read the head of a file, you can run the plugin from the command line or through the configuration file.
24+
25+
### Command line
26+
27+
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:
28+
29+
```shell
30+
fluent-bit -i head -t uptime -p File=/proc/uptime -o stdout -m '*'
31+
```
32+
33+
The output will look similar to:
34+
35+
```text
36+
Fluent Bit v1.x.x
37+
* Copyright (C) 2019-2020 The Fluent Bit Authors
38+
* Copyright (C) 2015-2018 Treasure Data
39+
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
40+
* https://fluentbit.io
41+
42+
[2016/05/17 21:53:54] [ info] starting engine
43+
[0] uptime: [1463543634, {"head"=>"133517.70 194870.97"}]
44+
[1] uptime: [1463543635, {"head"=>"133518.70 194872.85"}]
45+
[2] uptime: [1463543636, {"head"=>"133519.70 194876.63"}]
46+
[3] uptime: [1463543637, {"head"=>"133520.70 194879.72"}]
47+
```
48+
49+
### Configuration file
50+
51+
In your main configuration file append the following:
52+
53+
{% tabs %}
54+
{% tab title="fluent-bit.yaml" %}
55+
56+
```yaml
57+
pipeline:
58+
inputs:
59+
- name: head
60+
tag: uptime
61+
file: /proc/uptime
62+
buf_size: 256
63+
interval_sec: 1
64+
interval_nsec: 0
65+
66+
outputs:
67+
- name: stdout
68+
match: '*'
69+
```
70+
71+
{% endtab %}
72+
{% tab title="fluent-bit.conf" %}
73+
74+
```text
75+
[INPUT]
76+
Name head
77+
Tag uptime
78+
File /proc/uptime
79+
Buf_Size 256
80+
Interval_Sec 1
81+
Interval_NSec 0
82+
83+
[OUTPUT]
84+
Name stdout
85+
Match *
86+
```
87+
88+
{% endtab %}
89+
{% endtabs %}
90+
91+
The interval is calculated like this:
92+
93+
`Total interval (sec) = Interval_Sec + (Interval_Nsec / 1000000000)`.
94+
95+
For example: `1.5s = 1s + 500000000ns`.
96+
97+
## Split line mode
2298

2399
Use this mode to get a specific line. The following example gets CPU frequency from `/proc/cpuinfo`.
24100

@@ -45,43 +121,43 @@ The CPU frequency is `cpu MHz : 2791.009`. The following configuration file gets
45121

46122
```yaml
47123
pipeline:
48-
inputs:
49-
- name: head
50-
tag: head.cpu
51-
file: /proc/cpuinfo
52-
lines: 8
53-
split_line: true
54-
55-
filters:
56-
- name: record_modifier
57-
match: '*'
58-
whitelist_key: line7
59-
60-
outputs:
61-
- name: stdout
62-
match: '*'
124+
inputs:
125+
- name: head
126+
tag: head.cpu
127+
file: /proc/cpuinfo
128+
lines: 8
129+
split_line: true
130+
131+
filters:
132+
- name: record_modifier
133+
match: '*'
134+
whitelist_key: line7
135+
136+
outputs:
137+
- name: stdout
138+
match: '*'
63139
```
64140
65141
{% endtab %}
66142
{% tab title="fluent-bit.conf" %}
67143
68144
```text
69145
[INPUT]
70-
Name head
71-
Tag head.cpu
72-
File /proc/cpuinfo
73-
Lines 8
74-
Split_line true
75-
# {"line0":"processor : 0", "line1":"vendor_id : GenuineIntel" ...}
146+
Name head
147+
Tag head.cpu
148+
File /proc/cpuinfo
149+
Lines 8
150+
Split_line true
151+
# {"line0":"processor : 0", "line1":"vendor_id : GenuineIntel" ...}
76152

77153
[FILTER]
78-
Name record_modifier
79-
Match *
80-
Whitelist_key line7
154+
Name record_modifier
155+
Match *
156+
Whitelist_key line7
81157

82158
[OUTPUT]
83-
Name stdout
84-
Match *
159+
Name stdout
160+
Match *
85161
```
86162

87163
{% endtab %}
@@ -108,79 +184,3 @@ Fluent Bit v1.x.x
108184
[2] head.cpu: [1498484307.010042482, {"line7"=>"cpu MHz : 2791.009"}]
109185
[3] head.cpu: [1498484308.008447978, {"line7"=>"cpu MHz : 2791.009"}]
110186
```
111-
112-
## Get started
113-
114-
To read the head of a file, you can run the plugin from the command line or through the configuration file.
115-
116-
### Command line
117-
118-
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:
119-
120-
```shell
121-
fluent-bit -i head -t uptime -p File=/proc/uptime -o stdout -m '*'
122-
```
123-
124-
The output will look similar to:
125-
126-
```text
127-
Fluent Bit v1.x.x
128-
* Copyright (C) 2019-2020 The Fluent Bit Authors
129-
* Copyright (C) 2015-2018 Treasure Data
130-
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
131-
* https://fluentbit.io
132-
133-
[2016/05/17 21:53:54] [ info] starting engine
134-
[0] uptime: [1463543634, {"head"=>"133517.70 194870.97"}]
135-
[1] uptime: [1463543635, {"head"=>"133518.70 194872.85"}]
136-
[2] uptime: [1463543636, {"head"=>"133519.70 194876.63"}]
137-
[3] uptime: [1463543637, {"head"=>"133520.70 194879.72"}]
138-
```
139-
140-
### Configuration file
141-
142-
In your main configuration file append the following:
143-
144-
{% tabs %}
145-
{% tab title="fluent-bit.yaml" %}
146-
147-
```yaml
148-
pipeline:
149-
inputs:
150-
- name: head
151-
tag: uptime
152-
file: /proc/uptime
153-
buf_size: 256
154-
interval_sec: 1
155-
interval_nsec: 0
156-
157-
outputs:
158-
- name: stdout
159-
match: '*'
160-
```
161-
162-
{% endtab %}
163-
{% tab title="fluent-bit.conf" %}
164-
165-
```shell
166-
[INPUT]
167-
Name head
168-
Tag uptime
169-
File /proc/uptime
170-
Buf_Size 256
171-
Interval_Sec 1
172-
Interval_NSec 0
173-
174-
[OUTPUT]
175-
Name stdout
176-
Match *
177-
```
178-
179-
{% endtab %}
180-
{% endtabs %}
181-
182-
The interval is calculated like this:
183-
184-
`Total interval (sec) = Interval_Sec + (Interval_Nsec / 1000000000)`.
185-
186-
For example: `1.5s = 1s + 500000000ns`.

0 commit comments

Comments
 (0)