MQTT
The MQTT input plugin retrieves messages and data from MQTT control packets over a TCP connection. The incoming data to receive must be a JSON map.
Configuration parameters
The plugin supports the following configuration parameters:
buffer_size
Maximum payload size (in bytes) for a single MQTT message.
2048
listen
Listener network interface.
0.0.0.0
payload_key
Field name where the MQTT message payload will be stored in the output record.
none
port
TCP port where listening for connections.
1883
Notes:
buffer_sizedefaults to2048bytes; messages larger than this limit are dropped.Defaults for
listenandportare0.0.0.0and1883, so you can omit them if you want the standard MQTT listener.Payloads are expected to be JSON maps; non-JSON payloads will fail to parse.
TLS / SSL
The MQTT input plugin supports TLS/SSL. For the available options and guidance, see Transport Security.
Get started
To listen for MQTT messages, you can run the plugin from the command line or through the configuration file.
Command line
The MQTT input plugin lets Fluent Bit behave as a server. Dispatch some messages using a MQTT client. In the following example, the mosquitto tool is being used for the purpose:
Running the following command:
fluent-bit -i mqtt -t data -o stdout -m '*'Returns a response like the following:
...
[0] data: [1463775773, {"topic"=>"some/topic", "key1"=>123, "key2"=>456}]
...The following command line will send a message to the MQTT input plugin:
mosquitto_pub -m '{"key1": 123, "key2": 456}' -t some/topicConfiguration file
In your main configuration file append the following:
pipeline:
inputs:
- name: mqtt
tag: data
listen: 0.0.0.0
port: 1883
payload_key: payload
outputs:
- name: stdout
match: '*'[INPUT]
Name mqtt
Tag data
Listen 0.0.0.0
Port 1883
Payload_Key payload
[OUTPUT]
Name stdout
Match *Last updated
Was this helpful?