Skip to content

Commit bb58fbb

Browse files
committed
Pipeline: input: tcp: style
Signed-off-by: Lynette Miles <[email protected]>
1 parent 69f4bbe commit bb58fbb

File tree

1 file changed

+49
-41
lines changed

1 file changed

+49
-41
lines changed

pipeline/inputs/tcp.md

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,66 @@
11
# TCP
22

3-
The **tcp** input plugin allows to retrieve structured JSON or raw messages over a TCP network interface (TCP port).
3+
The _TCP_ input plugin lets you retrieve structured JSON or raw messages over a TCP network interface (TCP port).
44

55
## Configuration Parameters
66

77
The plugin supports the following configuration parameters:
88

99
| Key | Description | Default |
1010
| ------------ | ----------- | ------- |
11-
| Listen | Listener network interface. | 0.0.0.0 |
12-
| Port | TCP port where listening for connections | 5170 |
13-
| Buffer\_Size | Specify the maximum buffer size in KB to receive a JSON message. If not set, the default size will be the value of _Chunk\_Size_. | |
14-
| Chunk\_Size | By default the buffer to store the incoming JSON messages, do not allocate the maximum memory allowed, instead it allocate memory when is required. The rounds of allocations are set by _Chunk\_Size_ in KB. If not set, _Chunk\_Size_ is equal to 32 (32KB). | 32 |
15-
| Format | Specify the expected payload format. It support the options _json_ and _none_. When using _json_, it expects JSON maps, when is set to _none_, it will split every record using the defined _Separator_ (option below). | json |
16-
| Separator | When the expected _Format_ is set to _none_, Fluent Bit needs a separator string to split the records. By default it uses the breakline character (LF or 0x10). | |
17-
| Source\_Address\_Key| Specify the key where the source address will be injected. | |
18-
| Threaded | Indicates whether to run this input in its own [thread](../../administration/multithreading.md#inputs). | `false` |
11+
| `Listen` | Listener network interface. | `0.0.0.0` |
12+
| `Port` | TCP port to listen for connections. | `5170` |
13+
| `Buffer_Size` | Specify the maximum buffer size in KB to receive a JSON message. If not set, the default is the value of `Chunk_Size`. | `Chunk_Size` |
14+
| `Chunk_Size` | The default buffer to store the incoming JSON messages. It doesn't allocate the maximum memory allowed; instead it allocates memory when required. The rounds of allocations are set by `Chunk_Size`. If not set, `Chunk_Size` is equal to 32 (32KB). | `32` |
15+
| `Format` | Specify the expected payload format. Supported values: `json` and `none`. `json` it expects JSON maps. When set to `none`, every record splits using the defined `Separator`. | `json` |
16+
| `Separator` | When `Format` is set to `none`, Fluent Bit needs a separator string to split the records. | `LF` or `0x10` (break line) |
17+
| `Source_Address_Key`| Specify the key to inject the source address. | _none_ |
18+
| `Threaded` | Indicates whether to run this input in its own [thread](../../administration/multithreading.md#inputs). | `false` |
1919

20-
## Getting Started
20+
## Get started
2121

22-
In order to receive JSON messages over TCP, you can run the plugin from the command line or through the configuration file:
22+
To receive JSON messages over TCP, you can run the plugin from the command line or through the configuration file:
2323

24-
### Command Line
24+
### Command line
2525

26-
From the command line you can let Fluent Bit listen for _JSON_ messages with the following options:
26+
From the command line you can let Fluent Bit listen for JSON messages with the following options:
2727

2828
```bash
29-
$ fluent-bit -i tcp -o stdout
29+
fluent-bit -i tcp -o stdout
3030
```
3131

32-
By default the service will listen an all interfaces (0.0.0.0) through TCP port 5170, optionally you can change this directly, e.g:
32+
By default the service will listen an all interfaces (`0.0.0.0`) through TCP port `5170`. Optionally you can change this directly:
3333

3434
```bash
35-
$ fluent-bit -i tcp://192.168.3.2:9090 -o stdout
35+
fluent-bit -i tcp://192.168.3.2:9090 -o stdout
3636
```
3737

38-
In the example the JSON messages will only arrive through network interface under 192.168.3.2 address and TCP Port 9090.
38+
In the example the JSON messages will only arrive through the network interface at `192.168.3.2` address and TCP Port `9090`.
3939

40-
### Configuration File
40+
### Configuration file
4141

42-
In your main configuration file append the following _Input_ & _Output_ sections:
42+
In your main configuration file append the following sections:
4343

4444
{% tabs %}
45+
{% tab title="fluent-bit.yaml" %}
46+
47+
```yaml
48+
pipeline:
49+
inputs:
50+
- name: tcp
51+
listen: 0.0.0.0
52+
port: 5170
53+
chunk_size: 32
54+
buffer_size: 64
55+
format: json
56+
outputs:
57+
- name: stdout
58+
match: '*'
59+
```
60+
61+
{% endtab %}
4562
{% tab title="fluent-bit.conf" %}
63+
4664
```python
4765
[INPUT]
4866
Name tcp
@@ -56,37 +74,27 @@ In your main configuration file append the following _Input_ & _Output_ sections
5674
Name stdout
5775
Match *
5876
```
59-
{% endtab %}
6077

61-
{% tab title="fluent-bit.yaml" %}
62-
```yaml
63-
pipeline:
64-
inputs:
65-
- name: tcp
66-
listen: 0.0.0.0
67-
port: 5170
68-
chunk_size: 32
69-
buffer_size: 64
70-
format: json
71-
outputs:
72-
- name: stdout
73-
match: '*'
74-
```
7578
{% endtab %}
7679
{% endtabs %}
7780

78-
## Testing
81+
## Test the configuration
7982

80-
Once Fluent Bit is running, you can send some messages using the _netcat_:
83+
When Fluent Bit is running, you can send some messages using `netcat`:
8184

8285
```bash
83-
$ echo '{"key 1": 123456789, "key 2": "abcdefg"}' | nc 127.0.0.1 5170
86+
echo '{"key 1": 123456789, "key 2": "abcdefg"}' | nc 127.0.0.1 5170
87+
```
88+
89+
Run Fluent Bit:
90+
91+
```shell
92+
bin/fluent-bit -i tcp -o stdout -f 1
8493
```
8594

86-
In [Fluent Bit](http://fluentbit.io) we should see the following output:
95+
You should see the following output:
8796

8897
```bash
89-
$ bin/fluent-bit -i tcp -o stdout -f 1
9098
Fluent Bit v1.x.x
9199
* Copyright (C) 2019-2020 The Fluent Bit Authors
92100
* Copyright (C) 2015-2018 Treasure Data
@@ -101,8 +109,8 @@ Fluent Bit v1.x.x
101109
[0] tcp.0: [1570115975.581246030, {"key 1"=>123456789, "key 2"=>"abcdefg"}]
102110
```
103111

104-
## Performance Considerations
112+
## Performance considerations
105113

106114
When receiving payloads in JSON format, there are high performance penalties. Parsing JSON is a very expensive task so you could expect your CPU usage increase under high load environments.
107115

108-
To get faster data ingestion, consider to use the option `Format none` to avoid JSON parsing if not needed.
116+
To get faster data ingestion, consider using the option `Format none` to avoid JSON parsing if not needed.

0 commit comments

Comments
 (0)