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
msgpack: examples for TCP and other info (fluent#707)
* msgpack: examples for TCP and other info
Signed-off-by: Patrick Stephens <pat@calyptia.com>
* msgpack: review comments
Signed-off-by: Patrick Stephens <pat@calyptia.com>
Copy file name to clipboardExpand all lines: concepts/key-concepts.md
+2-1
Original file line number
Diff line number
Diff line change
@@ -103,7 +103,8 @@ Source events can have or not have a structure. A structure defines a set of _ke
103
103
At a low level both are just an array of bytes, but the Structured message defines _keys_ and _values_, having a structure helps to implement faster operations on data modifications.
104
104
105
105
{% hint style="info" %}
106
-
Fluent Bit **always** handles every Event message as a structured message. For performance reasons, we use a binary serialization data format called [MessagePack](https://msgpack.org/).
106
+
Fluent Bit **always** handles every Event message as a structured message.
107
+
For performance reasons, we use a binary serialization data format called [MessagePack](https://msgpack.org/).
107
108
108
109
Consider [MessagePack](https://msgpack.org/) as a binary version of JSON on steroids.
Fluent Bit **always** handles every Event message as a structured message using a binary serialization data format called [MessagePack](https://msgpack.org/).
4
+
5
+
## Fluent Bit usage
6
+
7
+
MessagePack is a standard and well-defined format, refer to the official documentation for full details.
8
+
This section provides an overview of the specific types used by Fluent Bit within the format to help anyone consuming it.
9
+
10
+
* The data structure used by Fluent Bit is a 2-length [`fixarray`](https://github.com/msgpack/msgpack/blob/master/spec.md#array-format-family) of the timestamp and the data.
11
+
* The timestamp comes from [`flb_time_append_to_msgpack`])(https://github.com/fluent/fluent-bit/blob/2138cee8f4878733956d42d82f6dcf95f0aa9339/src/flb_time.c#L197), so it’s either a `uint64`, a `float64`, or a [`fixext`](https://github.com/msgpack/msgpack/blob/master/spec.md#ext-format-family) where the 4 MSBs are the seconds (big-endian `uint32`) and 4 LSBs are nanoseconds.
12
+
* The data itself is just a [`msgpack` map](https://github.com/msgpack/msgpack/blob/master/spec.md#map-format-family) with the keys as strings.
13
+
14
+
## Example
15
+
16
+
Set up Fluent Bit to send in `msgpack` format to a specific port.
17
+
18
+
```bash
19
+
$ docker run --rm -it --network=host fluent/fluent-bit /fluent-bit/bin/fluent-bit -i cpu -o tcp://127.0.0.1:5170 -p format=msgpack -v
20
+
21
+
```
22
+
23
+
We could send this to stdout but as it is a serialized format you would end up with strange output.
24
+
As an example we use the [Python msgpack library](https://msgpack.org/#languages) to deal with it:
Copy file name to clipboardExpand all lines: pipeline/outputs/tcp-and-tls.md
+42-19
Original file line number
Diff line number
Diff line change
@@ -28,36 +28,59 @@ The following parameters are available to configure a secure channel connection
28
28
29
29
### Command Line
30
30
31
+
#### JSON format
32
+
31
33
```bash
32
34
$ bin/fluent-bit -i cpu -o tcp://127.0.0.1:5170 -p format=json_lines -v
33
35
```
34
36
35
-
We have specified to gather [CPU](https://github.com/fluent/fluent-bit-docs/tree/16f30161dc4c79d407cd9c586a0c6839d0969d97/pipeline/input/cpu.md) usage metrics and send them in JSON lines mode to a remote end-point using netcat service, e.g:
36
-
37
-
#### Start the TCP listener
37
+
We have specified to gather [CPU](https://github.com/fluent/fluent-bit-docs/tree/16f30161dc4c79d407cd9c586a0c6839d0969d97/pipeline/input/cpu.md) usage metrics and send them in JSON lines mode to a remote end-point using netcat service.
38
38
39
-
Run the following in a separate terminal, netcat will start listening for messages on TCP port 5170
39
+
Run the following in a separate terminal, `netcat` will start listening for messages on TCP port 5170.
40
+
Once it connects to Fluent Bit ou should see the output as above in JSON format:
$ bin/fluent-bit -i cpu -o tcp://127.0.0.1:5170 -p format=msgpack -v
53
+
60
54
```
61
55
62
-
No more, no less, it just works.
56
+
We could send this to stdout but as it is a serialized format you would end up with strange output.
57
+
This should really be handled by a msgpack receiver to unpack as per the details in the developer documentation [here](../../development/msgpack-format.md).
58
+
As an example we use the [Python msgpack library](https://msgpack.org/#languages) to deal with it:
0 commit comments