Skip to content

Commit 5d84e2c

Browse files
authored
Merge pull request #1991 from fluent/lynettemiles/sc-136275/update-fluent-bit-docs-pipeline-outputs-web
2 parents 933ee75 + eabf349 commit 5d84e2c

File tree

2 files changed

+31
-28
lines changed

2 files changed

+31
-28
lines changed

pipeline/outputs/websocket.md

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

3-
The **websocket** output plugin allows to flush your records into a WebSocket endpoint. For now the functionality is pretty basic, and it issues an HTTP GET request to do the handshake, and then use TCP connections to send the data records in either JSON or [MessagePack](http://msgpack.org) \(or JSON\) format.
3+
The _WebSocket_ output plugin lets you flush your records into a WebSocket endpoint. It issues an HTTP `GET` request to do the handshake, and then uses TCP connections to send the data records in either JSON or [MessagePack](http://msgpack.org) format.
44

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

7-
| Key | Description | default |
8-
|:-------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------|
9-
| Host | IP address or hostname of the target WebSocket Server | 127.0.0.1 |
10-
| Port | TCP port of the target WebSocket Server | 80 |
11-
| URI | Specify an optional HTTP URI for the target websocket server, e.g: /something | / |
12-
| Header | Add a HTTP header key/value pair. Multiple headers can be set. | |
13-
| Format | Specify the data format to be used in the HTTP request body, by default it uses _msgpack_. Other supported formats are _json_, _json\_stream_ and _json\_lines_ and _gelf_. | msgpack |
14-
| json\_date\_key | Specify the name of the date field in output | date |
15-
| json\_date\_format | Specify the format of the date. Supported formats are _double_, _epoch_, _iso8601_ (eg: _2018-05-30T09:39:52.000681Z_) and _java_sql_timestamp_ (eg: _2018-05-30 09:39:52.000681_) | double |
16-
| workers | The number of [workers](../../administration/multithreading.md#outputs) to perform flush operations for this output. | `0` |
7+
This plugin supports the following parameters:
178

18-
## Getting Started
9+
| Key | Description | Default |
10+
|:--- |:------------|:----------|
11+
| `Host` | IP address or hostname of the target WebSocket Server. | `127.0.0.1` |
12+
| `Port` | TCP port of the target WebSocket Server. | `80` |
13+
| `URI` | Specify an optional HTTP URI for the target WebSocket server. For example, `/someuri`. | `/` |
14+
| `Header` | Add a HTTP header key/value pair. Multiple headers can be set. | _none_ |
15+
| `Format` | Specify the data format to be used in the HTTP request body. Supported formats: `json`, `json_stream`, `json_lines`, `gelf`. | `msgpack` |
16+
| `json_date_key` | Specify the name of the date field in output. | `date` |
17+
| `json_date_format` | Specify the format of the date. Supported formats: `double`, `epoch`, `iso8601`, `java_sql_timestamp`. | `double` |
18+
| `workers` | The number of [workers](../../administration/multithreading.md#outputs) to perform flush operations for this output. | `0` |
1919

20-
In order to insert records into an HTTP server, you can run the plugin from the command line or through the configuration file:
20+
## Get started
2121

22-
### Command Line
22+
To insert records into an HTTP server, you can run the plugin from the command line or through the configuration file.
2323

24-
The **websocket** plugin, can read the parameters from the command line in two ways, through the **-p** argument \(property\) or setting them directly through the service URI. The URI format is the following:
24+
### Command line
25+
26+
The WebSocket plugin can read the parameters from the command line through the `-p` argument (property) or by setting them directly through the service URI. The URI format is the following:
2527

2628
```text
2729
http://host:port/something
@@ -33,7 +35,7 @@ Using the format specified, you could start Fluent Bit through:
3335
fluent-bit -i cpu -t cpu -o websocket://192.168.2.3:80/something -m '*'
3436
```
3537

36-
### Configuration File
38+
### Configuration file
3739

3840
In your main configuration file, append the following:
3941

@@ -45,7 +47,7 @@ pipeline:
4547
inputs:
4648
- name: cpu
4749
tag: cpu
48-
50+
4951
outputs:
5052
- name: websocket
5153
match: '*'
@@ -75,11 +77,11 @@ pipeline:
7577
{% endtab %}
7678
{% endtabs %}
7779

78-
Websocket plugin is working with tcp keepalive mode, please refer to [networking](https://docs.fluentbit.io/manual/v/master/administration/networking#configuration-options) section for details. Since websocket is a stateful plugin, it will decide when to send out handshake to server side, for example when plugin just begins to work or after connection with server has been dropped. In general, the interval to init a new websocket handshake would be less than the keepalive interval. With that strategy, it could detect and resume websocket connections.
80+
For details about how the WebSocket plugin works with TCP keepalive mode, see [networking](https://docs.fluentbit.io/manual/v/master/administration/networking#configuration-options). Because WebSocket is a stateful plugin, it will decide when to send out handshake to server side. For example, when the plugin begins to work or after connection with server has been dropped. In general, the interval to init a new WebSocket handshake would be less than the keepalive interval. With that strategy, it could detect and resume WebSocket connections.
7981

80-
## Testing
82+
## Tests
8183

82-
### Configuration File
84+
### Configuration file example
8385

8486
{% tabs %}
8587
{% tab title="fluent-bit.yaml" %}
@@ -91,7 +93,7 @@ pipeline:
9193
listen: 0.0.0.0
9294
port: 5170
9395
format: json
94-
96+
9597
outputs:
9698
- name: websocket
9799
match: '*'
@@ -129,16 +131,16 @@ pipeline:
129131
{% endtab %}
130132
{% endtabs %}
131133

132-
Once Fluent Bit is running, you can send some messages using the _netcat_:
134+
When Fluent Bit is running, you can send some messages using `netcat`:
133135

134136
```shell
135137
echo '{"key 1": 123456789, "key 2": "abcdefg"}' | nc 127.0.0.1 5170; sleep 35; echo '{"key 1": 123456789, "key 2": "abcdefg"}' | nc 127.0.0.1 5170
136138
```
137139

138-
In [Fluent Bit](http://fluentbit.io) we should see the following output:
140+
In [Fluent Bit](http://fluentbit.io) you should see the following output:
139141

140142
```shell
141-
$ fluent-bit -c ../conf/out_ws.conf
143+
fluent-bit -c ../conf/out_ws.conf
142144

143145
...
144146
[2021/02/05 22:17:09] [ info] [input:tcp:tcp.0] listening on 0.0.0.0:5170
@@ -166,8 +168,8 @@ $ fluent-bit -c ../conf/out_ws.conf
166168
...
167169
```
168170

169-
### Scenario Description
171+
### Scenario description
170172

171-
From the output of fluent-bit log, we see that once data has been ingested into fluent bit, plugin would perform handshake. After a while, no data or traffic is undergoing, tcp connection would be aborted. And then another piece of data arrived, a retry for websocket plugin has been triggered, with another handshake and data flush.
173+
From the output of the Fluent Bit log, you can see that when data has been ingested into Fluent Bit, the plugin performs a handshake. If no data or traffic is ongoing, the TCP connection would be aborted. When additional data arrives, a retry for WebSocket plugin triggers, with another handshake and data flush.
172174

173-
There is another scenario, once websocket server flaps in a short time, which means it goes down and up in a short time, fluent-bit would resume tcp connection immediately. But in that case, websocket output plugin is a malfunction state, it needs to restart fluent-bit to get back to work.
175+
In another scenario, if the WebSocket server goes down and up in a short time, Fluent Bit would resume the TCP connection immediately. But in that case, the WebSocket output plugin is a malfunction state, and needs to restart Fluent Bit to resume working.

vale-styles/FluentBit/Headings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,5 @@ exceptions:
111111
- Visual
112112
- Vivo Exporter
113113
- VS
114+
- WebSocket
114115
- Windows

0 commit comments

Comments
 (0)