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
Copy file name to clipboardExpand all lines: pipeline/outputs/websocket.md
+30-28Lines changed: 30 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,29 @@
1
1
# WebSocket
2
2
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.
| 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:
17
8
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`|
19
19
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
21
21
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.
23
23
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:
25
27
26
28
```text
27
29
http://host:port/something
@@ -33,7 +35,7 @@ Using the format specified, you could start Fluent Bit through:
33
35
fluent-bit -i cpu -t cpu -o websocket://192.168.2.3:80/something -m '*'
34
36
```
35
37
36
-
### Configuration File
38
+
### Configuration file
37
39
38
40
In your main configuration file, append the following:
39
41
@@ -45,7 +47,7 @@ pipeline:
45
47
inputs:
46
48
- name: cpu
47
49
tag: cpu
48
-
50
+
49
51
outputs:
50
52
- name: websocket
51
53
match: '*'
@@ -75,11 +77,11 @@ pipeline:
75
77
{% endtab %}
76
78
{% endtabs %}
77
79
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.
79
81
80
-
## Testing
82
+
## Tests
81
83
82
-
### Configuration File
84
+
### Configuration file example
83
85
84
86
{% tabs %}
85
87
{% tab title="fluent-bit.yaml" %}
@@ -91,7 +93,7 @@ pipeline:
91
93
listen: 0.0.0.0
92
94
port: 5170
93
95
format: json
94
-
96
+
95
97
outputs:
96
98
- name: websocket
97
99
match: '*'
@@ -129,16 +131,16 @@ pipeline:
129
131
{% endtab %}
130
132
{% endtabs %}
131
133
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`:
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.
172
174
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.
0 commit comments