NATS
The nats output plugin, allows to flush your records into a NATS Server end point. The following instructions assumes that you have a fully operational NATS Server in place.
In order to flush records, the nats plugin requires to know two parameters:
parameter
description
default
host
IP address or hostname of the NATS Server
127.0.0.1
port
TCP port of the target NATS Server
4222
In order to override the default configuration values, the plugin uses the optional Fluent Bit network address format, e.g:
1
nats://host:port
Copied!

Running

Fluent Bit only requires to know that it needs to use the nats output plugin, if no extra information is given, it will use the default values specified in the above table.
1
$ bin/fluent-bit -i cpu -o nats -V -f 5
2
Fluent Bit v1.x.x
3
* Copyright (C) 2019-2020 The Fluent Bit Authors
4
* Copyright (C) 2015-2018 Treasure Data
5
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
6
* https://fluentbit.io
7
8
[2016/03/04 10:17:33] [ info] Configuration
9
flush time : 5 seconds
10
input plugins : cpu
11
collectors :
12
[2016/03/04 10:17:33] [ info] starting engine
13
cpu[all] all=3.250000 user=2.500000 system=0.750000
14
cpu[i=0] all=3.000000 user=1.000000 system=2.000000
15
cpu[i=1] all=3.000000 user=2.000000 system=1.000000
16
cpu[i=2] all=2.000000 user=2.000000 system=0.000000
17
cpu[i=3] all=6.000000 user=5.000000 system=1.000000
18
[2016/03/04 10:17:33] [debug] [in_cpu] CPU 3.25%
19
...
Copied!
As described above, the target service and storage point can be changed, e.g:

Data format

For every set of records flushed to a NATS Server, Fluent Bit uses the following JSON format:
1
[
2
[UNIX_TIMESTAMP, JSON_MAP_1],
3
[UNIX_TIMESTAMP, JSON_MAP_2],
4
[UNIX_TIMESTAMP, JSON_MAP_N],
5
]
Copied!
Each record is an individual entity represented in a JSON array that contains a UNIX_TIMESTAMP and a JSON map with a set of key/values. A summarized output of the CPU input plugin will looks as this:
1
[
2
[1457108504,{"tag":"fluentbit","cpu_p":1.500000,"user_p":1,"system_p":0.500000}],
3
[1457108505,{"tag":"fluentbit","cpu_p":4.500000,"user_p":3,"system_p":1.500000}],
4
[1457108506,{"tag":"fluentbit","cpu_p":6.500000,"user_p":4.500000,"system_p":2}]
5
]
Copied!
Last modified 2mo ago
Export as PDF
Copy link