The websocket output plugin allows to flush your records into a WebSocket endpoint. For now the functionality is pretty basic and it issues a HTTP GET request to do the handshake, and then use TCP connections to send the data records in either JSON or MessagePack (or JSON) format.
In order to insert records into a HTTP server, you can run the plugin from the command line or through the configuration file:
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:
Using the format specified, you could start Fluent Bit through:
In your main configuration file, append the following Input & Output sections:
Suggested configuration for Idle Interval is 20. Websocket plugin is working with tcp keepalive mode, please refer to networking section for details.
By default, if there is no traffic for about 30 seconds, fluent-bit would abort the tcp connection. As a result, if websocket would like to send data to the same server again, it has to reconnect. This parameter is to help to determine if websocket need to reconnect or not.
Once Fluent Bit is running, you can send some messages using the netcat:
In Fluent Bit we should see the following output:
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 has been abort. And then another piece of data arrived, a try fro websocket plugin has been triggered, following with another handshake and data flush.
Key
Description
default
Host
IP address or hostname of the target WebScoket Server
127.0.0.1
Port
TCP port of the target WebScoket Server
80
URI
Specify an optional HTTP URI for the target websocket server, e.g: /something
/
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
json_date_key
Specify the name of the date field in output
date
json_date_format
Specify the format of the date. Supported formats are double and iso8601 (eg: 2018-05-30T09:39:52.000681Z)
double
idle_interval
The interval that websocket output plugin would keep to decide if it is OK to reconnect to Websocket Server
20