You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The **stdin**plugin supports retrieving a message stream from the standard input interface \(stdin\) of the Fluent Bit process.
4
-
In order to use it, specify the plugin name as the input, e.g:
3
+
The _Standard input_plugin supports retrieving a message stream from the standard input interface (`stdin`) of the Fluent Bit process.
4
+
To use it, specify the plugin name as the input. For example:
5
5
6
6
```bash
7
-
$ fluent-bit -i stdin -o stdout
7
+
fluent-bit -i stdin -o stdout
8
8
```
9
9
10
-
If the stdin stream is closed (end-of-file), the stdin plugin will instruct
11
-
Fluent Bit to exit with success (0) after flushing any pending output.
10
+
If the `stdin` stream is closed (`end-of-file`), the plugin instructs Fluent Bit to exit with success (`0`) after flushing any pending output.
11
+
12
+
## Configuration parameters
13
+
14
+
The plugin supports the following configuration parameters:
15
+
16
+
| Key | Description | Default |
17
+
| :--- | :--- | :--- |
18
+
|`Buffer_Size`| Set the buffer size to read data. This value is used to increase buffer size and must be set according to the [Unit Size](../../administration/configuring-fluent-bit/unit-sizes.md) specification. |`16k`|
19
+
|`Parser`| The name of the parser to invoke instead of the default JSON input parser. |_none_|
20
+
|`Threaded`| Indicates whether to run this input in its own [thread](../../administration/multithreading.md#inputs). |`false`|
12
21
13
22
## Input formats
14
23
15
-
If no parser is configured for the stdin plugin, it expects *valid JSON* input data in one of the following formats:
24
+
If no parser is configured for the `stdin` plugin, it expects valid JSON input data in one of the following formats:
16
25
17
-
1. A JSON object with one or more key-value pairs: `{ "key": "value", "key2": "value2" }`
18
-
3. A 2-element JSON array in [Fluent Bit Event](../../concepts/key-concepts.md#event-or-record) format, which may be:
19
-
*`[TIMESTAMP, { "key": "value" }]` where TIMESTAMP is a floating point value representing a timestamp in seconds; or
20
-
* from Fluent Bit v2.1.0, `[[TIMESTAMP, METADATA], { "key": "value" }]` where TIMESTAMP has the same meaning as above and METADATA is a JSON object.
26
+
- A JSON object with one or more key-value pairs: `{ "key": "value", "key2": "value2" }`
27
+
- A 2-element JSON array in [Fluent Bit Event](../../concepts/key-concepts.md#event-or-record) format, which can be:
28
+
-`[TIMESTAMP, { "key": "value" }]` where TIMESTAMP is a floating point value representing a timestamp in seconds.
29
+
- From Fluent Bit v2.1.0, `[[TIMESTAMP, METADATA], { "key": "value" }]` where _`TIMESTAMP`_ has the same meaning as previous and _`METADATA`_ is a JSON object.
21
30
22
31
Multi-line input JSON is supported.
23
32
24
-
Any input data that is *not*in one of the above formats will cause the plugin to log errors like:
33
+
Any input data which isn't in one of the supported formats will cause the plugin to log errors like:
[error] [input:stdin:stdin.0] invalid record found, it's not a JSON map or array
29
38
```
30
39
31
-
To handle inputs in other formats, a parser must be explicitly specified in the configuration for the `stdin` plugin. See [parser input example](#parser-input-example) for sample configuration.
40
+
To handle inputs in other formats, a parser must be explicitly specified in the configuration for the `stdin` plugin. See [parser input example](#parser-input) for sample configuration.
32
41
33
42
## Log event timestamps
34
43
35
-
The Fluent Bit event timestamp will be set from the input record if the 2-element event input is used or a custom parser configuration supplies a timestamp. Otherwise the event timestamp will be set to the timestamp at which the record is read by the stdin plugin.
44
+
The Fluent Bit event timestamp will be set from the input record if the two-element event input is used or a custom parser configuration supplies a timestamp. Otherwise the event timestamp will be set to the timestamp at which the record is read by the `stdin` plugin.
36
45
37
46
## Examples
38
47
39
-
### Json input example
48
+
### JSON input
40
49
41
-
A better example to demonstrate how it works will be through a _Bash_ script that generates messages and writes them to [Fluent Bit](http://fluentbit.io). Write the following content in a file named _test.sh_:
50
+
To demonstrate how the plugin works, you can use a `bash` script that generates messages and writes them to [Fluent Bit](http://fluentbit.io).
42
51
43
-
```bash
44
-
#!/bin/sh
52
+
1. Write the following content in a file named `test.sh`:
45
53
46
-
for((i=0; i<=5; i++));do
47
-
echo -n "{\"key\": \"some value\"}"
48
-
sleep 1
49
-
done
50
-
```
54
+
```bash
55
+
#!/bin/sh
51
56
52
-
Now lets start the script and [Fluent Bit](http://fluentbit.io):
57
+
for((i=0; i<=5; i++));do
58
+
echo -n "{\"key\": \"some value\"}"
59
+
sleep 1
60
+
done
61
+
```
53
62
54
-
```bash
55
-
$ bash test.sh | fluent-bit -q -i stdin -o stdout
63
+
1. Start the script and [Fluent Bit](http://fluentbit.io):
64
+
65
+
```bash
66
+
bash test.sh | fluent-bit -q -i stdin -o stdout
67
+
```
68
+
69
+
The command should return output like the following:
In real-world deployments it is best to use a more realistic parser that splits
197
-
messages into real fields and adds appropriate tags.
198
-
199
-
## Configuration Parameters <aid="config"></a>
200
-
201
-
The plugin supports the following configuration parameters:
202
-
203
-
| Key | Description | Default |
204
-
| :--- | :--- | :--- |
205
-
| Buffer\_Size | Set the buffer size to read data. This value is used to increase buffer size. The value must be according to the [Unit Size](../../administration/configuring-fluent-bit/unit-sizes.md) specification. | 16k |
206
-
| Parser | The name of the parser to invoke instead of the default JSON input parser ||
207
-
| Threaded | Indicates whether to run this input in its own [thread](../../administration/multithreading.md#inputs). |`false`|
228
+
In production deployments it's best to use a parser that splits messages into real fields and adds appropriate tags.
0 commit comments